Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5 | * Copyright (c) 2015-2016 Google, Inc. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12 | * |
| 13 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 14 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 15 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 16 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 17 | * Author: Mike Stroyan <mike@LunarG.com> |
| 18 | * Author: Tobin Ehlis <tobine@google.com> |
| 19 | * Author: Tony Barbour <tony@LunarG.com> |
| 20 | */ |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 21 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 22 | #ifdef ANDROID |
| 23 | #include "vulkan_wrapper.h" |
| 24 | #else |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 25 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 26 | #endif |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 27 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 28 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 29 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 30 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 31 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 32 | #define GLM_FORCE_RADIANS |
| 33 | #include "glm/glm.hpp" |
| 34 | #include <glm/gtc/matrix_transform.hpp> |
| 35 | |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 36 | #define PARAMETER_VALIDATION_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 37 | #define MEM_TRACKER_TESTS 1 |
| 38 | #define OBJ_TRACKER_TESTS 1 |
| 39 | #define DRAW_STATE_TESTS 1 |
| 40 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 41 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 42 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 43 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | //-------------------------------------------------------------------------------------- |
| 46 | // Mesh and VertexFormat Data |
| 47 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 48 | struct Vertex { |
| 49 | float posX, posY, posZ, posW; // Position data |
| 50 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 53 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 54 | |
| 55 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 56 | BsoFailNone = 0x00000000, |
| 57 | BsoFailLineWidth = 0x00000001, |
| 58 | BsoFailDepthBias = 0x00000002, |
| 59 | BsoFailViewport = 0x00000004, |
| 60 | BsoFailScissor = 0x00000008, |
| 61 | BsoFailBlend = 0x00000010, |
| 62 | BsoFailDepthBounds = 0x00000020, |
| 63 | BsoFailStencilReadMask = 0x00000040, |
| 64 | BsoFailStencilWriteMask = 0x00000080, |
| 65 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 66 | } BsoFailSelect; |
| 67 | |
| 68 | struct vktriangle_vs_uniform { |
| 69 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 70 | float mvp[4][4]; |
| 71 | float position[3][4]; |
| 72 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 73 | }; |
| 74 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 75 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 76 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 77 | "vec2 vertices[3];\n" |
| 78 | "out gl_PerVertex {\n" |
| 79 | " vec4 gl_Position;\n" |
| 80 | "};\n" |
| 81 | "void main() {\n" |
| 82 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 83 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 84 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 85 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 86 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 87 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 88 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 89 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 90 | "\n" |
| 91 | "layout(location = 0) out vec4 uFragColor;\n" |
| 92 | "void main(){\n" |
| 93 | " uFragColor = vec4(0,1,0,1);\n" |
| 94 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 95 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 96 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 97 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 98 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 99 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 100 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 101 | // ******************************************************** |
| 102 | // ErrorMonitor Usage: |
| 103 | // |
| 104 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 105 | // encountered log messages. Passing NULL will match all log messages. |
| 106 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 107 | // |
| 108 | // Call DesiredMsgFound to determine if the desired failure message |
| 109 | // was encountered. |
| 110 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 111 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 112 | public: |
| 113 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 114 | test_platform_thread_create_mutex(&m_mutex); |
| 115 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 116 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 117 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 118 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 119 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 120 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 121 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
| 122 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 123 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 124 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 125 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 126 | m_failureMsg.clear(); |
| 127 | m_otherMsgs.clear(); |
| 128 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 129 | m_msgFound = VK_FALSE; |
| 130 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 131 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 132 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 133 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 134 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 135 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 136 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 137 | if (m_bailout != NULL) { |
| 138 | *m_bailout = true; |
| 139 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 140 | string errorString(msgString); |
| 141 | if (msgFlags & m_msgFlags) { |
| 142 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 143 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 144 | m_otherMsgs.push_back(m_failureMsg); |
| 145 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 146 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 147 | m_msgFound = VK_TRUE; |
| 148 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 149 | } else { |
| 150 | m_otherMsgs.push_back(errorString); |
| 151 | } |
| 152 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 153 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 154 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 155 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 157 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 159 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 161 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 163 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 165 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 166 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 167 | cout << "Other error messages logged for this test were:" << endl; |
| 168 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 169 | cout << " " << *iter << endl; |
| 170 | } |
| 171 | } |
| 172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 173 | /* helpers */ |
| 174 | |
| 175 | void ExpectSuccess() { |
| 176 | // match anything |
| 177 | SetDesiredFailureMsg(~0u, ""); |
| 178 | } |
| 179 | |
| 180 | void VerifyFound() { |
| 181 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 182 | // any other messages. |
| 183 | if (!DesiredMsgFound()) { |
| 184 | DumpFailureMsgs(); |
| 185 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | void VerifyNotFound() { |
| 190 | // ExpectSuccess() configured us to match anything. Any error is a |
| 191 | // failure. |
| 192 | if (DesiredMsgFound()) { |
| 193 | DumpFailureMsgs(); |
| 194 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 195 | } |
| 196 | } |
| 197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 198 | private: |
| 199 | VkFlags m_msgFlags; |
| 200 | string m_desiredMsg; |
| 201 | string m_failureMsg; |
| 202 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 203 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 204 | bool *m_bailout; |
| 205 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 206 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 208 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 209 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 210 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 211 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 212 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 213 | (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 214 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 215 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 216 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 217 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 218 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 219 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 221 | class VkLayerTest : public VkRenderFramework { |
| 222 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 223 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 224 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 225 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 226 | BsoFailSelect failMask); |
| 227 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 228 | VkPipelineObj &pipelineobj, |
| 229 | VkDescriptorSetObj &descriptorSet, |
| 230 | BsoFailSelect failMask); |
| 231 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 232 | VkDescriptorSetObj &descriptorSet, |
| 233 | BsoFailSelect failMask) { |
| 234 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 235 | failMask); |
| 236 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 237 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 238 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 239 | VkResult BeginCommandBuffer() { |
| 240 | return BeginCommandBuffer(*m_commandBuffer); |
| 241 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 242 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 243 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 244 | uint32_t firstVertex, uint32_t firstInstance) { |
| 245 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 246 | firstInstance); |
| 247 | } |
| 248 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 249 | uint32_t firstIndex, int32_t vertexOffset, |
| 250 | uint32_t firstInstance) { |
| 251 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 252 | vertexOffset, firstInstance); |
| 253 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 254 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 255 | void QueueCommandBuffer(const VkFence &fence) { |
| 256 | m_commandBuffer->QueueCommandBuffer(fence); |
| 257 | } |
| 258 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 259 | VkDeviceSize offset, uint32_t binding) { |
| 260 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 261 | } |
| 262 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 263 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 264 | } |
| 265 | |
| 266 | protected: |
| 267 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 268 | |
| 269 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 270 | std::vector<const char *> instance_layer_names; |
| 271 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 272 | std::vector<const char *> instance_extension_names; |
| 273 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 274 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 275 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 276 | /* |
| 277 | * Since CreateDbgMsgCallback is an instance level extension call |
| 278 | * any extension / layer that utilizes that feature also needs |
| 279 | * to be enabled at create instance time. |
| 280 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 281 | // Use Threading layer first to protect others from |
| 282 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 283 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 284 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 290 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 291 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 292 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 293 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 296 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 297 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 298 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 299 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 300 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 301 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 302 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 303 | this->app_info.pApplicationName = "layer_tests"; |
| 304 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 305 | this->app_info.pEngineName = "unittest"; |
| 306 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 307 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 308 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 309 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 310 | InitFramework(instance_layer_names, device_layer_names, |
| 311 | instance_extension_names, device_extension_names, |
| 312 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | virtual void TearDown() { |
| 316 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 317 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 318 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 319 | } |
| 320 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 321 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 322 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 323 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 324 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 325 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 326 | |
| 327 | /* |
| 328 | * For render test all drawing happens in a single render pass |
| 329 | * on a single command buffer. |
| 330 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 331 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 332 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | return result; |
| 336 | } |
| 337 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 338 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 339 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 340 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 341 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 342 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 343 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 344 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 345 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 346 | |
| 347 | return result; |
| 348 | } |
| 349 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 350 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 351 | const char *fragShaderText, |
| 352 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 353 | // Create identity matrix |
| 354 | int i; |
| 355 | struct vktriangle_vs_uniform data; |
| 356 | |
| 357 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 358 | glm::mat4 View = glm::mat4(1.0f); |
| 359 | glm::mat4 Model = glm::mat4(1.0f); |
| 360 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 361 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 362 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 363 | |
| 364 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 365 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 366 | static const Vertex tri_data[] = { |
| 367 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 368 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 369 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 370 | }; |
| 371 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 372 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 373 | data.position[i][0] = tri_data[i].posX; |
| 374 | data.position[i][1] = tri_data[i].posY; |
| 375 | data.position[i][2] = tri_data[i].posZ; |
| 376 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 377 | data.color[i][0] = tri_data[i].r; |
| 378 | data.color[i][1] = tri_data[i].g; |
| 379 | data.color[i][2] = tri_data[i].b; |
| 380 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 384 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 385 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 386 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 387 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 388 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 389 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 390 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 391 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 392 | |
| 393 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 394 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 395 | pipelineobj.AddShader(&vs); |
| 396 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 397 | if (failMask & BsoFailLineWidth) { |
| 398 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 399 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 400 | ia_state.sType = |
| 401 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 402 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 403 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 404 | } |
| 405 | if (failMask & BsoFailDepthBias) { |
| 406 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 407 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 408 | rs_state.sType = |
| 409 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 410 | rs_state.depthBiasEnable = VK_TRUE; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 411 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 412 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 413 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 414 | // Viewport and scissors must stay in synch or other errors will occur than |
| 415 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 416 | if (failMask & BsoFailViewport) { |
| 417 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 418 | m_viewports.clear(); |
| 419 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 420 | } |
| 421 | if (failMask & BsoFailScissor) { |
| 422 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 423 | m_scissors.clear(); |
| 424 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 425 | } |
| 426 | if (failMask & BsoFailBlend) { |
| 427 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 428 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 429 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 430 | att_state.blendEnable = VK_TRUE; |
| 431 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 432 | } |
| 433 | if (failMask & BsoFailDepthBounds) { |
| 434 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 435 | } |
| 436 | if (failMask & BsoFailStencilReadMask) { |
| 437 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 438 | } |
| 439 | if (failMask & BsoFailStencilWriteMask) { |
| 440 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 441 | } |
| 442 | if (failMask & BsoFailStencilReference) { |
| 443 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 444 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 445 | |
| 446 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 447 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 448 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 449 | |
| 450 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 451 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 452 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 453 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 454 | |
| 455 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 456 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 457 | |
| 458 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 459 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 460 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 461 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 462 | } |
| 463 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 464 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 465 | VkPipelineObj &pipelineobj, |
| 466 | VkDescriptorSetObj &descriptorSet, |
| 467 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 468 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 469 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 470 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 471 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 472 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 473 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 474 | } |
| 475 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 476 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 477 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 478 | // correctly |
| 479 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 480 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 481 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 482 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 483 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 484 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 485 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 486 | |
| 487 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 488 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 489 | ds_ci.pNext = NULL; |
| 490 | ds_ci.depthTestEnable = VK_FALSE; |
| 491 | ds_ci.depthWriteEnable = VK_TRUE; |
| 492 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 493 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 494 | if (failMask & BsoFailDepthBounds) { |
| 495 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
| 496 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 497 | ds_ci.stencilTestEnable = VK_TRUE; |
| 498 | ds_ci.front = stencil; |
| 499 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 500 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 501 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 502 | pipelineobj.SetViewport(m_viewports); |
| 503 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 504 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 505 | VkResult err = pipelineobj.CreateVKPipeline( |
| 506 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 507 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 508 | commandBuffer->BindPipeline(pipelineobj); |
| 509 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | // ******************************************************************************************************************** |
| 513 | // ******************************************************************************************************************** |
| 514 | // ******************************************************************************************************************** |
| 515 | // ******************************************************************************************************************** |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 516 | #if PARAMETER_VALIDATION_TESTS |
| 517 | TEST_F(VkLayerTest, RequiredParameter) { |
| 518 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " |
| 519 | "pointer, array, and array count parameters"); |
| 520 | |
| 521 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 522 | |
| 523 | m_errorMonitor->SetDesiredFailureMsg( |
| 524 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 525 | "required parameter pFeatures specified as NULL"); |
| 526 | // Specify NULL for a pointer to a handle |
| 527 | // Expected to trigger an error with |
| 528 | // parameter_validation::validate_required_pointer |
| 529 | vkGetPhysicalDeviceFeatures(gpu(), NULL); |
| 530 | m_errorMonitor->VerifyFound(); |
| 531 | |
| 532 | m_errorMonitor->SetDesiredFailureMsg( |
| 533 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 534 | "required parameter pPhysicalDeviceCount specified as NULL"); |
| 535 | // Specify NULL for pointer to array count |
| 536 | // Expected to trigger an error with parameter_validation::validate_array |
| 537 | vkEnumeratePhysicalDevices(instance(), NULL, NULL); |
| 538 | m_errorMonitor->VerifyFound(); |
| 539 | |
| 540 | m_errorMonitor->SetDesiredFailureMsg( |
| 541 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 542 | "parameter viewportCount must be greater than 0"); |
| 543 | // Specify 0 for a required array count |
| 544 | // Expected to trigger an error with parameter_validation::validate_array |
| 545 | VkViewport view_port = {}; |
| 546 | m_commandBuffer->SetViewport(0, 0, &view_port); |
| 547 | m_errorMonitor->VerifyFound(); |
| 548 | |
| 549 | m_errorMonitor->SetDesiredFailureMsg( |
| 550 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 551 | "required parameter pViewports specified as NULL"); |
| 552 | // Specify NULL for a required array |
| 553 | // Expected to trigger an error with parameter_validation::validate_array |
| 554 | m_commandBuffer->SetViewport(0, 1, NULL); |
| 555 | m_errorMonitor->VerifyFound(); |
| 556 | |
| 557 | m_errorMonitor->SetDesiredFailureMsg( |
| 558 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 559 | "required parameter memory specified as VK_NULL_HANDLE"); |
| 560 | // Specify VK_NULL_HANDLE for a required handle |
| 561 | // Expected to trigger an error with |
| 562 | // parameter_validation::validate_required_handle |
| 563 | vkUnmapMemory(device(), VK_NULL_HANDLE); |
| 564 | m_errorMonitor->VerifyFound(); |
| 565 | |
| 566 | m_errorMonitor->SetDesiredFailureMsg( |
| 567 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 568 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); |
| 569 | // Specify VK_NULL_HANDLE for a required handle array entry |
| 570 | // Expected to trigger an error with |
| 571 | // parameter_validation::validate_required_handle_array |
| 572 | VkFence fence = VK_NULL_HANDLE; |
| 573 | vkResetFences(device(), 1, &fence); |
| 574 | m_errorMonitor->VerifyFound(); |
| 575 | |
| 576 | m_errorMonitor->SetDesiredFailureMsg( |
| 577 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 578 | "required parameter pAllocateInfo specified as NULL"); |
| 579 | // Specify NULL for a required struct pointer |
| 580 | // Expected to trigger an error with |
| 581 | // parameter_validation::validate_struct_type |
| 582 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 583 | vkAllocateMemory(device(), NULL, NULL, &memory); |
| 584 | m_errorMonitor->VerifyFound(); |
| 585 | |
| 586 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 587 | "value of faceMask must not be 0"); |
| 588 | // Specify 0 for a required VkFlags parameter |
| 589 | // Expected to trigger an error with parameter_validation::validate_flags |
| 590 | m_commandBuffer->SetStencilReference(0, 0); |
| 591 | m_errorMonitor->VerifyFound(); |
| 592 | |
| 593 | m_errorMonitor->SetDesiredFailureMsg( |
| 594 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 595 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); |
| 596 | // Specify 0 for a required VkFlags array entry |
| 597 | // Expected to trigger an error with |
| 598 | // parameter_validation::validate_flags_array |
| 599 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 600 | VkPipelineStageFlags stageFlags = 0; |
| 601 | VkSubmitInfo submitInfo = {}; |
| 602 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 603 | submitInfo.waitSemaphoreCount = 1; |
| 604 | submitInfo.pWaitSemaphores = &semaphore; |
| 605 | submitInfo.pWaitDstStageMask = &stageFlags; |
| 606 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); |
| 607 | m_errorMonitor->VerifyFound(); |
| 608 | } |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame^] | 609 | |
| 610 | TEST_F(VkLayerTest, InvalidStructSType) { |
| 611 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " |
| 612 | "structure's sType field"); |
| 613 | |
| 614 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 615 | |
| 616 | m_errorMonitor->SetDesiredFailureMsg( |
| 617 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 618 | "parameter pAllocateInfo->sType must be"); |
| 619 | // Zero struct memory, effectively setting sType to |
| 620 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 621 | // Expected to trigger an error with |
| 622 | // parameter_validation::validate_struct_type |
| 623 | VkMemoryAllocateInfo alloc_info = {}; |
| 624 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 625 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); |
| 626 | m_errorMonitor->VerifyFound(); |
| 627 | |
| 628 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 629 | "parameter pSubmits[0].sType must be"); |
| 630 | // Zero struct memory, effectively setting sType to |
| 631 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 632 | // Expected to trigger an error with |
| 633 | // parameter_validation::validate_struct_type_array |
| 634 | VkSubmitInfo submit_info = {}; |
| 635 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 636 | m_errorMonitor->VerifyFound(); |
| 637 | } |
| 638 | |
| 639 | TEST_F(VkLayerTest, InvalidStructPNext) { |
| 640 | TEST_DESCRIPTION( |
| 641 | "Specify an invalid value for a Vulkan structure's pNext field"); |
| 642 | |
| 643 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 644 | |
| 645 | m_errorMonitor->SetDesiredFailureMsg( |
| 646 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 647 | "value of pAllocateInfo->pNext must be NULL"); |
| 648 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be |
| 649 | // NULL |
| 650 | // Expected to trigger an error with |
| 651 | // parameter_validation::validate_struct_pnext |
| 652 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 653 | // Zero-initialization will provide the correct sType |
| 654 | VkApplicationInfo app_info = {}; |
| 655 | VkMemoryAllocateInfo alloc_info = {}; |
| 656 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 657 | alloc_info.pNext = &app_info; |
| 658 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); |
| 659 | m_errorMonitor->VerifyFound(); |
| 660 | |
| 661 | // TODO: Add non-NULL pNext case |
| 662 | } |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 663 | #endif // PARAMETER_VALIDATION_TESTS |
| 664 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 665 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 666 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 667 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 668 | { |
| 669 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 670 | VkFenceCreateInfo fenceInfo = {}; |
| 671 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 672 | fenceInfo.pNext = NULL; |
| 673 | fenceInfo.flags = 0; |
| 674 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 675 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 676 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 677 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 678 | |
| 679 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 680 | vk_testing::Buffer buffer; |
| 681 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 682 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 683 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 684 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 685 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 686 | |
| 687 | testFence.init(*m_device, fenceInfo); |
| 688 | |
| 689 | // Bypass framework since it does the waits automatically |
| 690 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 691 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 692 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 693 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 694 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 695 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 696 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 697 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 698 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 699 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 700 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 701 | |
| 702 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 703 | ASSERT_VK_SUCCESS( err ); |
| 704 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 705 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 706 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 707 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 708 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 709 | } |
| 710 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 711 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 712 | { |
| 713 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 714 | VkFenceCreateInfo fenceInfo = {}; |
| 715 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 716 | fenceInfo.pNext = NULL; |
| 717 | fenceInfo.flags = 0; |
| 718 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 719 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Calling vkBeginCommandBuffer() on active CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 720 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 721 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 722 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 723 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 724 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 725 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 726 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 727 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 728 | |
| 729 | testFence.init(*m_device, fenceInfo); |
| 730 | |
| 731 | // Bypass framework since it does the waits automatically |
| 732 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 733 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 734 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 735 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 736 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 737 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 738 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 739 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 740 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 741 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 742 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 743 | |
| 744 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 745 | ASSERT_VK_SUCCESS( err ); |
| 746 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 747 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 748 | VkCommandBufferBeginInfo info = {}; |
| 749 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 750 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 751 | info.renderPass = VK_NULL_HANDLE; |
| 752 | info.subpass = 0; |
| 753 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 754 | info.occlusionQueryEnable = VK_FALSE; |
| 755 | info.queryFlags = 0; |
| 756 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 757 | |
| 758 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 759 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 760 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 761 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 762 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 763 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 764 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 765 | // This is a positive test. No failures are expected. |
| 766 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 767 | VkResult err; |
| 768 | bool pass; |
| 769 | |
| 770 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 771 | "the buffer, create an image, and bind the same memory to " |
| 772 | "it"); |
| 773 | |
| 774 | m_errorMonitor->ExpectSuccess(); |
| 775 | |
| 776 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 777 | |
| 778 | VkBuffer buffer; |
| 779 | VkImage image; |
| 780 | VkDeviceMemory mem; |
| 781 | VkMemoryRequirements mem_reqs; |
| 782 | |
| 783 | VkBufferCreateInfo buf_info = {}; |
| 784 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 785 | buf_info.pNext = NULL; |
| 786 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 787 | buf_info.size = 256; |
| 788 | buf_info.queueFamilyIndexCount = 0; |
| 789 | buf_info.pQueueFamilyIndices = NULL; |
| 790 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 791 | buf_info.flags = 0; |
| 792 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 793 | ASSERT_VK_SUCCESS(err); |
| 794 | |
| 795 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 796 | |
| 797 | VkMemoryAllocateInfo alloc_info = {}; |
| 798 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 799 | alloc_info.pNext = NULL; |
| 800 | alloc_info.memoryTypeIndex = 0; |
| 801 | |
| 802 | // Ensure memory is big enough for both bindings |
| 803 | alloc_info.allocationSize = 0x10000; |
| 804 | |
| 805 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 806 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 807 | if (!pass) { |
| 808 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 809 | return; |
| 810 | } |
| 811 | |
| 812 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 813 | ASSERT_VK_SUCCESS(err); |
| 814 | |
| 815 | uint8_t *pData; |
| 816 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 817 | (void **)&pData); |
| 818 | ASSERT_VK_SUCCESS(err); |
| 819 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 820 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 821 | |
| 822 | vkUnmapMemory(m_device->device(), mem); |
| 823 | |
| 824 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 825 | ASSERT_VK_SUCCESS(err); |
| 826 | |
| 827 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 828 | // memory. In fact, it was never used by the GPU. |
| 829 | // Just be be sure, wait for idle. |
| 830 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 831 | vkDeviceWaitIdle(m_device->device()); |
| 832 | |
| 833 | VkImageCreateInfo image_create_info = {}; |
| 834 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 835 | image_create_info.pNext = NULL; |
| 836 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 837 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 838 | image_create_info.extent.width = 64; |
| 839 | image_create_info.extent.height = 64; |
| 840 | image_create_info.extent.depth = 1; |
| 841 | image_create_info.mipLevels = 1; |
| 842 | image_create_info.arrayLayers = 1; |
| 843 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 844 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 845 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 846 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 847 | image_create_info.queueFamilyIndexCount = 0; |
| 848 | image_create_info.pQueueFamilyIndices = NULL; |
| 849 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 850 | image_create_info.flags = 0; |
| 851 | |
| 852 | VkMemoryAllocateInfo mem_alloc = {}; |
| 853 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 854 | mem_alloc.pNext = NULL; |
| 855 | mem_alloc.allocationSize = 0; |
| 856 | mem_alloc.memoryTypeIndex = 0; |
| 857 | |
| 858 | /* Create a mappable image. It will be the texture if linear images are ok |
| 859 | * to be textures or it will be the staging image if they are not. |
| 860 | */ |
| 861 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 862 | ASSERT_VK_SUCCESS(err); |
| 863 | |
| 864 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 865 | |
| 866 | mem_alloc.allocationSize = mem_reqs.size; |
| 867 | |
| 868 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 869 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 870 | if (!pass) { |
| 871 | vkDestroyImage(m_device->device(), image, NULL); |
| 872 | return; |
| 873 | } |
| 874 | |
| 875 | // VALDIATION FAILURE: |
| 876 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 877 | ASSERT_VK_SUCCESS(err); |
| 878 | |
| 879 | m_errorMonitor->VerifyNotFound(); |
| 880 | |
| 881 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 882 | vkDestroyImage(m_device->device(), image, NULL); |
| 883 | } |
| 884 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 885 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 886 | VkResult err; |
| 887 | bool pass; |
| 888 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 889 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 890 | // following declaration (which is temporarily being moved below): |
| 891 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 892 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 893 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 894 | uint32_t swapchain_image_count = 0; |
| 895 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 896 | uint32_t image_index = 0; |
| 897 | // VkPresentInfoKHR present_info = {}; |
| 898 | |
| 899 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 900 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 901 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 902 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 903 | // Use the functions from the VK_KHR_android_surface extension without |
| 904 | // enabling that extension: |
| 905 | |
| 906 | // Create a surface: |
| 907 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
| 908 | #if 0 |
| 909 | #endif |
| 910 | m_errorMonitor->SetDesiredFailureMsg( |
| 911 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 912 | "extension was not enabled for this"); |
| 913 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 914 | &surface); |
| 915 | pass = (err != VK_SUCCESS); |
| 916 | ASSERT_TRUE(pass); |
| 917 | m_errorMonitor->VerifyFound(); |
| 918 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 919 | |
| 920 | |
| 921 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 922 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 923 | // that extension: |
| 924 | |
| 925 | // Create a surface: |
| 926 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
| 927 | #if 0 |
| 928 | #endif |
| 929 | m_errorMonitor->SetDesiredFailureMsg( |
| 930 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 931 | "extension was not enabled for this"); |
| 932 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 933 | pass = (err != VK_SUCCESS); |
| 934 | ASSERT_TRUE(pass); |
| 935 | m_errorMonitor->VerifyFound(); |
| 936 | |
| 937 | // Tell whether an mir_connection supports presentation: |
| 938 | MirConnection *mir_connection = NULL; |
| 939 | m_errorMonitor->SetDesiredFailureMsg( |
| 940 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 941 | "extension was not enabled for this"); |
| 942 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 943 | visual_id); |
| 944 | m_errorMonitor->VerifyFound(); |
| 945 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 946 | |
| 947 | |
| 948 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 949 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 950 | // enabling that extension: |
| 951 | |
| 952 | // Create a surface: |
| 953 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
| 954 | #if 0 |
| 955 | #endif |
| 956 | m_errorMonitor->SetDesiredFailureMsg( |
| 957 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 958 | "extension was not enabled for this"); |
| 959 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 960 | &surface); |
| 961 | pass = (err != VK_SUCCESS); |
| 962 | ASSERT_TRUE(pass); |
| 963 | m_errorMonitor->VerifyFound(); |
| 964 | |
| 965 | // Tell whether an wayland_display supports presentation: |
| 966 | struct wl_display wayland_display = {}; |
| 967 | m_errorMonitor->SetDesiredFailureMsg( |
| 968 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 969 | "extension was not enabled for this"); |
| 970 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 971 | &wayland_display); |
| 972 | m_errorMonitor->VerifyFound(); |
| 973 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 974 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 975 | |
| 976 | |
| 977 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 978 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 979 | // TO NON-LINUX PLATFORMS: |
| 980 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 981 | // Use the functions from the VK_KHR_win32_surface extension without |
| 982 | // enabling that extension: |
| 983 | |
| 984 | // Create a surface: |
| 985 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
| 986 | #if 0 |
| 987 | #endif |
| 988 | m_errorMonitor->SetDesiredFailureMsg( |
| 989 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 990 | "extension was not enabled for this"); |
| 991 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 992 | &surface); |
| 993 | pass = (err != VK_SUCCESS); |
| 994 | ASSERT_TRUE(pass); |
| 995 | m_errorMonitor->VerifyFound(); |
| 996 | |
| 997 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 998 | m_errorMonitor->SetDesiredFailureMsg( |
| 999 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1000 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1001 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1002 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1003 | // Set this (for now, until all platforms are supported and tested): |
| 1004 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 1005 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1006 | |
| 1007 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1008 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1009 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1010 | // TO NON-LINUX PLATFORMS: |
| 1011 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1012 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 1013 | // that extension: |
| 1014 | |
| 1015 | // Create a surface: |
| 1016 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 1017 | #if 0 |
| 1018 | #endif |
| 1019 | m_errorMonitor->SetDesiredFailureMsg( |
| 1020 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1021 | "extension was not enabled for this"); |
| 1022 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1023 | pass = (err != VK_SUCCESS); |
| 1024 | ASSERT_TRUE(pass); |
| 1025 | m_errorMonitor->VerifyFound(); |
| 1026 | |
| 1027 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1028 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1029 | xcb_visualid_t visual_id = 0; |
| 1030 | m_errorMonitor->SetDesiredFailureMsg( |
| 1031 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1032 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1033 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1034 | visual_id); |
| 1035 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1036 | // Set this (for now, until all platforms are supported and tested): |
| 1037 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1038 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1039 | |
| 1040 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1041 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1042 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 1043 | // that extension: |
| 1044 | |
| 1045 | // Create a surface: |
| 1046 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
| 1047 | #if 0 |
| 1048 | #endif |
| 1049 | m_errorMonitor->SetDesiredFailureMsg( |
| 1050 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1051 | "extension was not enabled for this"); |
| 1052 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 1053 | pass = (err != VK_SUCCESS); |
| 1054 | ASSERT_TRUE(pass); |
| 1055 | m_errorMonitor->VerifyFound(); |
| 1056 | |
| 1057 | // Tell whether an Xlib VisualID supports presentation: |
| 1058 | Display *dpy = NULL; |
| 1059 | VisualID visual = 0; |
| 1060 | m_errorMonitor->SetDesiredFailureMsg( |
| 1061 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1062 | "extension was not enabled for this"); |
| 1063 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1064 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1065 | // Set this (for now, until all platforms are supported and tested): |
| 1066 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1067 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1068 | |
| 1069 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1070 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1071 | // that extension: |
| 1072 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1073 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1074 | // Destroy a surface: |
| 1075 | m_errorMonitor->SetDesiredFailureMsg( |
| 1076 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1077 | "extension was not enabled for this"); |
| 1078 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1079 | m_errorMonitor->VerifyFound(); |
| 1080 | |
| 1081 | // Check if surface supports presentation: |
| 1082 | VkBool32 supported = false; |
| 1083 | m_errorMonitor->SetDesiredFailureMsg( |
| 1084 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1085 | "extension was not enabled for this"); |
| 1086 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1087 | pass = (err != VK_SUCCESS); |
| 1088 | ASSERT_TRUE(pass); |
| 1089 | m_errorMonitor->VerifyFound(); |
| 1090 | |
| 1091 | // Check surface capabilities: |
| 1092 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1093 | m_errorMonitor->SetDesiredFailureMsg( |
| 1094 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1095 | "extension was not enabled for this"); |
| 1096 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1097 | &capabilities); |
| 1098 | pass = (err != VK_SUCCESS); |
| 1099 | ASSERT_TRUE(pass); |
| 1100 | m_errorMonitor->VerifyFound(); |
| 1101 | |
| 1102 | // Check surface formats: |
| 1103 | uint32_t format_count = 0; |
| 1104 | VkSurfaceFormatKHR *formats = NULL; |
| 1105 | m_errorMonitor->SetDesiredFailureMsg( |
| 1106 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1107 | "extension was not enabled for this"); |
| 1108 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1109 | &format_count, formats); |
| 1110 | pass = (err != VK_SUCCESS); |
| 1111 | ASSERT_TRUE(pass); |
| 1112 | m_errorMonitor->VerifyFound(); |
| 1113 | |
| 1114 | // Check surface present modes: |
| 1115 | uint32_t present_mode_count = 0; |
| 1116 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1117 | m_errorMonitor->SetDesiredFailureMsg( |
| 1118 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1119 | "extension was not enabled for this"); |
| 1120 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1121 | &present_mode_count, present_modes); |
| 1122 | pass = (err != VK_SUCCESS); |
| 1123 | ASSERT_TRUE(pass); |
| 1124 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1125 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1126 | |
| 1127 | |
| 1128 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1129 | // that extension: |
| 1130 | |
| 1131 | // Create a swapchain: |
| 1132 | m_errorMonitor->SetDesiredFailureMsg( |
| 1133 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1134 | "extension was not enabled for this"); |
| 1135 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1136 | swapchain_create_info.pNext = NULL; |
| 1137 | #if 0 |
| 1138 | swapchain_create_info.flags = 0; |
| 1139 | swapchain_create_info.surface = 0; |
| 1140 | swapchain_create_info.minImageCount = 0; |
| 1141 | swapchain_create_info.imageFormat = 0; |
| 1142 | swapchain_create_info.imageColorSpace = 0; |
| 1143 | swapchain_create_info.imageExtent.width = 0; |
| 1144 | swapchain_create_info.imageExtent.height = 0; |
| 1145 | swapchain_create_info.imageArrayLayers = 0; |
| 1146 | swapchain_create_info.imageUsage = 0; |
| 1147 | swapchain_create_info.imageSharingMode = 0; |
| 1148 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 1149 | swapchain_create_info.preTransform = 0; |
| 1150 | swapchain_create_info.compositeAlpha = 0; |
| 1151 | swapchain_create_info.presentMode = 0; |
| 1152 | swapchain_create_info.clipped = 0; |
| 1153 | swapchain_create_info.oldSwapchain = NULL; |
| 1154 | #endif |
| 1155 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1156 | NULL, &swapchain); |
| 1157 | pass = (err != VK_SUCCESS); |
| 1158 | ASSERT_TRUE(pass); |
| 1159 | m_errorMonitor->VerifyFound(); |
| 1160 | |
| 1161 | // Get the images from the swapchain: |
| 1162 | m_errorMonitor->SetDesiredFailureMsg( |
| 1163 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1164 | "extension was not enabled for this"); |
| 1165 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1166 | &swapchain_image_count, NULL); |
| 1167 | pass = (err != VK_SUCCESS); |
| 1168 | ASSERT_TRUE(pass); |
| 1169 | m_errorMonitor->VerifyFound(); |
| 1170 | |
| 1171 | // Try to acquire an image: |
| 1172 | m_errorMonitor->SetDesiredFailureMsg( |
| 1173 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1174 | "extension was not enabled for this"); |
| 1175 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1176 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1177 | pass = (err != VK_SUCCESS); |
| 1178 | ASSERT_TRUE(pass); |
| 1179 | m_errorMonitor->VerifyFound(); |
| 1180 | |
| 1181 | // Try to present an image: |
| 1182 | #if 0 // NOTE: Currently can't test this because a real swapchain is needed |
| 1183 | // (as opposed to the fake one we created) in order for the layer to |
| 1184 | // lookup the VkDevice used to enable the extension: |
| 1185 | m_errorMonitor->SetDesiredFailureMsg( |
| 1186 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1187 | "extension was not enabled for this"); |
| 1188 | present_info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; |
| 1189 | present_info.pNext = NULL; |
| 1190 | #if 0 |
| 1191 | #endif |
| 1192 | err = vkQueuePresentKHR(m_device->m_queue, &present_info); |
| 1193 | pass = (err != VK_SUCCESS); |
| 1194 | ASSERT_TRUE(pass); |
| 1195 | m_errorMonitor->VerifyFound(); |
| 1196 | #endif |
| 1197 | |
| 1198 | // Destroy the swapchain: |
| 1199 | m_errorMonitor->SetDesiredFailureMsg( |
| 1200 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1201 | "extension was not enabled for this"); |
| 1202 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1203 | m_errorMonitor->VerifyFound(); |
| 1204 | } |
| 1205 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1206 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 1207 | VkResult err; |
| 1208 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1209 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1210 | m_errorMonitor->SetDesiredFailureMsg( |
| 1211 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1212 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 1213 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1214 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1215 | |
| 1216 | // Create an image, allocate memory, free it, and then try to bind it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1217 | VkImage image; |
| 1218 | VkDeviceMemory mem; |
| 1219 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1221 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1222 | const int32_t tex_width = 32; |
| 1223 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1224 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1225 | VkImageCreateInfo image_create_info = {}; |
| 1226 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1227 | image_create_info.pNext = NULL; |
| 1228 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1229 | image_create_info.format = tex_format; |
| 1230 | image_create_info.extent.width = tex_width; |
| 1231 | image_create_info.extent.height = tex_height; |
| 1232 | image_create_info.extent.depth = 1; |
| 1233 | image_create_info.mipLevels = 1; |
| 1234 | image_create_info.arrayLayers = 1; |
| 1235 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1236 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1237 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1238 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1239 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1240 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1241 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1242 | mem_alloc.pNext = NULL; |
| 1243 | mem_alloc.allocationSize = 0; |
| 1244 | // Introduce failure, do NOT set memProps to |
| 1245 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 1246 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1247 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1248 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1249 | ASSERT_VK_SUCCESS(err); |
| 1250 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1251 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1252 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 1253 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1254 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1255 | pass = |
| 1256 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 1257 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1258 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 1259 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1260 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 1261 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1262 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1263 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1264 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1265 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1266 | ASSERT_VK_SUCCESS(err); |
| 1267 | |
| 1268 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1269 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1270 | ASSERT_VK_SUCCESS(err); |
| 1271 | |
| 1272 | // Map memory as if to initialize the image |
| 1273 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1274 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 1275 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1276 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1277 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1278 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1279 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1280 | } |
| 1281 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1282 | TEST_F(VkLayerTest, RebindMemory) { |
| 1283 | VkResult err; |
| 1284 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1285 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1286 | m_errorMonitor->SetDesiredFailureMsg( |
| 1287 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1288 | "which has already been bound to mem object"); |
| 1289 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1290 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1291 | |
| 1292 | // Create an image, allocate memory, free it, and then try to bind it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1293 | VkImage image; |
| 1294 | VkDeviceMemory mem1; |
| 1295 | VkDeviceMemory mem2; |
| 1296 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1297 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1298 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1299 | const int32_t tex_width = 32; |
| 1300 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1301 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1302 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1303 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1304 | image_create_info.pNext = NULL; |
| 1305 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1306 | image_create_info.format = tex_format; |
| 1307 | image_create_info.extent.width = tex_width; |
| 1308 | image_create_info.extent.height = tex_height; |
| 1309 | image_create_info.extent.depth = 1; |
| 1310 | image_create_info.mipLevels = 1; |
| 1311 | image_create_info.arrayLayers = 1; |
| 1312 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1313 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1314 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1315 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1316 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1317 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1318 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1319 | mem_alloc.pNext = NULL; |
| 1320 | mem_alloc.allocationSize = 0; |
| 1321 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1322 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1323 | // Introduce failure, do NOT set memProps to |
| 1324 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1325 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1326 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1327 | ASSERT_VK_SUCCESS(err); |
| 1328 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1329 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1330 | |
| 1331 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1332 | pass = |
| 1333 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1334 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1335 | |
| 1336 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1337 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1338 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1339 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1340 | ASSERT_VK_SUCCESS(err); |
| 1341 | |
| 1342 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1343 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1344 | ASSERT_VK_SUCCESS(err); |
| 1345 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1346 | // Introduce validation failure, try to bind a different memory object to |
| 1347 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1348 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1349 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1350 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1351 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1352 | vkDestroyImage(m_device->device(), image, NULL); |
| 1353 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 1354 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1355 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1356 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1357 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1358 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1359 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1360 | m_errorMonitor->SetDesiredFailureMsg( |
| 1361 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 1362 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1363 | |
| 1364 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1365 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1366 | fenceInfo.pNext = NULL; |
| 1367 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1368 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1369 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1370 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1371 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1372 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1373 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1374 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 1375 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1376 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1377 | |
| 1378 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1379 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1380 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1381 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1382 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1383 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1384 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1385 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1386 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1387 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1388 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1389 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1390 | |
| 1391 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1392 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1393 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1394 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1395 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1396 | // This is a positive test. We used to expect error in this case but spec now |
| 1397 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1398 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1399 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1400 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1401 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1402 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1403 | fenceInfo.pNext = NULL; |
| 1404 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1405 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1406 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 1407 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1408 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 1409 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1410 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1411 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1412 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1413 | |
| 1414 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 1415 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1416 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 1417 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1418 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 1419 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1420 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1421 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1422 | |
| 1423 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1424 | VkImageObj image(m_device); |
| 1425 | // Initialize image with USAGE_INPUT_ATTACHMENT |
| 1426 | image.init(128, 128, VK_FORMAT_D32_SFLOAT_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 1427 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 1428 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1429 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1430 | VkImageView dsv; |
| 1431 | VkImageViewCreateInfo dsvci = {}; |
| 1432 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 1433 | dsvci.image = image.handle(); |
| 1434 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 1435 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 1436 | dsvci.subresourceRange.layerCount = 1; |
| 1437 | dsvci.subresourceRange.baseMipLevel = 0; |
| 1438 | dsvci.subresourceRange.levelCount = 1; |
| 1439 | dsvci.subresourceRange.aspectMask = |
| 1440 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1441 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1442 | // Create a view with depth / stencil aspect for image with different usage |
| 1443 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1444 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1445 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1446 | |
| 1447 | // Initialize buffer with TRANSFER_DST usage |
| 1448 | vk_testing::Buffer buffer; |
| 1449 | VkMemoryPropertyFlags reqs = 0; |
| 1450 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 1451 | VkBufferImageCopy region = {}; |
| 1452 | region.bufferRowLength = 128; |
| 1453 | region.bufferImageHeight = 128; |
| 1454 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1455 | region.imageSubresource.layerCount = 1; |
| 1456 | region.imageExtent.height = 16; |
| 1457 | region.imageExtent.width = 16; |
| 1458 | region.imageExtent.depth = 1; |
| 1459 | |
| 1460 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1461 | "Invalid usage flag for buffer "); |
| 1462 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 1463 | // TRANSFER_DST |
| 1464 | BeginCommandBuffer(); |
| 1465 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 1466 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 1467 | 1, ®ion); |
| 1468 | m_errorMonitor->VerifyFound(); |
| 1469 | |
| 1470 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1471 | "Invalid usage flag for image "); |
| 1472 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 1473 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 1474 | 1, ®ion); |
| 1475 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1476 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1477 | #endif // MEM_TRACKER_TESTS |
| 1478 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 1479 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 1480 | |
| 1481 | TEST_F(VkLayerTest, LeakAnObject) { |
| 1482 | VkResult err; |
| 1483 | |
| 1484 | TEST_DESCRIPTION( |
| 1485 | "Create a fence and destroy its device without first destroying the fence."); |
| 1486 | |
| 1487 | // Note that we have to create a new device since destroying the |
| 1488 | // framework's device causes Teardown() to fail and just calling Teardown |
| 1489 | // will destroy the errorMonitor. |
| 1490 | |
| 1491 | m_errorMonitor->SetDesiredFailureMsg( |
| 1492 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1493 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 1494 | |
| 1495 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1496 | |
| 1497 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 1498 | m_device->queue_props; |
| 1499 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 1500 | queue_info.reserve(queue_props.size()); |
| 1501 | std::vector<std::vector<float>> queue_priorities; |
| 1502 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 1503 | VkDeviceQueueCreateInfo qi = {}; |
| 1504 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 1505 | qi.pNext = NULL; |
| 1506 | qi.queueFamilyIndex = i; |
| 1507 | qi.queueCount = queue_props[i].queueCount; |
| 1508 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 1509 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 1510 | queue_info.push_back(qi); |
| 1511 | } |
| 1512 | |
| 1513 | std::vector<const char *> device_layer_names; |
| 1514 | std::vector<const char *> device_extension_names; |
| 1515 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 1516 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 1517 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 1518 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 1519 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 1520 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 1521 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 1522 | |
| 1523 | // The sacrificial device object |
| 1524 | VkDevice testDevice; |
| 1525 | VkDeviceCreateInfo device_create_info = {}; |
| 1526 | auto features = m_device->phy().features(); |
| 1527 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 1528 | device_create_info.pNext = NULL; |
| 1529 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 1530 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 1531 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 1532 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 1533 | device_create_info.pEnabledFeatures = &features; |
| 1534 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 1535 | ASSERT_VK_SUCCESS(err); |
| 1536 | |
| 1537 | VkFence fence; |
| 1538 | VkFenceCreateInfo fence_create_info = {}; |
| 1539 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1540 | fence_create_info.pNext = NULL; |
| 1541 | fence_create_info.flags = 0; |
| 1542 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 1543 | ASSERT_VK_SUCCESS(err); |
| 1544 | |
| 1545 | // Induce failure by not calling vkDestroyFence |
| 1546 | vkDestroyDevice(testDevice, NULL); |
| 1547 | m_errorMonitor->VerifyFound(); |
| 1548 | } |
| 1549 | |
| 1550 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 1551 | |
| 1552 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 1553 | "attempt to delete them from another."); |
| 1554 | |
| 1555 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1556 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 1557 | |
| 1558 | VkCommandPool command_pool_one; |
| 1559 | VkCommandPool command_pool_two; |
| 1560 | |
| 1561 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1562 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1563 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1564 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1565 | |
| 1566 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1567 | &command_pool_one); |
| 1568 | |
| 1569 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1570 | &command_pool_two); |
| 1571 | |
| 1572 | VkCommandBuffer command_buffer[9]; |
| 1573 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1574 | command_buffer_allocate_info.sType = |
| 1575 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1576 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 1577 | command_buffer_allocate_info.commandBufferCount = 9; |
| 1578 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1579 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1580 | command_buffer); |
| 1581 | |
| 1582 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 1583 | &command_buffer[3]); |
| 1584 | |
| 1585 | m_errorMonitor->VerifyFound(); |
| 1586 | |
| 1587 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 1588 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 1589 | } |
| 1590 | |
| 1591 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 1592 | VkResult err; |
| 1593 | |
| 1594 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 1595 | "attempt to delete them from another."); |
| 1596 | |
| 1597 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1598 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 1599 | |
| 1600 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1601 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1602 | |
| 1603 | VkDescriptorPoolSize ds_type_count = {}; |
| 1604 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1605 | ds_type_count.descriptorCount = 1; |
| 1606 | |
| 1607 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1608 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1609 | ds_pool_ci.pNext = NULL; |
| 1610 | ds_pool_ci.flags = 0; |
| 1611 | ds_pool_ci.maxSets = 1; |
| 1612 | ds_pool_ci.poolSizeCount = 1; |
| 1613 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1614 | |
| 1615 | VkDescriptorPool ds_pool_one; |
| 1616 | err = |
| 1617 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 1618 | ASSERT_VK_SUCCESS(err); |
| 1619 | |
| 1620 | // Create a second descriptor pool |
| 1621 | VkDescriptorPool ds_pool_two; |
| 1622 | err = |
| 1623 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 1624 | ASSERT_VK_SUCCESS(err); |
| 1625 | |
| 1626 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1627 | dsl_binding.binding = 0; |
| 1628 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1629 | dsl_binding.descriptorCount = 1; |
| 1630 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1631 | dsl_binding.pImmutableSamplers = NULL; |
| 1632 | |
| 1633 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1634 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1635 | ds_layout_ci.pNext = NULL; |
| 1636 | ds_layout_ci.bindingCount = 1; |
| 1637 | ds_layout_ci.pBindings = &dsl_binding; |
| 1638 | |
| 1639 | VkDescriptorSetLayout ds_layout; |
| 1640 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1641 | &ds_layout); |
| 1642 | ASSERT_VK_SUCCESS(err); |
| 1643 | |
| 1644 | VkDescriptorSet descriptorSet; |
| 1645 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 1646 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 1647 | alloc_info.descriptorSetCount = 1; |
| 1648 | alloc_info.descriptorPool = ds_pool_one; |
| 1649 | alloc_info.pSetLayouts = &ds_layout; |
| 1650 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1651 | &descriptorSet); |
| 1652 | ASSERT_VK_SUCCESS(err); |
| 1653 | |
| 1654 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 1655 | |
| 1656 | m_errorMonitor->VerifyFound(); |
| 1657 | |
| 1658 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1659 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 1660 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 1661 | } |
| 1662 | |
| 1663 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 1664 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1665 | "Invalid VkImage Object "); |
| 1666 | |
| 1667 | TEST_DESCRIPTION( |
| 1668 | "Pass an invalid image object handle into a Vulkan API call."); |
| 1669 | |
| 1670 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1671 | |
| 1672 | // Pass bogus handle into GetImageMemoryRequirements |
| 1673 | VkMemoryRequirements mem_reqs; |
| 1674 | uint64_t fakeImageHandle = 0xCADECADE; |
| 1675 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 1676 | |
| 1677 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 1678 | |
| 1679 | m_errorMonitor->VerifyFound(); |
| 1680 | } |
| 1681 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1682 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 1683 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1684 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 1685 | TEST_DESCRIPTION( |
| 1686 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 1687 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1688 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1689 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1690 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1691 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1692 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1693 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1694 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1695 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1696 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1697 | |
| 1698 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1699 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1700 | ds_pool_ci.pNext = NULL; |
| 1701 | ds_pool_ci.maxSets = 1; |
| 1702 | ds_pool_ci.poolSizeCount = 1; |
| 1703 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1704 | |
| 1705 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1706 | err = |
| 1707 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1708 | ASSERT_VK_SUCCESS(err); |
| 1709 | |
| 1710 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1711 | dsl_binding.binding = 0; |
| 1712 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1713 | dsl_binding.descriptorCount = 1; |
| 1714 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1715 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1716 | |
| 1717 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1718 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1719 | ds_layout_ci.pNext = NULL; |
| 1720 | ds_layout_ci.bindingCount = 1; |
| 1721 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1722 | |
| 1723 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1724 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1725 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1726 | ASSERT_VK_SUCCESS(err); |
| 1727 | |
| 1728 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1729 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1730 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1731 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1732 | alloc_info.descriptorPool = ds_pool; |
| 1733 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1734 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1735 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1736 | ASSERT_VK_SUCCESS(err); |
| 1737 | |
| 1738 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1739 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1740 | pipeline_layout_ci.pNext = NULL; |
| 1741 | pipeline_layout_ci.setLayoutCount = 1; |
| 1742 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1743 | |
| 1744 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1745 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1746 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1747 | ASSERT_VK_SUCCESS(err); |
| 1748 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 1749 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1750 | |
| 1751 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1752 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1753 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1754 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1755 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1756 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1757 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1758 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1759 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1760 | } |
| 1761 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1762 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 1763 | VkResult err; |
| 1764 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1765 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1766 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1767 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1768 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1769 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1770 | |
| 1771 | // Create an image, allocate memory, free it, and then try to bind it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1772 | VkImage image; |
| 1773 | VkDeviceMemory mem; |
| 1774 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1775 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1776 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1777 | const int32_t tex_width = 32; |
| 1778 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1779 | |
| 1780 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1781 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1782 | image_create_info.pNext = NULL; |
| 1783 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1784 | image_create_info.format = tex_format; |
| 1785 | image_create_info.extent.width = tex_width; |
| 1786 | image_create_info.extent.height = tex_height; |
| 1787 | image_create_info.extent.depth = 1; |
| 1788 | image_create_info.mipLevels = 1; |
| 1789 | image_create_info.arrayLayers = 1; |
| 1790 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1791 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1792 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1793 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1794 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1795 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1796 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1797 | mem_alloc.pNext = NULL; |
| 1798 | mem_alloc.allocationSize = 0; |
| 1799 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1800 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1801 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1802 | ASSERT_VK_SUCCESS(err); |
| 1803 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1804 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1805 | |
| 1806 | mem_alloc.allocationSize = mem_reqs.size; |
| 1807 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1808 | pass = |
| 1809 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1810 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1811 | |
| 1812 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1813 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1814 | ASSERT_VK_SUCCESS(err); |
| 1815 | |
| 1816 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1817 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1818 | |
| 1819 | // Try to bind free memory that has been freed |
| 1820 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1821 | // This may very well return an error. |
| 1822 | (void)err; |
| 1823 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1824 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1825 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1826 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1827 | } |
| 1828 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1829 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1830 | VkResult err; |
| 1831 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1832 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1833 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1834 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1835 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1836 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1837 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1838 | // Create an image object, allocate memory, destroy the object and then try |
| 1839 | // to bind it |
| 1840 | VkImage image; |
| 1841 | VkDeviceMemory mem; |
| 1842 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1843 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1844 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1845 | const int32_t tex_width = 32; |
| 1846 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1847 | |
| 1848 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1849 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1850 | image_create_info.pNext = NULL; |
| 1851 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1852 | image_create_info.format = tex_format; |
| 1853 | image_create_info.extent.width = tex_width; |
| 1854 | image_create_info.extent.height = tex_height; |
| 1855 | image_create_info.extent.depth = 1; |
| 1856 | image_create_info.mipLevels = 1; |
| 1857 | image_create_info.arrayLayers = 1; |
| 1858 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1859 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1860 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1861 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1862 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1863 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1864 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1865 | mem_alloc.pNext = NULL; |
| 1866 | mem_alloc.allocationSize = 0; |
| 1867 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1868 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1869 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1870 | ASSERT_VK_SUCCESS(err); |
| 1871 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1872 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1873 | |
| 1874 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1875 | pass = |
| 1876 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1877 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1878 | |
| 1879 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1880 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1881 | ASSERT_VK_SUCCESS(err); |
| 1882 | |
| 1883 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1884 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1885 | ASSERT_VK_SUCCESS(err); |
| 1886 | |
| 1887 | // Now Try to bind memory to this destroyed object |
| 1888 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1889 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1890 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1891 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1892 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1893 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1894 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1895 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1896 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1897 | #endif // OBJ_TRACKER_TESTS |
| 1898 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1899 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1900 | |
| 1901 | // This is a positive test. No errors should be generated. |
| 1902 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 1903 | |
| 1904 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1905 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 1906 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1907 | if ((m_device->queue_props.empty()) || |
| 1908 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1909 | return; |
| 1910 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1911 | m_errorMonitor->ExpectSuccess(); |
| 1912 | |
| 1913 | VkSemaphore semaphore; |
| 1914 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1915 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1916 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1917 | &semaphore); |
| 1918 | |
| 1919 | VkCommandPool command_pool; |
| 1920 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1921 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1922 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1923 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1924 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1925 | &command_pool); |
| 1926 | |
| 1927 | VkCommandBuffer command_buffer[2]; |
| 1928 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1929 | command_buffer_allocate_info.sType = |
| 1930 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1931 | command_buffer_allocate_info.commandPool = command_pool; |
| 1932 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1933 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1934 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1935 | command_buffer); |
| 1936 | |
| 1937 | VkQueue queue = VK_NULL_HANDLE; |
| 1938 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1939 | 1, &queue); |
| 1940 | |
| 1941 | { |
| 1942 | VkCommandBufferBeginInfo begin_info{}; |
| 1943 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1944 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1945 | |
| 1946 | vkCmdPipelineBarrier(command_buffer[0], |
| 1947 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1948 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1949 | 0, nullptr, 0, nullptr); |
| 1950 | |
| 1951 | VkViewport viewport{}; |
| 1952 | viewport.maxDepth = 1.0f; |
| 1953 | viewport.minDepth = 0.0f; |
| 1954 | viewport.width = 512; |
| 1955 | viewport.height = 512; |
| 1956 | viewport.x = 0; |
| 1957 | viewport.y = 0; |
| 1958 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1959 | vkEndCommandBuffer(command_buffer[0]); |
| 1960 | } |
| 1961 | { |
| 1962 | VkCommandBufferBeginInfo begin_info{}; |
| 1963 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1964 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1965 | |
| 1966 | VkViewport viewport{}; |
| 1967 | viewport.maxDepth = 1.0f; |
| 1968 | viewport.minDepth = 0.0f; |
| 1969 | viewport.width = 512; |
| 1970 | viewport.height = 512; |
| 1971 | viewport.x = 0; |
| 1972 | viewport.y = 0; |
| 1973 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1974 | vkEndCommandBuffer(command_buffer[1]); |
| 1975 | } |
| 1976 | { |
| 1977 | VkSubmitInfo submit_info{}; |
| 1978 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1979 | submit_info.commandBufferCount = 1; |
| 1980 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1981 | submit_info.signalSemaphoreCount = 1; |
| 1982 | submit_info.pSignalSemaphores = &semaphore; |
| 1983 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1984 | } |
| 1985 | { |
| 1986 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1987 | VkSubmitInfo submit_info{}; |
| 1988 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1989 | submit_info.commandBufferCount = 1; |
| 1990 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1991 | submit_info.waitSemaphoreCount = 1; |
| 1992 | submit_info.pWaitSemaphores = &semaphore; |
| 1993 | submit_info.pWaitDstStageMask = flags; |
| 1994 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1995 | } |
| 1996 | |
| 1997 | vkQueueWaitIdle(m_device->m_queue); |
| 1998 | |
| 1999 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2000 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2001 | &command_buffer[0]); |
| 2002 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2003 | |
| 2004 | m_errorMonitor->VerifyNotFound(); |
| 2005 | } |
| 2006 | |
| 2007 | // This is a positive test. No errors should be generated. |
| 2008 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 2009 | |
| 2010 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2011 | "submitted on separate queues, the second having a fence" |
| 2012 | "followed by a QueueWaitIdle."); |
| 2013 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2014 | if ((m_device->queue_props.empty()) || |
| 2015 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2016 | return; |
| 2017 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2018 | m_errorMonitor->ExpectSuccess(); |
| 2019 | |
| 2020 | VkFence fence; |
| 2021 | VkFenceCreateInfo fence_create_info{}; |
| 2022 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2023 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2024 | |
| 2025 | VkSemaphore semaphore; |
| 2026 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2027 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2028 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2029 | &semaphore); |
| 2030 | |
| 2031 | VkCommandPool command_pool; |
| 2032 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2033 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2034 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2035 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2036 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2037 | &command_pool); |
| 2038 | |
| 2039 | VkCommandBuffer command_buffer[2]; |
| 2040 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2041 | command_buffer_allocate_info.sType = |
| 2042 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2043 | command_buffer_allocate_info.commandPool = command_pool; |
| 2044 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2045 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2046 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2047 | command_buffer); |
| 2048 | |
| 2049 | VkQueue queue = VK_NULL_HANDLE; |
| 2050 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2051 | 1, &queue); |
| 2052 | |
| 2053 | { |
| 2054 | VkCommandBufferBeginInfo begin_info{}; |
| 2055 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2056 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2057 | |
| 2058 | vkCmdPipelineBarrier(command_buffer[0], |
| 2059 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2060 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2061 | 0, nullptr, 0, nullptr); |
| 2062 | |
| 2063 | VkViewport viewport{}; |
| 2064 | viewport.maxDepth = 1.0f; |
| 2065 | viewport.minDepth = 0.0f; |
| 2066 | viewport.width = 512; |
| 2067 | viewport.height = 512; |
| 2068 | viewport.x = 0; |
| 2069 | viewport.y = 0; |
| 2070 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2071 | vkEndCommandBuffer(command_buffer[0]); |
| 2072 | } |
| 2073 | { |
| 2074 | VkCommandBufferBeginInfo begin_info{}; |
| 2075 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2076 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2077 | |
| 2078 | VkViewport viewport{}; |
| 2079 | viewport.maxDepth = 1.0f; |
| 2080 | viewport.minDepth = 0.0f; |
| 2081 | viewport.width = 512; |
| 2082 | viewport.height = 512; |
| 2083 | viewport.x = 0; |
| 2084 | viewport.y = 0; |
| 2085 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2086 | vkEndCommandBuffer(command_buffer[1]); |
| 2087 | } |
| 2088 | { |
| 2089 | VkSubmitInfo submit_info{}; |
| 2090 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2091 | submit_info.commandBufferCount = 1; |
| 2092 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2093 | submit_info.signalSemaphoreCount = 1; |
| 2094 | submit_info.pSignalSemaphores = &semaphore; |
| 2095 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2096 | } |
| 2097 | { |
| 2098 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2099 | VkSubmitInfo submit_info{}; |
| 2100 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2101 | submit_info.commandBufferCount = 1; |
| 2102 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2103 | submit_info.waitSemaphoreCount = 1; |
| 2104 | submit_info.pWaitSemaphores = &semaphore; |
| 2105 | submit_info.pWaitDstStageMask = flags; |
| 2106 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2107 | } |
| 2108 | |
| 2109 | vkQueueWaitIdle(m_device->m_queue); |
| 2110 | |
| 2111 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2112 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2113 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2114 | &command_buffer[0]); |
| 2115 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2116 | |
| 2117 | m_errorMonitor->VerifyNotFound(); |
| 2118 | } |
| 2119 | |
| 2120 | // This is a positive test. No errors should be generated. |
| 2121 | TEST_F(VkLayerTest, |
| 2122 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 2123 | |
| 2124 | TEST_DESCRIPTION( |
| 2125 | "Two command buffers, each in a separate QueueSubmit call " |
| 2126 | "submitted on separate queues, the second having a fence" |
| 2127 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 2128 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2129 | if ((m_device->queue_props.empty()) || |
| 2130 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2131 | return; |
| 2132 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2133 | m_errorMonitor->ExpectSuccess(); |
| 2134 | |
| 2135 | VkFence fence; |
| 2136 | VkFenceCreateInfo fence_create_info{}; |
| 2137 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2138 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2139 | |
| 2140 | VkSemaphore semaphore; |
| 2141 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2142 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2143 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2144 | &semaphore); |
| 2145 | |
| 2146 | VkCommandPool command_pool; |
| 2147 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2148 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2149 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2150 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2151 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2152 | &command_pool); |
| 2153 | |
| 2154 | VkCommandBuffer command_buffer[2]; |
| 2155 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2156 | command_buffer_allocate_info.sType = |
| 2157 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2158 | command_buffer_allocate_info.commandPool = command_pool; |
| 2159 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2160 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2161 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2162 | command_buffer); |
| 2163 | |
| 2164 | VkQueue queue = VK_NULL_HANDLE; |
| 2165 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2166 | 1, &queue); |
| 2167 | |
| 2168 | { |
| 2169 | VkCommandBufferBeginInfo begin_info{}; |
| 2170 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2171 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2172 | |
| 2173 | vkCmdPipelineBarrier(command_buffer[0], |
| 2174 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2175 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2176 | 0, nullptr, 0, nullptr); |
| 2177 | |
| 2178 | VkViewport viewport{}; |
| 2179 | viewport.maxDepth = 1.0f; |
| 2180 | viewport.minDepth = 0.0f; |
| 2181 | viewport.width = 512; |
| 2182 | viewport.height = 512; |
| 2183 | viewport.x = 0; |
| 2184 | viewport.y = 0; |
| 2185 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2186 | vkEndCommandBuffer(command_buffer[0]); |
| 2187 | } |
| 2188 | { |
| 2189 | VkCommandBufferBeginInfo begin_info{}; |
| 2190 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2191 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2192 | |
| 2193 | VkViewport viewport{}; |
| 2194 | viewport.maxDepth = 1.0f; |
| 2195 | viewport.minDepth = 0.0f; |
| 2196 | viewport.width = 512; |
| 2197 | viewport.height = 512; |
| 2198 | viewport.x = 0; |
| 2199 | viewport.y = 0; |
| 2200 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2201 | vkEndCommandBuffer(command_buffer[1]); |
| 2202 | } |
| 2203 | { |
| 2204 | VkSubmitInfo submit_info{}; |
| 2205 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2206 | submit_info.commandBufferCount = 1; |
| 2207 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2208 | submit_info.signalSemaphoreCount = 1; |
| 2209 | submit_info.pSignalSemaphores = &semaphore; |
| 2210 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2211 | } |
| 2212 | { |
| 2213 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2214 | VkSubmitInfo submit_info{}; |
| 2215 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2216 | submit_info.commandBufferCount = 1; |
| 2217 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2218 | submit_info.waitSemaphoreCount = 1; |
| 2219 | submit_info.pWaitSemaphores = &semaphore; |
| 2220 | submit_info.pWaitDstStageMask = flags; |
| 2221 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2222 | } |
| 2223 | |
| 2224 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2225 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2226 | |
| 2227 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2228 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2229 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2230 | &command_buffer[0]); |
| 2231 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2232 | |
| 2233 | m_errorMonitor->VerifyNotFound(); |
| 2234 | } |
| 2235 | |
| 2236 | // This is a positive test. No errors should be generated. |
| 2237 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 2238 | |
| 2239 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2240 | "submitted on separate queues, the second having a fence, " |
| 2241 | "followed by a WaitForFences call."); |
| 2242 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2243 | if ((m_device->queue_props.empty()) || |
| 2244 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2245 | return; |
| 2246 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2247 | m_errorMonitor->ExpectSuccess(); |
| 2248 | |
| 2249 | VkFence fence; |
| 2250 | VkFenceCreateInfo fence_create_info{}; |
| 2251 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2252 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2253 | |
| 2254 | VkSemaphore semaphore; |
| 2255 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2256 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2257 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2258 | &semaphore); |
| 2259 | |
| 2260 | VkCommandPool command_pool; |
| 2261 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2262 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2263 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2264 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2265 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2266 | &command_pool); |
| 2267 | |
| 2268 | VkCommandBuffer command_buffer[2]; |
| 2269 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2270 | command_buffer_allocate_info.sType = |
| 2271 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2272 | command_buffer_allocate_info.commandPool = command_pool; |
| 2273 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2274 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2275 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2276 | command_buffer); |
| 2277 | |
| 2278 | VkQueue queue = VK_NULL_HANDLE; |
| 2279 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2280 | 1, &queue); |
| 2281 | |
| 2282 | |
| 2283 | { |
| 2284 | VkCommandBufferBeginInfo begin_info{}; |
| 2285 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2286 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2287 | |
| 2288 | vkCmdPipelineBarrier(command_buffer[0], |
| 2289 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2290 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2291 | 0, nullptr, 0, nullptr); |
| 2292 | |
| 2293 | VkViewport viewport{}; |
| 2294 | viewport.maxDepth = 1.0f; |
| 2295 | viewport.minDepth = 0.0f; |
| 2296 | viewport.width = 512; |
| 2297 | viewport.height = 512; |
| 2298 | viewport.x = 0; |
| 2299 | viewport.y = 0; |
| 2300 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2301 | vkEndCommandBuffer(command_buffer[0]); |
| 2302 | } |
| 2303 | { |
| 2304 | VkCommandBufferBeginInfo begin_info{}; |
| 2305 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2306 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2307 | |
| 2308 | VkViewport viewport{}; |
| 2309 | viewport.maxDepth = 1.0f; |
| 2310 | viewport.minDepth = 0.0f; |
| 2311 | viewport.width = 512; |
| 2312 | viewport.height = 512; |
| 2313 | viewport.x = 0; |
| 2314 | viewport.y = 0; |
| 2315 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2316 | vkEndCommandBuffer(command_buffer[1]); |
| 2317 | } |
| 2318 | { |
| 2319 | VkSubmitInfo submit_info{}; |
| 2320 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2321 | submit_info.commandBufferCount = 1; |
| 2322 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2323 | submit_info.signalSemaphoreCount = 1; |
| 2324 | submit_info.pSignalSemaphores = &semaphore; |
| 2325 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2326 | } |
| 2327 | { |
| 2328 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2329 | VkSubmitInfo submit_info{}; |
| 2330 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2331 | submit_info.commandBufferCount = 1; |
| 2332 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2333 | submit_info.waitSemaphoreCount = 1; |
| 2334 | submit_info.pWaitSemaphores = &semaphore; |
| 2335 | submit_info.pWaitDstStageMask = flags; |
| 2336 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2337 | } |
| 2338 | |
| 2339 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2340 | |
| 2341 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2342 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2343 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2344 | &command_buffer[0]); |
| 2345 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2346 | |
| 2347 | m_errorMonitor->VerifyNotFound(); |
| 2348 | } |
| 2349 | |
| 2350 | // This is a positive test. No errors should be generated. |
| 2351 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 2352 | |
| 2353 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2354 | "on the same queue, sharing a signal/wait semaphore, the " |
| 2355 | "second having a fence, " |
| 2356 | "followed by a WaitForFences call."); |
| 2357 | |
| 2358 | m_errorMonitor->ExpectSuccess(); |
| 2359 | |
| 2360 | VkFence fence; |
| 2361 | VkFenceCreateInfo fence_create_info{}; |
| 2362 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2363 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2364 | |
| 2365 | VkSemaphore semaphore; |
| 2366 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2367 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2368 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2369 | &semaphore); |
| 2370 | |
| 2371 | VkCommandPool command_pool; |
| 2372 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2373 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2374 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2375 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2376 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2377 | &command_pool); |
| 2378 | |
| 2379 | VkCommandBuffer command_buffer[2]; |
| 2380 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2381 | command_buffer_allocate_info.sType = |
| 2382 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2383 | command_buffer_allocate_info.commandPool = command_pool; |
| 2384 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2385 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2386 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2387 | command_buffer); |
| 2388 | |
| 2389 | { |
| 2390 | VkCommandBufferBeginInfo begin_info{}; |
| 2391 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2392 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2393 | |
| 2394 | vkCmdPipelineBarrier(command_buffer[0], |
| 2395 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2396 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2397 | 0, nullptr, 0, nullptr); |
| 2398 | |
| 2399 | VkViewport viewport{}; |
| 2400 | viewport.maxDepth = 1.0f; |
| 2401 | viewport.minDepth = 0.0f; |
| 2402 | viewport.width = 512; |
| 2403 | viewport.height = 512; |
| 2404 | viewport.x = 0; |
| 2405 | viewport.y = 0; |
| 2406 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2407 | vkEndCommandBuffer(command_buffer[0]); |
| 2408 | } |
| 2409 | { |
| 2410 | VkCommandBufferBeginInfo begin_info{}; |
| 2411 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2412 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2413 | |
| 2414 | VkViewport viewport{}; |
| 2415 | viewport.maxDepth = 1.0f; |
| 2416 | viewport.minDepth = 0.0f; |
| 2417 | viewport.width = 512; |
| 2418 | viewport.height = 512; |
| 2419 | viewport.x = 0; |
| 2420 | viewport.y = 0; |
| 2421 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2422 | vkEndCommandBuffer(command_buffer[1]); |
| 2423 | } |
| 2424 | { |
| 2425 | VkSubmitInfo submit_info{}; |
| 2426 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2427 | submit_info.commandBufferCount = 1; |
| 2428 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2429 | submit_info.signalSemaphoreCount = 1; |
| 2430 | submit_info.pSignalSemaphores = &semaphore; |
| 2431 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2432 | } |
| 2433 | { |
| 2434 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2435 | VkSubmitInfo submit_info{}; |
| 2436 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2437 | submit_info.commandBufferCount = 1; |
| 2438 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2439 | submit_info.waitSemaphoreCount = 1; |
| 2440 | submit_info.pWaitSemaphores = &semaphore; |
| 2441 | submit_info.pWaitDstStageMask = flags; |
| 2442 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2443 | } |
| 2444 | |
| 2445 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2446 | |
| 2447 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2448 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2449 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2450 | &command_buffer[0]); |
| 2451 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2452 | |
| 2453 | m_errorMonitor->VerifyNotFound(); |
| 2454 | } |
| 2455 | |
| 2456 | // This is a positive test. No errors should be generated. |
| 2457 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 2458 | |
| 2459 | TEST_DESCRIPTION( |
| 2460 | "Two command buffers, each in a separate QueueSubmit call " |
| 2461 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 2462 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 2463 | |
| 2464 | m_errorMonitor->ExpectSuccess(); |
| 2465 | |
| 2466 | VkFence fence; |
| 2467 | VkFenceCreateInfo fence_create_info{}; |
| 2468 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2469 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2470 | |
| 2471 | VkCommandPool command_pool; |
| 2472 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2473 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2474 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2475 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2476 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2477 | &command_pool); |
| 2478 | |
| 2479 | VkCommandBuffer command_buffer[2]; |
| 2480 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2481 | command_buffer_allocate_info.sType = |
| 2482 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2483 | command_buffer_allocate_info.commandPool = command_pool; |
| 2484 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2485 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2486 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2487 | command_buffer); |
| 2488 | |
| 2489 | { |
| 2490 | VkCommandBufferBeginInfo begin_info{}; |
| 2491 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2492 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2493 | |
| 2494 | vkCmdPipelineBarrier(command_buffer[0], |
| 2495 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2496 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2497 | 0, nullptr, 0, nullptr); |
| 2498 | |
| 2499 | VkViewport viewport{}; |
| 2500 | viewport.maxDepth = 1.0f; |
| 2501 | viewport.minDepth = 0.0f; |
| 2502 | viewport.width = 512; |
| 2503 | viewport.height = 512; |
| 2504 | viewport.x = 0; |
| 2505 | viewport.y = 0; |
| 2506 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2507 | vkEndCommandBuffer(command_buffer[0]); |
| 2508 | } |
| 2509 | { |
| 2510 | VkCommandBufferBeginInfo begin_info{}; |
| 2511 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2512 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2513 | |
| 2514 | VkViewport viewport{}; |
| 2515 | viewport.maxDepth = 1.0f; |
| 2516 | viewport.minDepth = 0.0f; |
| 2517 | viewport.width = 512; |
| 2518 | viewport.height = 512; |
| 2519 | viewport.x = 0; |
| 2520 | viewport.y = 0; |
| 2521 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2522 | vkEndCommandBuffer(command_buffer[1]); |
| 2523 | } |
| 2524 | { |
| 2525 | VkSubmitInfo submit_info{}; |
| 2526 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2527 | submit_info.commandBufferCount = 1; |
| 2528 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2529 | submit_info.signalSemaphoreCount = 0; |
| 2530 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2531 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2532 | } |
| 2533 | { |
| 2534 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2535 | VkSubmitInfo submit_info{}; |
| 2536 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2537 | submit_info.commandBufferCount = 1; |
| 2538 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2539 | submit_info.waitSemaphoreCount = 0; |
| 2540 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2541 | submit_info.pWaitDstStageMask = flags; |
| 2542 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2543 | } |
| 2544 | |
| 2545 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 2546 | |
| 2547 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2548 | |
| 2549 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2550 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2551 | &command_buffer[0]); |
| 2552 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2553 | |
| 2554 | m_errorMonitor->VerifyNotFound(); |
| 2555 | } |
| 2556 | |
| 2557 | // This is a positive test. No errors should be generated. |
| 2558 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 2559 | |
| 2560 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2561 | "on the same queue, the second having a fence, followed " |
| 2562 | "by a WaitForFences call."); |
| 2563 | |
| 2564 | m_errorMonitor->ExpectSuccess(); |
| 2565 | |
| 2566 | VkFence fence; |
| 2567 | VkFenceCreateInfo fence_create_info{}; |
| 2568 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2569 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2570 | |
| 2571 | VkCommandPool command_pool; |
| 2572 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2573 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2574 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2575 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2576 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2577 | &command_pool); |
| 2578 | |
| 2579 | VkCommandBuffer command_buffer[2]; |
| 2580 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2581 | command_buffer_allocate_info.sType = |
| 2582 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2583 | command_buffer_allocate_info.commandPool = command_pool; |
| 2584 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2585 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2586 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2587 | command_buffer); |
| 2588 | |
| 2589 | { |
| 2590 | VkCommandBufferBeginInfo begin_info{}; |
| 2591 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2592 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2593 | |
| 2594 | vkCmdPipelineBarrier(command_buffer[0], |
| 2595 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2596 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2597 | 0, nullptr, 0, nullptr); |
| 2598 | |
| 2599 | VkViewport viewport{}; |
| 2600 | viewport.maxDepth = 1.0f; |
| 2601 | viewport.minDepth = 0.0f; |
| 2602 | viewport.width = 512; |
| 2603 | viewport.height = 512; |
| 2604 | viewport.x = 0; |
| 2605 | viewport.y = 0; |
| 2606 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2607 | vkEndCommandBuffer(command_buffer[0]); |
| 2608 | } |
| 2609 | { |
| 2610 | VkCommandBufferBeginInfo begin_info{}; |
| 2611 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2612 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2613 | |
| 2614 | VkViewport viewport{}; |
| 2615 | viewport.maxDepth = 1.0f; |
| 2616 | viewport.minDepth = 0.0f; |
| 2617 | viewport.width = 512; |
| 2618 | viewport.height = 512; |
| 2619 | viewport.x = 0; |
| 2620 | viewport.y = 0; |
| 2621 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2622 | vkEndCommandBuffer(command_buffer[1]); |
| 2623 | } |
| 2624 | { |
| 2625 | VkSubmitInfo submit_info{}; |
| 2626 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2627 | submit_info.commandBufferCount = 1; |
| 2628 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2629 | submit_info.signalSemaphoreCount = 0; |
| 2630 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2631 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2632 | } |
| 2633 | { |
| 2634 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2635 | VkSubmitInfo submit_info{}; |
| 2636 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2637 | submit_info.commandBufferCount = 1; |
| 2638 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2639 | submit_info.waitSemaphoreCount = 0; |
| 2640 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2641 | submit_info.pWaitDstStageMask = flags; |
| 2642 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2643 | } |
| 2644 | |
| 2645 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2646 | |
| 2647 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2648 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2649 | &command_buffer[0]); |
| 2650 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2651 | |
| 2652 | m_errorMonitor->VerifyNotFound(); |
| 2653 | } |
| 2654 | |
| 2655 | // This is a positive test. No errors should be generated. |
| 2656 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 2657 | |
| 2658 | TEST_DESCRIPTION( |
| 2659 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 2660 | "QueueSubmit call followed by a WaitForFences call."); |
| 2661 | |
| 2662 | m_errorMonitor->ExpectSuccess(); |
| 2663 | |
| 2664 | VkFence fence; |
| 2665 | VkFenceCreateInfo fence_create_info{}; |
| 2666 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2667 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2668 | |
| 2669 | VkSemaphore semaphore; |
| 2670 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2671 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2672 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2673 | &semaphore); |
| 2674 | |
| 2675 | VkCommandPool command_pool; |
| 2676 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2677 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2678 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2679 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2680 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2681 | &command_pool); |
| 2682 | |
| 2683 | VkCommandBuffer command_buffer[2]; |
| 2684 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2685 | command_buffer_allocate_info.sType = |
| 2686 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2687 | command_buffer_allocate_info.commandPool = command_pool; |
| 2688 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2689 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2690 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2691 | command_buffer); |
| 2692 | |
| 2693 | { |
| 2694 | VkCommandBufferBeginInfo begin_info{}; |
| 2695 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2696 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2697 | |
| 2698 | vkCmdPipelineBarrier(command_buffer[0], |
| 2699 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2700 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2701 | 0, nullptr, 0, nullptr); |
| 2702 | |
| 2703 | VkViewport viewport{}; |
| 2704 | viewport.maxDepth = 1.0f; |
| 2705 | viewport.minDepth = 0.0f; |
| 2706 | viewport.width = 512; |
| 2707 | viewport.height = 512; |
| 2708 | viewport.x = 0; |
| 2709 | viewport.y = 0; |
| 2710 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2711 | vkEndCommandBuffer(command_buffer[0]); |
| 2712 | } |
| 2713 | { |
| 2714 | VkCommandBufferBeginInfo begin_info{}; |
| 2715 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2716 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2717 | |
| 2718 | VkViewport viewport{}; |
| 2719 | viewport.maxDepth = 1.0f; |
| 2720 | viewport.minDepth = 0.0f; |
| 2721 | viewport.width = 512; |
| 2722 | viewport.height = 512; |
| 2723 | viewport.x = 0; |
| 2724 | viewport.y = 0; |
| 2725 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2726 | vkEndCommandBuffer(command_buffer[1]); |
| 2727 | } |
| 2728 | { |
| 2729 | VkSubmitInfo submit_info[2]; |
| 2730 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2731 | |
| 2732 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2733 | submit_info[0].pNext = NULL; |
| 2734 | submit_info[0].commandBufferCount = 1; |
| 2735 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 2736 | submit_info[0].signalSemaphoreCount = 1; |
| 2737 | submit_info[0].pSignalSemaphores = &semaphore; |
| 2738 | submit_info[0].waitSemaphoreCount = 0; |
| 2739 | submit_info[0].pWaitSemaphores = NULL; |
| 2740 | submit_info[0].pWaitDstStageMask = 0; |
| 2741 | |
| 2742 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2743 | submit_info[1].pNext = NULL; |
| 2744 | submit_info[1].commandBufferCount = 1; |
| 2745 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 2746 | submit_info[1].waitSemaphoreCount = 1; |
| 2747 | submit_info[1].pWaitSemaphores = &semaphore; |
| 2748 | submit_info[1].pWaitDstStageMask = flags; |
| 2749 | submit_info[1].signalSemaphoreCount = 0; |
| 2750 | submit_info[1].pSignalSemaphores = NULL; |
| 2751 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 2752 | } |
| 2753 | |
| 2754 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2755 | |
| 2756 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2757 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2758 | &command_buffer[0]); |
| 2759 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2760 | |
| 2761 | m_errorMonitor->VerifyNotFound(); |
| 2762 | } |
| 2763 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2764 | TEST_F(VkLayerTest, DynamicStatesNotBound) { |
| 2765 | TEST_DESCRIPTION( |
| 2766 | "Run a series of simple draw calls to validate all the different " |
| 2767 | "failure cases that can occur when dynamic state is required but not " |
| 2768 | "correctly bound." |
| 2769 | "Here are the different dynamic state cases verified by this test:\n" |
| 2770 | "-Line Width\n-Depth Bias\n-Viewport State\n-Scissor State\n-Blend " |
| 2771 | "State\n-Depth Bounds\n-Stencil Read Mask\n-Stencil Write " |
| 2772 | "Mask\n-Stencil Reference"); |
| 2773 | |
| 2774 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2775 | m_errorMonitor->SetDesiredFailureMsg( |
| 2776 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2777 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2778 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2779 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2780 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2781 | // Dynamic depth bias |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2782 | m_errorMonitor->SetDesiredFailureMsg( |
| 2783 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2784 | "Dynamic depth bias state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2785 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2786 | BsoFailDepthBias); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2787 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2788 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2789 | m_errorMonitor->SetDesiredFailureMsg( |
| 2790 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2791 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2792 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2793 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2794 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2795 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2796 | m_errorMonitor->SetDesiredFailureMsg( |
| 2797 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2798 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2799 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2800 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2801 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2802 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2803 | m_errorMonitor->SetDesiredFailureMsg( |
| 2804 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2805 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2806 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2807 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2808 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2809 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2810 | m_errorMonitor->SetDesiredFailureMsg( |
| 2811 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2812 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2813 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2814 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2815 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2816 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2817 | m_errorMonitor->SetDesiredFailureMsg( |
| 2818 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2819 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2820 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2821 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2822 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2823 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2824 | m_errorMonitor->SetDesiredFailureMsg( |
| 2825 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2826 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2827 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2828 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2829 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 2830 | } |
| 2831 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2832 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2833 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2834 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2835 | m_errorMonitor->SetDesiredFailureMsg( |
| 2836 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2837 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 2838 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2839 | |
| 2840 | VkFenceCreateInfo fenceInfo = {}; |
| 2841 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2842 | fenceInfo.pNext = NULL; |
| 2843 | fenceInfo.flags = 0; |
| 2844 | |
| 2845 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2846 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2847 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2848 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2849 | // We luck out b/c by default the framework creates CB w/ the |
| 2850 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2851 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2852 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2853 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2854 | EndCommandBuffer(); |
| 2855 | |
| 2856 | testFence.init(*m_device, fenceInfo); |
| 2857 | |
| 2858 | // Bypass framework since it does the waits automatically |
| 2859 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2860 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2861 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2862 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2863 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2864 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2865 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2866 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2867 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2868 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2869 | submit_info.pSignalSemaphores = NULL; |
| 2870 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2871 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 2872 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2873 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2874 | // Cause validation error by re-submitting cmd buffer that should only be |
| 2875 | // submitted once |
| 2876 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2877 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2878 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2879 | } |
| 2880 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2881 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2882 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2883 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2884 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2885 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2886 | "Unable to allocate 1 descriptors of " |
| 2887 | "type " |
| 2888 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2889 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2890 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2891 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2892 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2893 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 2894 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2895 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2896 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2897 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2898 | |
| 2899 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2900 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2901 | ds_pool_ci.pNext = NULL; |
| 2902 | ds_pool_ci.flags = 0; |
| 2903 | ds_pool_ci.maxSets = 1; |
| 2904 | ds_pool_ci.poolSizeCount = 1; |
| 2905 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2906 | |
| 2907 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2908 | err = |
| 2909 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2910 | ASSERT_VK_SUCCESS(err); |
| 2911 | |
| 2912 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2913 | dsl_binding.binding = 0; |
| 2914 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2915 | dsl_binding.descriptorCount = 1; |
| 2916 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2917 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2918 | |
| 2919 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2920 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2921 | ds_layout_ci.pNext = NULL; |
| 2922 | ds_layout_ci.bindingCount = 1; |
| 2923 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2924 | |
| 2925 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2926 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2927 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2928 | ASSERT_VK_SUCCESS(err); |
| 2929 | |
| 2930 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2931 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2932 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2933 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2934 | alloc_info.descriptorPool = ds_pool; |
| 2935 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2936 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2937 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2938 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2939 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2940 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2941 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2942 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2943 | } |
| 2944 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2945 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 2946 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2947 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2948 | m_errorMonitor->SetDesiredFailureMsg( |
| 2949 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2950 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 2951 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2952 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2953 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2954 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2955 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2956 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2957 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2958 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2959 | |
| 2960 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2961 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2962 | ds_pool_ci.pNext = NULL; |
| 2963 | ds_pool_ci.maxSets = 1; |
| 2964 | ds_pool_ci.poolSizeCount = 1; |
| 2965 | ds_pool_ci.flags = 0; |
| 2966 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 2967 | // app can only call vkResetDescriptorPool on this pool.; |
| 2968 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2969 | |
| 2970 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2971 | err = |
| 2972 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2973 | ASSERT_VK_SUCCESS(err); |
| 2974 | |
| 2975 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2976 | dsl_binding.binding = 0; |
| 2977 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2978 | dsl_binding.descriptorCount = 1; |
| 2979 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2980 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2981 | |
| 2982 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2983 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2984 | ds_layout_ci.pNext = NULL; |
| 2985 | ds_layout_ci.bindingCount = 1; |
| 2986 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2987 | |
| 2988 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2989 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2990 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2991 | ASSERT_VK_SUCCESS(err); |
| 2992 | |
| 2993 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2994 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2995 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2996 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2997 | alloc_info.descriptorPool = ds_pool; |
| 2998 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2999 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3000 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3001 | ASSERT_VK_SUCCESS(err); |
| 3002 | |
| 3003 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3004 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3005 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3006 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3007 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3008 | } |
| 3009 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3010 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3011 | // Attempt to clear Descriptor Pool with bad object. |
| 3012 | // ObjectTracker should catch this. |
| 3013 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3014 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3015 | uint64_t fake_pool_handle = 0xbaad6001; |
| 3016 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 3017 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3018 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3019 | } |
| 3020 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3021 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3022 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 3023 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3024 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3025 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3026 | |
| 3027 | uint64_t fake_set_handle = 0xbaad6001; |
| 3028 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3029 | VkResult err; |
| 3030 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3031 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 3032 | |
| 3033 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3034 | |
| 3035 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 3036 | layout_bindings[0].binding = 0; |
| 3037 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3038 | layout_bindings[0].descriptorCount = 1; |
| 3039 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3040 | layout_bindings[0].pImmutableSamplers = NULL; |
| 3041 | |
| 3042 | VkDescriptorSetLayout descriptor_set_layout; |
| 3043 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 3044 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3045 | dslci.pNext = NULL; |
| 3046 | dslci.bindingCount = 1; |
| 3047 | dslci.pBindings = layout_bindings; |
| 3048 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3049 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3050 | |
| 3051 | VkPipelineLayout pipeline_layout; |
| 3052 | VkPipelineLayoutCreateInfo plci = {}; |
| 3053 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3054 | plci.pNext = NULL; |
| 3055 | plci.setLayoutCount = 1; |
| 3056 | plci.pSetLayouts = &descriptor_set_layout; |
| 3057 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3058 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3059 | |
| 3060 | BeginCommandBuffer(); |
| 3061 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3062 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3063 | m_errorMonitor->VerifyFound(); |
| 3064 | EndCommandBuffer(); |
| 3065 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 3066 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3067 | } |
| 3068 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3069 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3070 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 3071 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3072 | uint64_t fake_layout_handle = 0xbaad6001; |
| 3073 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3074 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3075 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 3076 | |
| 3077 | VkPipelineLayout pipeline_layout; |
| 3078 | VkPipelineLayoutCreateInfo plci = {}; |
| 3079 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3080 | plci.pNext = NULL; |
| 3081 | plci.setLayoutCount = 1; |
| 3082 | plci.pSetLayouts = &bad_layout; |
| 3083 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 3084 | |
| 3085 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3086 | } |
| 3087 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3088 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3089 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 3090 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3091 | // Create a valid cmd buffer |
| 3092 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3093 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 3094 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3095 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3096 | "Invalid VkPipeline Object 0xbaad6001"); |
| 3097 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3098 | BeginCommandBuffer(); |
| 3099 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3100 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 3101 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 3102 | |
| 3103 | // Now issue a draw call with no pipeline bound |
| 3104 | m_errorMonitor->SetDesiredFailureMsg( |
| 3105 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3106 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3107 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3108 | BeginCommandBuffer(); |
| 3109 | Draw(1, 0, 0, 0); |
| 3110 | m_errorMonitor->VerifyFound(); |
| 3111 | // Finally same check once more but with Dispatch/Compute |
| 3112 | m_errorMonitor->SetDesiredFailureMsg( |
| 3113 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3114 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3115 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3116 | BeginCommandBuffer(); |
| 3117 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 3118 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3119 | } |
| 3120 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3121 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 3122 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 3123 | // CommandBuffer |
| 3124 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3125 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3126 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3127 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3128 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3129 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3130 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3131 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3132 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3133 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3134 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3135 | |
| 3136 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3137 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3138 | ds_pool_ci.pNext = NULL; |
| 3139 | ds_pool_ci.maxSets = 1; |
| 3140 | ds_pool_ci.poolSizeCount = 1; |
| 3141 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3142 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3143 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3144 | err = |
| 3145 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3146 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3147 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3148 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3149 | dsl_binding.binding = 0; |
| 3150 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3151 | dsl_binding.descriptorCount = 1; |
| 3152 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3153 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3154 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3155 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3156 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3157 | ds_layout_ci.pNext = NULL; |
| 3158 | ds_layout_ci.bindingCount = 1; |
| 3159 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3160 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3161 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3162 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3163 | ASSERT_VK_SUCCESS(err); |
| 3164 | |
| 3165 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3166 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3167 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3168 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3169 | alloc_info.descriptorPool = ds_pool; |
| 3170 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3171 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3172 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3173 | ASSERT_VK_SUCCESS(err); |
| 3174 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3175 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3176 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3177 | pipeline_layout_ci.pNext = NULL; |
| 3178 | pipeline_layout_ci.setLayoutCount = 1; |
| 3179 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3180 | |
| 3181 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3182 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3183 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3184 | ASSERT_VK_SUCCESS(err); |
| 3185 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3186 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3187 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3188 | // We shouldn't need a fragment shader but add it to be able to run |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3189 | // on more devices |
| 3190 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3191 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3192 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3193 | VkPipelineObj pipe(m_device); |
| 3194 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3195 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3196 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3197 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3198 | |
| 3199 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3200 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3201 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3202 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3203 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3204 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3205 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3206 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3207 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3208 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3209 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3210 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3211 | } |
| 3212 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3213 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3214 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3215 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3216 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3217 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3218 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 3219 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3220 | |
| 3221 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3222 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3223 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3224 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3225 | |
| 3226 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3227 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3228 | ds_pool_ci.pNext = NULL; |
| 3229 | ds_pool_ci.maxSets = 1; |
| 3230 | ds_pool_ci.poolSizeCount = 1; |
| 3231 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3232 | |
| 3233 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3234 | err = |
| 3235 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3236 | ASSERT_VK_SUCCESS(err); |
| 3237 | |
| 3238 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3239 | dsl_binding.binding = 0; |
| 3240 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3241 | dsl_binding.descriptorCount = 1; |
| 3242 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3243 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3244 | |
| 3245 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3246 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3247 | ds_layout_ci.pNext = NULL; |
| 3248 | ds_layout_ci.bindingCount = 1; |
| 3249 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3250 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3251 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3252 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3253 | ASSERT_VK_SUCCESS(err); |
| 3254 | |
| 3255 | VkDescriptorSet descriptorSet; |
| 3256 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3257 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3258 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3259 | alloc_info.descriptorPool = ds_pool; |
| 3260 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3261 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3262 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3263 | ASSERT_VK_SUCCESS(err); |
| 3264 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3265 | VkBufferView view = |
| 3266 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3267 | VkWriteDescriptorSet descriptor_write; |
| 3268 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3269 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3270 | descriptor_write.dstSet = descriptorSet; |
| 3271 | descriptor_write.dstBinding = 0; |
| 3272 | descriptor_write.descriptorCount = 1; |
| 3273 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3274 | descriptor_write.pTexelBufferView = &view; |
| 3275 | |
| 3276 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3277 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3278 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3279 | |
| 3280 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3281 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3282 | } |
| 3283 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3284 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 3285 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 3286 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3287 | // 1. No dynamicOffset supplied |
| 3288 | // 2. Too many dynamicOffsets supplied |
| 3289 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3290 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3291 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3292 | " requires 1 dynamicOffsets, but only " |
| 3293 | "0 dynamicOffsets are left in " |
| 3294 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3295 | |
| 3296 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3297 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3298 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3299 | |
| 3300 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3301 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3302 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3303 | |
| 3304 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3305 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3306 | ds_pool_ci.pNext = NULL; |
| 3307 | ds_pool_ci.maxSets = 1; |
| 3308 | ds_pool_ci.poolSizeCount = 1; |
| 3309 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3310 | |
| 3311 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3312 | err = |
| 3313 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3314 | ASSERT_VK_SUCCESS(err); |
| 3315 | |
| 3316 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3317 | dsl_binding.binding = 0; |
| 3318 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3319 | dsl_binding.descriptorCount = 1; |
| 3320 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3321 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3322 | |
| 3323 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3324 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3325 | ds_layout_ci.pNext = NULL; |
| 3326 | ds_layout_ci.bindingCount = 1; |
| 3327 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3328 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3329 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3330 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3331 | ASSERT_VK_SUCCESS(err); |
| 3332 | |
| 3333 | VkDescriptorSet descriptorSet; |
| 3334 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3335 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3336 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3337 | alloc_info.descriptorPool = ds_pool; |
| 3338 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3339 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3340 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3341 | ASSERT_VK_SUCCESS(err); |
| 3342 | |
| 3343 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3344 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3345 | pipeline_layout_ci.pNext = NULL; |
| 3346 | pipeline_layout_ci.setLayoutCount = 1; |
| 3347 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3348 | |
| 3349 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3350 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3351 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3352 | ASSERT_VK_SUCCESS(err); |
| 3353 | |
| 3354 | // Create a buffer to update the descriptor with |
| 3355 | uint32_t qfi = 0; |
| 3356 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3357 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3358 | buffCI.size = 1024; |
| 3359 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3360 | buffCI.queueFamilyIndexCount = 1; |
| 3361 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3362 | |
| 3363 | VkBuffer dyub; |
| 3364 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3365 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3366 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 3367 | // error |
| 3368 | VkMemoryAllocateInfo mem_alloc = {}; |
| 3369 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3370 | mem_alloc.pNext = NULL; |
| 3371 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 3372 | mem_alloc.memoryTypeIndex = 0; |
| 3373 | |
| 3374 | VkMemoryRequirements memReqs; |
| 3375 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 3376 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 3377 | 0); |
| 3378 | if (!pass) { |
| 3379 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 3380 | return; |
| 3381 | } |
| 3382 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3383 | VkDeviceMemory mem; |
| 3384 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 3385 | ASSERT_VK_SUCCESS(err); |
| 3386 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 3387 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3388 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3389 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3390 | buffInfo.buffer = dyub; |
| 3391 | buffInfo.offset = 0; |
| 3392 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3393 | |
| 3394 | VkWriteDescriptorSet descriptor_write; |
| 3395 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3396 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3397 | descriptor_write.dstSet = descriptorSet; |
| 3398 | descriptor_write.dstBinding = 0; |
| 3399 | descriptor_write.descriptorCount = 1; |
| 3400 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3401 | descriptor_write.pBufferInfo = &buffInfo; |
| 3402 | |
| 3403 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3404 | |
| 3405 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3406 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3407 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3408 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3409 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3410 | uint32_t pDynOff[2] = {512, 756}; |
| 3411 | // Now cause error b/c too many dynOffsets in array for # of dyn descriptors |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3412 | m_errorMonitor->SetDesiredFailureMsg( |
| 3413 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3414 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3415 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3416 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3417 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3418 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3419 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3420 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3421 | " dynamic offset 512 combined with " |
| 3422 | "offset 0 and range 1024 that " |
| 3423 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3424 | // Create PSO to be used for draw-time errors below |
| 3425 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3426 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3427 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3428 | "out gl_PerVertex { \n" |
| 3429 | " vec4 gl_Position;\n" |
| 3430 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3431 | "void main(){\n" |
| 3432 | " gl_Position = vec4(1);\n" |
| 3433 | "}\n"; |
| 3434 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3435 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3436 | "\n" |
| 3437 | "layout(location=0) out vec4 x;\n" |
| 3438 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3439 | "void main(){\n" |
| 3440 | " x = vec4(bar.y);\n" |
| 3441 | "}\n"; |
| 3442 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3443 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 3444 | VkPipelineObj pipe(m_device); |
| 3445 | pipe.AddShader(&vs); |
| 3446 | pipe.AddShader(&fs); |
| 3447 | pipe.AddColorAttachment(); |
| 3448 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 3449 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3450 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3451 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3452 | // This update should succeed, but offset size of 512 will overstep buffer |
| 3453 | // /w range 1024 & size 1024 |
| 3454 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3455 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3456 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3457 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3458 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3459 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3460 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 3461 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3462 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3463 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3464 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3465 | } |
| 3466 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3467 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 3468 | // Hit push constant error cases: |
| 3469 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 3470 | // 2. Incorrectly set push constant size to 0 |
| 3471 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 3472 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 3473 | VkResult err; |
| 3474 | m_errorMonitor->SetDesiredFailureMsg( |
| 3475 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3476 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 3477 | |
| 3478 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3479 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3480 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3481 | |
| 3482 | VkPushConstantRange pc_range = {}; |
| 3483 | pc_range.size = 0xFFFFFFFFu; |
| 3484 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3485 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3486 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3487 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 3488 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 3489 | |
| 3490 | VkPipelineLayout pipeline_layout; |
| 3491 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3492 | &pipeline_layout); |
| 3493 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3494 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3495 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 3496 | pc_range.size = 0; |
| 3497 | m_errorMonitor->SetDesiredFailureMsg( |
| 3498 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3499 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 3500 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3501 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3502 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3503 | pc_range.size = 1; |
| 3504 | m_errorMonitor->SetDesiredFailureMsg( |
| 3505 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3506 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 3507 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3508 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3509 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3510 | // Cause error due to bad size in vkCmdPushConstants() call |
| 3511 | m_errorMonitor->SetDesiredFailureMsg( |
| 3512 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3513 | "vkCmdPushConstants() call has push constants with offset "); |
| 3514 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 3515 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 3516 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3517 | &pipeline_layout); |
| 3518 | ASSERT_VK_SUCCESS(err); |
| 3519 | BeginCommandBuffer(); |
| 3520 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 3521 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3522 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3523 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3524 | } |
| 3525 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3526 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3527 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3528 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3529 | |
| 3530 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3531 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3532 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3533 | |
| 3534 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 3535 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3536 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3537 | ds_type_count[0].descriptorCount = 10; |
| 3538 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3539 | ds_type_count[1].descriptorCount = 2; |
| 3540 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3541 | ds_type_count[2].descriptorCount = 2; |
| 3542 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3543 | ds_type_count[3].descriptorCount = 5; |
| 3544 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 3545 | // type |
| 3546 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 3547 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 3548 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3549 | |
| 3550 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3551 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3552 | ds_pool_ci.pNext = NULL; |
| 3553 | ds_pool_ci.maxSets = 5; |
| 3554 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 3555 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3556 | |
| 3557 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3558 | err = |
| 3559 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3560 | ASSERT_VK_SUCCESS(err); |
| 3561 | |
| 3562 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 3563 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3564 | dsl_binding[0].binding = 0; |
| 3565 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3566 | dsl_binding[0].descriptorCount = 5; |
| 3567 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3568 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3569 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3570 | // Create layout identical to set0 layout but w/ different stageFlags |
| 3571 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3572 | dsl_fs_stage_only.binding = 0; |
| 3573 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3574 | dsl_fs_stage_only.descriptorCount = 5; |
| 3575 | dsl_fs_stage_only.stageFlags = |
| 3576 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 3577 | // bind time |
| 3578 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3579 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3580 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3581 | ds_layout_ci.pNext = NULL; |
| 3582 | ds_layout_ci.bindingCount = 1; |
| 3583 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3584 | static const uint32_t NUM_LAYOUTS = 4; |
| 3585 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3586 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3587 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 3588 | // layout for error case |
| 3589 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3590 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3591 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3592 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3593 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3594 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3595 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3596 | dsl_binding[0].binding = 0; |
| 3597 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3598 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3599 | dsl_binding[1].binding = 1; |
| 3600 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3601 | dsl_binding[1].descriptorCount = 2; |
| 3602 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3603 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3604 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3605 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3606 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3607 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3608 | ASSERT_VK_SUCCESS(err); |
| 3609 | dsl_binding[0].binding = 0; |
| 3610 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3611 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3612 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3613 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3614 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3615 | ASSERT_VK_SUCCESS(err); |
| 3616 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3617 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3618 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3619 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3620 | ASSERT_VK_SUCCESS(err); |
| 3621 | |
| 3622 | static const uint32_t NUM_SETS = 4; |
| 3623 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 3624 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3625 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3626 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3627 | alloc_info.descriptorPool = ds_pool; |
| 3628 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3629 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3630 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3631 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3632 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3633 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3634 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3635 | err = |
| 3636 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3637 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3638 | |
| 3639 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3640 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3641 | pipeline_layout_ci.pNext = NULL; |
| 3642 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 3643 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3644 | |
| 3645 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3646 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3647 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3648 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3649 | // Create pipelineLayout with only one setLayout |
| 3650 | pipeline_layout_ci.setLayoutCount = 1; |
| 3651 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3652 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3653 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3654 | ASSERT_VK_SUCCESS(err); |
| 3655 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 3656 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 3657 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3658 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3659 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3660 | ASSERT_VK_SUCCESS(err); |
| 3661 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 3662 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 3663 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3664 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3665 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3666 | ASSERT_VK_SUCCESS(err); |
| 3667 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 3668 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 3669 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3670 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3671 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3672 | ASSERT_VK_SUCCESS(err); |
| 3673 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 3674 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 3675 | pl_bad_s0[0] = ds_layout_fs_only; |
| 3676 | pl_bad_s0[1] = ds_layout[1]; |
| 3677 | pipeline_layout_ci.setLayoutCount = 2; |
| 3678 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 3679 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3680 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3681 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3682 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3683 | |
| 3684 | // Create a buffer to update the descriptor with |
| 3685 | uint32_t qfi = 0; |
| 3686 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3687 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3688 | buffCI.size = 1024; |
| 3689 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3690 | buffCI.queueFamilyIndexCount = 1; |
| 3691 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3692 | |
| 3693 | VkBuffer dyub; |
| 3694 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3695 | ASSERT_VK_SUCCESS(err); |
| 3696 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3697 | static const uint32_t NUM_BUFFS = 5; |
| 3698 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3699 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3700 | buffInfo[i].buffer = dyub; |
| 3701 | buffInfo[i].offset = 0; |
| 3702 | buffInfo[i].range = 1024; |
| 3703 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3704 | VkImage image; |
| 3705 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3706 | const int32_t tex_width = 32; |
| 3707 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3708 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3709 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3710 | image_create_info.pNext = NULL; |
| 3711 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3712 | image_create_info.format = tex_format; |
| 3713 | image_create_info.extent.width = tex_width; |
| 3714 | image_create_info.extent.height = tex_height; |
| 3715 | image_create_info.extent.depth = 1; |
| 3716 | image_create_info.mipLevels = 1; |
| 3717 | image_create_info.arrayLayers = 1; |
| 3718 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3719 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3720 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3721 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3722 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 3723 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3724 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3725 | VkMemoryRequirements memReqs; |
| 3726 | VkDeviceMemory imageMem; |
| 3727 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3728 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3729 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3730 | memAlloc.pNext = NULL; |
| 3731 | memAlloc.allocationSize = 0; |
| 3732 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3733 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 3734 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3735 | pass = |
| 3736 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3737 | ASSERT_TRUE(pass); |
| 3738 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 3739 | ASSERT_VK_SUCCESS(err); |
| 3740 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 3741 | ASSERT_VK_SUCCESS(err); |
| 3742 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3743 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3744 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3745 | image_view_create_info.image = image; |
| 3746 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3747 | image_view_create_info.format = tex_format; |
| 3748 | image_view_create_info.subresourceRange.layerCount = 1; |
| 3749 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 3750 | image_view_create_info.subresourceRange.levelCount = 1; |
| 3751 | image_view_create_info.subresourceRange.aspectMask = |
| 3752 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3753 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3754 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3755 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 3756 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3757 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3758 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3759 | imageInfo[0].imageView = view; |
| 3760 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3761 | imageInfo[1].imageView = view; |
| 3762 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3763 | imageInfo[2].imageView = view; |
| 3764 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3765 | imageInfo[3].imageView = view; |
| 3766 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3767 | |
| 3768 | static const uint32_t NUM_SET_UPDATES = 3; |
| 3769 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 3770 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3771 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 3772 | descriptor_write[0].dstBinding = 0; |
| 3773 | descriptor_write[0].descriptorCount = 5; |
| 3774 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3775 | descriptor_write[0].pBufferInfo = buffInfo; |
| 3776 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3777 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 3778 | descriptor_write[1].dstBinding = 0; |
| 3779 | descriptor_write[1].descriptorCount = 2; |
| 3780 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3781 | descriptor_write[1].pImageInfo = imageInfo; |
| 3782 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3783 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 3784 | descriptor_write[2].dstBinding = 1; |
| 3785 | descriptor_write[2].descriptorCount = 2; |
| 3786 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3787 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3788 | |
| 3789 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3790 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3791 | // Create PSO to be used for draw-time errors below |
| 3792 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3793 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3794 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3795 | "out gl_PerVertex {\n" |
| 3796 | " vec4 gl_Position;\n" |
| 3797 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3798 | "void main(){\n" |
| 3799 | " gl_Position = vec4(1);\n" |
| 3800 | "}\n"; |
| 3801 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3802 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3803 | "\n" |
| 3804 | "layout(location=0) out vec4 x;\n" |
| 3805 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3806 | "void main(){\n" |
| 3807 | " x = vec4(bar.y);\n" |
| 3808 | "}\n"; |
| 3809 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3810 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3811 | VkPipelineObj pipe(m_device); |
| 3812 | pipe.AddShader(&vs); |
| 3813 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3814 | pipe.AddColorAttachment(); |
| 3815 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3816 | |
| 3817 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3818 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3819 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3820 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3821 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 3822 | // of PSO |
| 3823 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 3824 | // cmd_pipeline.c |
| 3825 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 3826 | // cmd_bind_graphics_pipeline() |
| 3827 | // TODO : Want to cause various binding incompatibility issues here to test |
| 3828 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3829 | // First cause various verify_layout_compatibility() fails |
| 3830 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3831 | // verify_set_layout_compatibility fail cases: |
| 3832 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3833 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3834 | " due to: invalid VkPipelineLayout "); |
| 3835 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3836 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3837 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 3838 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3839 | m_errorMonitor->VerifyFound(); |
| 3840 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3841 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3842 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3843 | " attempting to bind set to index 1"); |
| 3844 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3845 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 3846 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3847 | m_errorMonitor->VerifyFound(); |
| 3848 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3849 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3850 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 3851 | // descriptors |
| 3852 | m_errorMonitor->SetDesiredFailureMsg( |
| 3853 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3854 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3855 | vkCmdBindDescriptorSets( |
| 3856 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3857 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3858 | m_errorMonitor->VerifyFound(); |
| 3859 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3860 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 3861 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3862 | m_errorMonitor->SetDesiredFailureMsg( |
| 3863 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3864 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3865 | vkCmdBindDescriptorSets( |
| 3866 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3867 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3868 | m_errorMonitor->VerifyFound(); |
| 3869 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3870 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 3871 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3872 | m_errorMonitor->SetDesiredFailureMsg( |
| 3873 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3874 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3875 | vkCmdBindDescriptorSets( |
| 3876 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3877 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3878 | m_errorMonitor->VerifyFound(); |
| 3879 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3880 | // Cause INFO messages due to disturbing previously bound Sets |
| 3881 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3882 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3883 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3884 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3885 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3886 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3887 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3888 | " previously bound as set #0 was disturbed "); |
| 3889 | vkCmdBindDescriptorSets( |
| 3890 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3891 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3892 | m_errorMonitor->VerifyFound(); |
| 3893 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3894 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3895 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3896 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3897 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3898 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3899 | " newly bound as set #0 so set #1 and " |
| 3900 | "any subsequent sets were disturbed "); |
| 3901 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3902 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3903 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3904 | m_errorMonitor->VerifyFound(); |
| 3905 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3906 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3907 | // 1. Error due to not binding required set (we actually use same code as |
| 3908 | // above to disturb set0) |
| 3909 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3910 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3911 | 2, &descriptorSet[0], 0, NULL); |
| 3912 | vkCmdBindDescriptorSets( |
| 3913 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3914 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 3915 | m_errorMonitor->SetDesiredFailureMsg( |
| 3916 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3917 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3918 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3919 | m_errorMonitor->VerifyFound(); |
| 3920 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3921 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3922 | // 2. Error due to bound set not being compatible with PSO's |
| 3923 | // VkPipelineLayout (diff stageFlags in this case) |
| 3924 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3925 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3926 | 2, &descriptorSet[0], 0, NULL); |
| 3927 | m_errorMonitor->SetDesiredFailureMsg( |
| 3928 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3929 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3930 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3931 | m_errorMonitor->VerifyFound(); |
| 3932 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3933 | // Remaining clean-up |
| 3934 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3935 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3936 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 3937 | } |
| 3938 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 3939 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 3940 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3941 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3942 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3943 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3944 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3945 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3946 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3947 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3948 | m_errorMonitor->SetDesiredFailureMsg( |
| 3949 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3950 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3951 | |
| 3952 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3953 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3954 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3955 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3956 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3957 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3958 | } |
| 3959 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3960 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 3961 | VkResult err; |
| 3962 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3963 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3964 | m_errorMonitor->SetDesiredFailureMsg( |
| 3965 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 3966 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3967 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3968 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3969 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3970 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3971 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3972 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3973 | cmd.commandPool = m_commandPool; |
| 3974 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3975 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3976 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3977 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3978 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3979 | |
| 3980 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3981 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3982 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3983 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3984 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3985 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 3986 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3987 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3988 | |
| 3989 | // The error should be caught by validation of the BeginCommandBuffer call |
| 3990 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 3991 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3992 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3993 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3994 | } |
| 3995 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3996 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3997 | // Cause error due to Begin while recording CB |
| 3998 | // Then cause 2 errors for attempting to reset CB w/o having |
| 3999 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 4000 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4001 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4002 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4003 | |
| 4004 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4005 | |
| 4006 | // Calls AllocateCommandBuffers |
| 4007 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 4008 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4009 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 4010 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4011 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4012 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4013 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4014 | cmd_buf_info.pNext = NULL; |
| 4015 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4016 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4017 | |
| 4018 | // Begin CB to transition to recording state |
| 4019 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 4020 | // Can't re-begin. This should trigger error |
| 4021 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4022 | m_errorMonitor->VerifyFound(); |
| 4023 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4024 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4025 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4026 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 4027 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 4028 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4029 | m_errorMonitor->VerifyFound(); |
| 4030 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4031 | m_errorMonitor->SetDesiredFailureMsg( |
| 4032 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4033 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4034 | // Transition CB to RECORDED state |
| 4035 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 4036 | // Now attempting to Begin will implicitly reset, which triggers error |
| 4037 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4038 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4039 | } |
| 4040 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4041 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4042 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4043 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4044 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4045 | m_errorMonitor->SetDesiredFailureMsg( |
| 4046 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4047 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 4048 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4049 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4050 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4051 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4052 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4053 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4054 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4055 | |
| 4056 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4057 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4058 | ds_pool_ci.pNext = NULL; |
| 4059 | ds_pool_ci.maxSets = 1; |
| 4060 | ds_pool_ci.poolSizeCount = 1; |
| 4061 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4062 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4063 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4064 | err = |
| 4065 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4066 | ASSERT_VK_SUCCESS(err); |
| 4067 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4068 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4069 | dsl_binding.binding = 0; |
| 4070 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4071 | dsl_binding.descriptorCount = 1; |
| 4072 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4073 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4074 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4075 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4076 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4077 | ds_layout_ci.pNext = NULL; |
| 4078 | ds_layout_ci.bindingCount = 1; |
| 4079 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4080 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4081 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4082 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4083 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4084 | ASSERT_VK_SUCCESS(err); |
| 4085 | |
| 4086 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4087 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4088 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4089 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4090 | alloc_info.descriptorPool = ds_pool; |
| 4091 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4092 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4093 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4094 | ASSERT_VK_SUCCESS(err); |
| 4095 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4096 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4097 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4098 | pipeline_layout_ci.setLayoutCount = 1; |
| 4099 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4100 | |
| 4101 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4102 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4103 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4104 | ASSERT_VK_SUCCESS(err); |
| 4105 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4106 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4107 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4108 | |
| 4109 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4110 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4111 | vp_state_ci.scissorCount = 1; |
| 4112 | vp_state_ci.pScissors = ≻ |
| 4113 | vp_state_ci.viewportCount = 1; |
| 4114 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4115 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4116 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4117 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4118 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4119 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4120 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4121 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4122 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4123 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4124 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4125 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4126 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4127 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4128 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4129 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4130 | gp_ci.layout = pipeline_layout; |
| 4131 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4132 | |
| 4133 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4134 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4135 | pc_ci.initialDataSize = 0; |
| 4136 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4137 | |
| 4138 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 4139 | VkPipelineCache pipelineCache; |
| 4140 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4141 | err = |
| 4142 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 4143 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4144 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4145 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4146 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4147 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4148 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4149 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4150 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4151 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4152 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4153 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4154 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 4155 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 4156 | { |
| 4157 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4158 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4159 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4160 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4161 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 4162 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4163 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4164 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4165 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4166 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4167 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4168 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4169 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4170 | |
| 4171 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4172 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4173 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4174 | ds_pool_ci.poolSizeCount = 1; |
| 4175 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4176 | |
| 4177 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4178 | err = vkCreateDescriptorPool(m_device->device(), |
| 4179 | VK_DESCRIPTOR_POOL_USAGE_NON_FREE, 1, &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4180 | ASSERT_VK_SUCCESS(err); |
| 4181 | |
| 4182 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4183 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4184 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4185 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4186 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4187 | dsl_binding.pImmutableSamplers = NULL; |
| 4188 | |
| 4189 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4190 | ds_layout_ci.sType = |
| 4191 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4192 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4193 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4194 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4195 | |
| 4196 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4197 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4198 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4199 | ASSERT_VK_SUCCESS(err); |
| 4200 | |
| 4201 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4202 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 4203 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4204 | ASSERT_VK_SUCCESS(err); |
| 4205 | |
| 4206 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4207 | pipeline_layout_ci.sType = |
| 4208 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4209 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4210 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4211 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4212 | |
| 4213 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4214 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4215 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4216 | ASSERT_VK_SUCCESS(err); |
| 4217 | |
| 4218 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 4219 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4221 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 4222 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4223 | // Just using VS txt for Tess shaders as we don't care about functionality |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4224 | VkShaderObj |
| 4225 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4226 | this); |
| 4227 | VkShaderObj |
| 4228 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 4229 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4230 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4231 | shaderStages[0].sType = |
| 4232 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4233 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4234 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4235 | shaderStages[1].sType = |
| 4236 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4237 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4238 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4239 | shaderStages[2].sType = |
| 4240 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4241 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4242 | shaderStages[2].shader = te.handle(); |
| 4243 | |
| 4244 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4245 | iaCI.sType = |
| 4246 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4247 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4248 | |
| 4249 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 4250 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 4251 | tsCI.patchControlPoints = 0; // This will cause an error |
| 4252 | |
| 4253 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4254 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4255 | gp_ci.pNext = NULL; |
| 4256 | gp_ci.stageCount = 3; |
| 4257 | gp_ci.pStages = shaderStages; |
| 4258 | gp_ci.pVertexInputState = NULL; |
| 4259 | gp_ci.pInputAssemblyState = &iaCI; |
| 4260 | gp_ci.pTessellationState = &tsCI; |
| 4261 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4262 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4263 | gp_ci.pMultisampleState = NULL; |
| 4264 | gp_ci.pDepthStencilState = NULL; |
| 4265 | gp_ci.pColorBlendState = NULL; |
| 4266 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4267 | gp_ci.layout = pipeline_layout; |
| 4268 | gp_ci.renderPass = renderPass(); |
| 4269 | |
| 4270 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4271 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4272 | pc_ci.pNext = NULL; |
| 4273 | pc_ci.initialSize = 0; |
| 4274 | pc_ci.initialData = 0; |
| 4275 | pc_ci.maxSize = 0; |
| 4276 | |
| 4277 | VkPipeline pipeline; |
| 4278 | VkPipelineCache pipelineCache; |
| 4279 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4280 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 4281 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4282 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4283 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4284 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4285 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4286 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4287 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4288 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4289 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4290 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4291 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4292 | } |
| 4293 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4294 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4295 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4296 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4297 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4298 | m_errorMonitor->SetDesiredFailureMsg( |
| 4299 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4300 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 4301 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4302 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4303 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4304 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4305 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4306 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4307 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4308 | |
| 4309 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4310 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4311 | ds_pool_ci.maxSets = 1; |
| 4312 | ds_pool_ci.poolSizeCount = 1; |
| 4313 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4314 | |
| 4315 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4316 | err = |
| 4317 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4318 | ASSERT_VK_SUCCESS(err); |
| 4319 | |
| 4320 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4321 | dsl_binding.binding = 0; |
| 4322 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4323 | dsl_binding.descriptorCount = 1; |
| 4324 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4325 | |
| 4326 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4327 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4328 | ds_layout_ci.bindingCount = 1; |
| 4329 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4330 | |
| 4331 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4332 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4333 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4334 | ASSERT_VK_SUCCESS(err); |
| 4335 | |
| 4336 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4337 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4338 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4339 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4340 | alloc_info.descriptorPool = ds_pool; |
| 4341 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4342 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4343 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4344 | ASSERT_VK_SUCCESS(err); |
| 4345 | |
| 4346 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4347 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4348 | pipeline_layout_ci.setLayoutCount = 1; |
| 4349 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4350 | |
| 4351 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4352 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4353 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4354 | ASSERT_VK_SUCCESS(err); |
| 4355 | |
| 4356 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4357 | |
| 4358 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4359 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4360 | vp_state_ci.scissorCount = 0; |
| 4361 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 4362 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4363 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4364 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4365 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4366 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4367 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4368 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4369 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4370 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4371 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4372 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4373 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4374 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4375 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4376 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4377 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4378 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4379 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4380 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4381 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4382 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4383 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4384 | |
| 4385 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4386 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4387 | gp_ci.stageCount = 2; |
| 4388 | gp_ci.pStages = shaderStages; |
| 4389 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4390 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4391 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4392 | gp_ci.layout = pipeline_layout; |
| 4393 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4394 | |
| 4395 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4396 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4397 | |
| 4398 | VkPipeline pipeline; |
| 4399 | VkPipelineCache pipelineCache; |
| 4400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4401 | err = |
| 4402 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4403 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4404 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4405 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4406 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4407 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4408 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4409 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4410 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4411 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4412 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4413 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4414 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 4415 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4416 | // for the counts even if the data is going to be set dynamically. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4417 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4418 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4419 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4420 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4421 | m_errorMonitor->SetDesiredFailureMsg( |
| 4422 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4423 | "Gfx Pipeline pViewportState is null. Even if "); |
| 4424 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4425 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4426 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4427 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4428 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4429 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4430 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4431 | |
| 4432 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4433 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4434 | ds_pool_ci.maxSets = 1; |
| 4435 | ds_pool_ci.poolSizeCount = 1; |
| 4436 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4437 | |
| 4438 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4439 | err = |
| 4440 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4441 | ASSERT_VK_SUCCESS(err); |
| 4442 | |
| 4443 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4444 | dsl_binding.binding = 0; |
| 4445 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4446 | dsl_binding.descriptorCount = 1; |
| 4447 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4448 | |
| 4449 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4450 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4451 | ds_layout_ci.bindingCount = 1; |
| 4452 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4453 | |
| 4454 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4455 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4456 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4457 | ASSERT_VK_SUCCESS(err); |
| 4458 | |
| 4459 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4460 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4461 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4462 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4463 | alloc_info.descriptorPool = ds_pool; |
| 4464 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4465 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4466 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4467 | ASSERT_VK_SUCCESS(err); |
| 4468 | |
| 4469 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4470 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4471 | pipeline_layout_ci.setLayoutCount = 1; |
| 4472 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4473 | |
| 4474 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4475 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4476 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4477 | ASSERT_VK_SUCCESS(err); |
| 4478 | |
| 4479 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4480 | // Set scissor as dynamic to avoid second error |
| 4481 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4482 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4483 | dyn_state_ci.dynamicStateCount = 1; |
| 4484 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4485 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4486 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4487 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4488 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4489 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4490 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4491 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4492 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4493 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4494 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4495 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4496 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4497 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4498 | |
| 4499 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4500 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4501 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4502 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4503 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4504 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4505 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4506 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4507 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4508 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4509 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4510 | gp_ci.stageCount = 2; |
| 4511 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4512 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4513 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 4514 | // should cause validation error |
| 4515 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4516 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4517 | gp_ci.layout = pipeline_layout; |
| 4518 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4519 | |
| 4520 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4521 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4522 | |
| 4523 | VkPipeline pipeline; |
| 4524 | VkPipelineCache pipelineCache; |
| 4525 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4526 | err = |
| 4527 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4528 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4529 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4530 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4531 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4532 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4533 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4534 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4535 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4536 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4537 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4538 | } |
| 4539 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4540 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 4541 | // count |
| 4542 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 4543 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4544 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4545 | m_errorMonitor->SetDesiredFailureMsg( |
| 4546 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4547 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 4548 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4549 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4550 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4551 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4552 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4553 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4554 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4555 | |
| 4556 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4557 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4558 | ds_pool_ci.maxSets = 1; |
| 4559 | ds_pool_ci.poolSizeCount = 1; |
| 4560 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4561 | |
| 4562 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4563 | err = |
| 4564 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4565 | ASSERT_VK_SUCCESS(err); |
| 4566 | |
| 4567 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4568 | dsl_binding.binding = 0; |
| 4569 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4570 | dsl_binding.descriptorCount = 1; |
| 4571 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4572 | |
| 4573 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4574 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4575 | ds_layout_ci.bindingCount = 1; |
| 4576 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4577 | |
| 4578 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4579 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4580 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4581 | ASSERT_VK_SUCCESS(err); |
| 4582 | |
| 4583 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4584 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4585 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4586 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4587 | alloc_info.descriptorPool = ds_pool; |
| 4588 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4589 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4590 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4591 | ASSERT_VK_SUCCESS(err); |
| 4592 | |
| 4593 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4594 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4595 | pipeline_layout_ci.setLayoutCount = 1; |
| 4596 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4597 | |
| 4598 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4599 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4600 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4601 | ASSERT_VK_SUCCESS(err); |
| 4602 | |
| 4603 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4604 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4605 | vp_state_ci.viewportCount = 1; |
| 4606 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 4607 | vp_state_ci.scissorCount = 1; |
| 4608 | vp_state_ci.pScissors = |
| 4609 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4610 | |
| 4611 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4612 | // Set scissor as dynamic to avoid that error |
| 4613 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4614 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4615 | dyn_state_ci.dynamicStateCount = 1; |
| 4616 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4617 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4618 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4619 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4620 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4621 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4622 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4623 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4624 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4625 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4626 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4627 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4628 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4629 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4630 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4631 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4632 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4633 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4634 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4635 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4636 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4637 | |
| 4638 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4639 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4640 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4641 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4642 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4643 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4644 | rs_ci.pNext = nullptr; |
| 4645 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4646 | VkPipelineColorBlendAttachmentState att = {}; |
| 4647 | att.blendEnable = VK_FALSE; |
| 4648 | att.colorWriteMask = 0xf; |
| 4649 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4650 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4651 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4652 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4653 | cb_ci.attachmentCount = 1; |
| 4654 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4655 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4656 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4657 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4658 | gp_ci.stageCount = 2; |
| 4659 | gp_ci.pStages = shaderStages; |
| 4660 | gp_ci.pVertexInputState = &vi_ci; |
| 4661 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4662 | gp_ci.pViewportState = &vp_state_ci; |
| 4663 | gp_ci.pRasterizationState = &rs_ci; |
| 4664 | gp_ci.pColorBlendState = &cb_ci; |
| 4665 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4666 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4667 | gp_ci.layout = pipeline_layout; |
| 4668 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4669 | |
| 4670 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4671 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4672 | |
| 4673 | VkPipeline pipeline; |
| 4674 | VkPipelineCache pipelineCache; |
| 4675 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4676 | err = |
| 4677 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4678 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4679 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4680 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4681 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4682 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4683 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4684 | // Now hit second fail case where we set scissor w/ different count than PSO |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4685 | // First need to successfully create the PSO from above by setting |
| 4686 | // pViewports |
| 4687 | m_errorMonitor->SetDesiredFailureMsg( |
| 4688 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4689 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 4690 | "scissorCount is 1. These counts must match."); |
| 4691 | |
| 4692 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4693 | vp_state_ci.pViewports = &vp; |
| 4694 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4695 | &gp_ci, NULL, &pipeline); |
| 4696 | ASSERT_VK_SUCCESS(err); |
| 4697 | BeginCommandBuffer(); |
| 4698 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4699 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4700 | VkRect2D scissors[2] = {}; // don't care about data |
| 4701 | // Count of 2 doesn't match PSO count of 1 |
| 4702 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 4703 | Draw(1, 0, 0, 0); |
| 4704 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4705 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4706 | |
| 4707 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4708 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4709 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4710 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4711 | } |
| 4712 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 4713 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 4714 | // viewportCount |
| 4715 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 4716 | VkResult err; |
| 4717 | |
| 4718 | m_errorMonitor->SetDesiredFailureMsg( |
| 4719 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4720 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 4721 | |
| 4722 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4723 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4724 | |
| 4725 | VkDescriptorPoolSize ds_type_count = {}; |
| 4726 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4727 | ds_type_count.descriptorCount = 1; |
| 4728 | |
| 4729 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4730 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4731 | ds_pool_ci.maxSets = 1; |
| 4732 | ds_pool_ci.poolSizeCount = 1; |
| 4733 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4734 | |
| 4735 | VkDescriptorPool ds_pool; |
| 4736 | err = |
| 4737 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4738 | ASSERT_VK_SUCCESS(err); |
| 4739 | |
| 4740 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4741 | dsl_binding.binding = 0; |
| 4742 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4743 | dsl_binding.descriptorCount = 1; |
| 4744 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4745 | |
| 4746 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4747 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4748 | ds_layout_ci.bindingCount = 1; |
| 4749 | ds_layout_ci.pBindings = &dsl_binding; |
| 4750 | |
| 4751 | VkDescriptorSetLayout ds_layout; |
| 4752 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4753 | &ds_layout); |
| 4754 | ASSERT_VK_SUCCESS(err); |
| 4755 | |
| 4756 | VkDescriptorSet descriptorSet; |
| 4757 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4758 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4759 | alloc_info.descriptorSetCount = 1; |
| 4760 | alloc_info.descriptorPool = ds_pool; |
| 4761 | alloc_info.pSetLayouts = &ds_layout; |
| 4762 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4763 | &descriptorSet); |
| 4764 | ASSERT_VK_SUCCESS(err); |
| 4765 | |
| 4766 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4767 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4768 | pipeline_layout_ci.setLayoutCount = 1; |
| 4769 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4770 | |
| 4771 | VkPipelineLayout pipeline_layout; |
| 4772 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4773 | &pipeline_layout); |
| 4774 | ASSERT_VK_SUCCESS(err); |
| 4775 | |
| 4776 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4777 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4778 | vp_state_ci.scissorCount = 1; |
| 4779 | vp_state_ci.pScissors = |
| 4780 | NULL; // Null scissor w/ count of 1 should cause error |
| 4781 | vp_state_ci.viewportCount = 1; |
| 4782 | vp_state_ci.pViewports = |
| 4783 | NULL; // vp is dynamic (below) so this won't cause error |
| 4784 | |
| 4785 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 4786 | // Set scissor as dynamic to avoid that error |
| 4787 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4788 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4789 | dyn_state_ci.dynamicStateCount = 1; |
| 4790 | dyn_state_ci.pDynamicStates = &vp_state; |
| 4791 | |
| 4792 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4793 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4794 | |
| 4795 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4796 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4797 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4798 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4799 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4800 | // but add it to be able to run on more devices |
| 4801 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4802 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4803 | |
| 4804 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4805 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4806 | vi_ci.pNext = nullptr; |
| 4807 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4808 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4809 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4810 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4811 | |
| 4812 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4813 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4814 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4815 | |
| 4816 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4817 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4818 | rs_ci.pNext = nullptr; |
| 4819 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4820 | VkPipelineColorBlendAttachmentState att = {}; |
| 4821 | att.blendEnable = VK_FALSE; |
| 4822 | att.colorWriteMask = 0xf; |
| 4823 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4824 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4825 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4826 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4827 | cb_ci.attachmentCount = 1; |
| 4828 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4829 | |
| 4830 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4831 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4832 | gp_ci.stageCount = 2; |
| 4833 | gp_ci.pStages = shaderStages; |
| 4834 | gp_ci.pVertexInputState = &vi_ci; |
| 4835 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4836 | gp_ci.pViewportState = &vp_state_ci; |
| 4837 | gp_ci.pRasterizationState = &rs_ci; |
| 4838 | gp_ci.pColorBlendState = &cb_ci; |
| 4839 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4840 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4841 | gp_ci.layout = pipeline_layout; |
| 4842 | gp_ci.renderPass = renderPass(); |
| 4843 | |
| 4844 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4845 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4846 | |
| 4847 | VkPipeline pipeline; |
| 4848 | VkPipelineCache pipelineCache; |
| 4849 | |
| 4850 | err = |
| 4851 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4852 | ASSERT_VK_SUCCESS(err); |
| 4853 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4854 | &gp_ci, NULL, &pipeline); |
| 4855 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4856 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4857 | |
| 4858 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 4859 | // First need to successfully create the PSO from above by setting |
| 4860 | // pViewports |
| 4861 | m_errorMonitor->SetDesiredFailureMsg( |
| 4862 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4863 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 4864 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4865 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4866 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 4867 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4868 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4869 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4870 | ASSERT_VK_SUCCESS(err); |
| 4871 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4872 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4873 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4874 | VkViewport viewports[2] = {}; // don't care about data |
| 4875 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 4876 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4877 | Draw(1, 0, 0, 0); |
| 4878 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4879 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4880 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4881 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4882 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4883 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4884 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4885 | } |
| 4886 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4887 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 4888 | VkResult err; |
| 4889 | |
| 4890 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4891 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4892 | |
| 4893 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4894 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4895 | |
| 4896 | VkDescriptorPoolSize ds_type_count = {}; |
| 4897 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4898 | ds_type_count.descriptorCount = 1; |
| 4899 | |
| 4900 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4901 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4902 | ds_pool_ci.maxSets = 1; |
| 4903 | ds_pool_ci.poolSizeCount = 1; |
| 4904 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4905 | |
| 4906 | VkDescriptorPool ds_pool; |
| 4907 | err = |
| 4908 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4909 | ASSERT_VK_SUCCESS(err); |
| 4910 | |
| 4911 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4912 | dsl_binding.binding = 0; |
| 4913 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4914 | dsl_binding.descriptorCount = 1; |
| 4915 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4916 | |
| 4917 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4918 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4919 | ds_layout_ci.bindingCount = 1; |
| 4920 | ds_layout_ci.pBindings = &dsl_binding; |
| 4921 | |
| 4922 | VkDescriptorSetLayout ds_layout; |
| 4923 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4924 | &ds_layout); |
| 4925 | ASSERT_VK_SUCCESS(err); |
| 4926 | |
| 4927 | VkDescriptorSet descriptorSet; |
| 4928 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4929 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4930 | alloc_info.descriptorSetCount = 1; |
| 4931 | alloc_info.descriptorPool = ds_pool; |
| 4932 | alloc_info.pSetLayouts = &ds_layout; |
| 4933 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4934 | &descriptorSet); |
| 4935 | ASSERT_VK_SUCCESS(err); |
| 4936 | |
| 4937 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4938 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4939 | pipeline_layout_ci.setLayoutCount = 1; |
| 4940 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4941 | |
| 4942 | VkPipelineLayout pipeline_layout; |
| 4943 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4944 | &pipeline_layout); |
| 4945 | ASSERT_VK_SUCCESS(err); |
| 4946 | |
| 4947 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4948 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4949 | vp_state_ci.scissorCount = 1; |
| 4950 | vp_state_ci.pScissors = NULL; |
| 4951 | vp_state_ci.viewportCount = 1; |
| 4952 | vp_state_ci.pViewports = NULL; |
| 4953 | |
| 4954 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 4955 | VK_DYNAMIC_STATE_SCISSOR, |
| 4956 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 4957 | // Set scissor as dynamic to avoid that error |
| 4958 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4959 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4960 | dyn_state_ci.dynamicStateCount = 2; |
| 4961 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 4962 | |
| 4963 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4964 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4965 | |
| 4966 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4967 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4968 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4969 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4970 | this); // TODO - We shouldn't need a fragment shader |
| 4971 | // but add it to be able to run on more devices |
| 4972 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4973 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4974 | |
| 4975 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4976 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4977 | vi_ci.pNext = nullptr; |
| 4978 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4979 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4980 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4981 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4982 | |
| 4983 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4984 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4985 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4986 | |
| 4987 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4988 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4989 | rs_ci.pNext = nullptr; |
| 4990 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4991 | // Check too low (line width of -1.0f). |
| 4992 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4993 | |
| 4994 | VkPipelineColorBlendAttachmentState att = {}; |
| 4995 | att.blendEnable = VK_FALSE; |
| 4996 | att.colorWriteMask = 0xf; |
| 4997 | |
| 4998 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4999 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 5000 | cb_ci.pNext = nullptr; |
| 5001 | cb_ci.attachmentCount = 1; |
| 5002 | cb_ci.pAttachments = &att; |
| 5003 | |
| 5004 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5005 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5006 | gp_ci.stageCount = 2; |
| 5007 | gp_ci.pStages = shaderStages; |
| 5008 | gp_ci.pVertexInputState = &vi_ci; |
| 5009 | gp_ci.pInputAssemblyState = &ia_ci; |
| 5010 | gp_ci.pViewportState = &vp_state_ci; |
| 5011 | gp_ci.pRasterizationState = &rs_ci; |
| 5012 | gp_ci.pColorBlendState = &cb_ci; |
| 5013 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5014 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5015 | gp_ci.layout = pipeline_layout; |
| 5016 | gp_ci.renderPass = renderPass(); |
| 5017 | |
| 5018 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5019 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5020 | |
| 5021 | VkPipeline pipeline; |
| 5022 | VkPipelineCache pipelineCache; |
| 5023 | |
| 5024 | err = |
| 5025 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5026 | ASSERT_VK_SUCCESS(err); |
| 5027 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5028 | &gp_ci, NULL, &pipeline); |
| 5029 | |
| 5030 | m_errorMonitor->VerifyFound(); |
| 5031 | |
| 5032 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5033 | "Attempt to set lineWidth to 65536"); |
| 5034 | |
| 5035 | // Check too high (line width of 65536.0f). |
| 5036 | rs_ci.lineWidth = 65536.0f; |
| 5037 | |
| 5038 | err = |
| 5039 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5040 | ASSERT_VK_SUCCESS(err); |
| 5041 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5042 | &gp_ci, NULL, &pipeline); |
| 5043 | |
| 5044 | m_errorMonitor->VerifyFound(); |
| 5045 | |
| 5046 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 5047 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5048 | |
| 5049 | dyn_state_ci.dynamicStateCount = 3; |
| 5050 | |
| 5051 | rs_ci.lineWidth = 1.0f; |
| 5052 | |
| 5053 | err = |
| 5054 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5055 | ASSERT_VK_SUCCESS(err); |
| 5056 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5057 | &gp_ci, NULL, &pipeline); |
| 5058 | BeginCommandBuffer(); |
| 5059 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5060 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 5061 | |
| 5062 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 5063 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5064 | m_errorMonitor->VerifyFound(); |
| 5065 | |
| 5066 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5067 | "Attempt to set lineWidth to 65536"); |
| 5068 | |
| 5069 | // Check too high with dynamic setting. |
| 5070 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 5071 | m_errorMonitor->VerifyFound(); |
| 5072 | EndCommandBuffer(); |
| 5073 | |
| 5074 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5075 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5076 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5077 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5078 | } |
| 5079 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5080 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5081 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5082 | m_errorMonitor->SetDesiredFailureMsg( |
| 5083 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5084 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5085 | |
| 5086 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5087 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5088 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5089 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5090 | // Don't care about RenderPass handle b/c error should be flagged before |
| 5091 | // that |
| 5092 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 5093 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5094 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5095 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5096 | } |
| 5097 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5098 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5099 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5100 | m_errorMonitor->SetDesiredFailureMsg( |
| 5101 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5102 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5103 | |
| 5104 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5105 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5106 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5107 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5108 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 5109 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5110 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5111 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 5112 | rp_begin.pNext = NULL; |
| 5113 | rp_begin.renderPass = renderPass(); |
| 5114 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5115 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5116 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 5117 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5118 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5119 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5120 | } |
| 5121 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5122 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5123 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5124 | m_errorMonitor->SetDesiredFailureMsg( |
| 5125 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5126 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5127 | |
| 5128 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5129 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5130 | |
| 5131 | // Renderpass is started here |
| 5132 | BeginCommandBuffer(); |
| 5133 | |
| 5134 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5135 | vk_testing::Buffer dstBuffer; |
| 5136 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5137 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5138 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5139 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5140 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5141 | } |
| 5142 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5143 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5144 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5145 | m_errorMonitor->SetDesiredFailureMsg( |
| 5146 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5147 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5148 | |
| 5149 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5150 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5151 | |
| 5152 | // Renderpass is started here |
| 5153 | BeginCommandBuffer(); |
| 5154 | |
| 5155 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5156 | vk_testing::Buffer dstBuffer; |
| 5157 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5159 | VkDeviceSize dstOffset = 0; |
| 5160 | VkDeviceSize dataSize = 1024; |
| 5161 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5163 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 5164 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5165 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5166 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5167 | } |
| 5168 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5169 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5170 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5171 | m_errorMonitor->SetDesiredFailureMsg( |
| 5172 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5173 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5174 | |
| 5175 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5176 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5177 | |
| 5178 | // Renderpass is started here |
| 5179 | BeginCommandBuffer(); |
| 5180 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5181 | VkClearColorValue clear_color; |
| 5182 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5183 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5184 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5185 | const int32_t tex_width = 32; |
| 5186 | const int32_t tex_height = 32; |
| 5187 | VkImageCreateInfo image_create_info = {}; |
| 5188 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5189 | image_create_info.pNext = NULL; |
| 5190 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5191 | image_create_info.format = tex_format; |
| 5192 | image_create_info.extent.width = tex_width; |
| 5193 | image_create_info.extent.height = tex_height; |
| 5194 | image_create_info.extent.depth = 1; |
| 5195 | image_create_info.mipLevels = 1; |
| 5196 | image_create_info.arrayLayers = 1; |
| 5197 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5198 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5199 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5200 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5201 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5202 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 5203 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5204 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5205 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 5206 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5208 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 5209 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5210 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5211 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5212 | } |
| 5213 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5214 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5215 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5216 | m_errorMonitor->SetDesiredFailureMsg( |
| 5217 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5218 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5219 | |
| 5220 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5221 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5222 | |
| 5223 | // Renderpass is started here |
| 5224 | BeginCommandBuffer(); |
| 5225 | |
| 5226 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 5227 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5228 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 5229 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5230 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 5231 | image_create_info.extent.width = 64; |
| 5232 | image_create_info.extent.height = 64; |
| 5233 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5234 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5235 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5236 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5237 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 5238 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5239 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5240 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 5241 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5242 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5243 | vkCmdClearDepthStencilImage( |
| 5244 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 5245 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 5246 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5247 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5248 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5249 | } |
| 5250 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5251 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 5252 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5253 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5254 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5255 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5256 | "vkCmdClearAttachments: This call " |
| 5257 | "must be issued inside an active " |
| 5258 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5259 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5260 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5261 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5262 | |
| 5263 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5264 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5265 | ASSERT_VK_SUCCESS(err); |
| 5266 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 5267 | VkClearAttachment color_attachment; |
| 5268 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5269 | color_attachment.clearValue.color.float32[0] = 0; |
| 5270 | color_attachment.clearValue.color.float32[1] = 0; |
| 5271 | color_attachment.clearValue.color.float32[2] = 0; |
| 5272 | color_attachment.clearValue.color.float32[3] = 0; |
| 5273 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5274 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 5275 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 5276 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5277 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5278 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5279 | } |
| 5280 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 5281 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 5282 | // Try to add a buffer memory barrier with no buffer. |
| 5283 | m_errorMonitor->SetDesiredFailureMsg( |
| 5284 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5285 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 5286 | |
| 5287 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5288 | BeginCommandBuffer(); |
| 5289 | |
| 5290 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5291 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5292 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5293 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5294 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5295 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5296 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 5297 | buf_barrier.offset = 0; |
| 5298 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5299 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5300 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 5301 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 5302 | |
| 5303 | m_errorMonitor->VerifyFound(); |
| 5304 | } |
| 5305 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 5306 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 5307 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 5308 | |
| 5309 | m_errorMonitor->SetDesiredFailureMsg( |
| 5310 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 5311 | |
| 5312 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5313 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5314 | |
| 5315 | VkMemoryBarrier mem_barrier = {}; |
| 5316 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 5317 | mem_barrier.pNext = NULL; |
| 5318 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5319 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5320 | BeginCommandBuffer(); |
| 5321 | // BeginCommandBuffer() starts a render pass |
| 5322 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5323 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5324 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 5325 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 5326 | m_errorMonitor->VerifyFound(); |
| 5327 | |
| 5328 | m_errorMonitor->SetDesiredFailureMsg( |
| 5329 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5330 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 5331 | VkImageObj image(m_device); |
| 5332 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 5333 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 5334 | ASSERT_TRUE(image.initialized()); |
| 5335 | VkImageMemoryBarrier img_barrier = {}; |
| 5336 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 5337 | img_barrier.pNext = NULL; |
| 5338 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5339 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5340 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5341 | // New layout can't be UNDEFINED |
| 5342 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 5343 | img_barrier.image = image.handle(); |
| 5344 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5345 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5346 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5347 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5348 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5349 | img_barrier.subresourceRange.layerCount = 1; |
| 5350 | img_barrier.subresourceRange.levelCount = 1; |
| 5351 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5352 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5353 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5354 | nullptr, 1, &img_barrier); |
| 5355 | m_errorMonitor->VerifyFound(); |
| 5356 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5357 | |
| 5358 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5359 | "Subresource must have the sum of the " |
| 5360 | "baseArrayLayer"); |
| 5361 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 5362 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 5363 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5364 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5365 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5366 | nullptr, 1, &img_barrier); |
| 5367 | m_errorMonitor->VerifyFound(); |
| 5368 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5369 | |
| 5370 | m_errorMonitor->SetDesiredFailureMsg( |
| 5371 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5372 | "Subresource must have the sum of the baseMipLevel"); |
| 5373 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 5374 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 5375 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5376 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5377 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5378 | nullptr, 1, &img_barrier); |
| 5379 | m_errorMonitor->VerifyFound(); |
| 5380 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5381 | |
| 5382 | m_errorMonitor->SetDesiredFailureMsg( |
| 5383 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5384 | "Buffer Barriers cannot be used during a render pass"); |
| 5385 | vk_testing::Buffer buffer; |
| 5386 | buffer.init(*m_device, 256); |
| 5387 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5388 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5389 | buf_barrier.pNext = NULL; |
| 5390 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5391 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5392 | buf_barrier.buffer = buffer.handle(); |
| 5393 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5394 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5395 | buf_barrier.offset = 0; |
| 5396 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5397 | // Can't send buffer barrier during a render pass |
| 5398 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5399 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5400 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5401 | &buf_barrier, 0, nullptr); |
| 5402 | m_errorMonitor->VerifyFound(); |
| 5403 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 5404 | |
| 5405 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5406 | "which is not less than total size"); |
| 5407 | buf_barrier.offset = 257; |
| 5408 | // Offset greater than total size |
| 5409 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5410 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5411 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5412 | &buf_barrier, 0, nullptr); |
| 5413 | m_errorMonitor->VerifyFound(); |
| 5414 | buf_barrier.offset = 0; |
| 5415 | |
| 5416 | m_errorMonitor->SetDesiredFailureMsg( |
| 5417 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 5418 | buf_barrier.size = 257; |
| 5419 | // Size greater than total size |
| 5420 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5421 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5422 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5423 | &buf_barrier, 0, nullptr); |
| 5424 | m_errorMonitor->VerifyFound(); |
| 5425 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5426 | |
| 5427 | m_errorMonitor->SetDesiredFailureMsg( |
| 5428 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5429 | "Image is a depth and stencil format and thus must " |
| 5430 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 5431 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 5432 | VkDepthStencilObj ds_image(m_device); |
| 5433 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 5434 | ASSERT_TRUE(ds_image.initialized()); |
| 5435 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5436 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 5437 | img_barrier.image = ds_image.handle(); |
| 5438 | // Leave aspectMask at COLOR on purpose |
| 5439 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5440 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5441 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5442 | nullptr, 1, &img_barrier); |
| 5443 | m_errorMonitor->VerifyFound(); |
| 5444 | } |
| 5445 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5446 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5447 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5448 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5449 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5450 | m_errorMonitor->SetDesiredFailureMsg( |
| 5451 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5452 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 5453 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5454 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5455 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5456 | uint32_t qfi = 0; |
| 5457 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5458 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5459 | buffCI.size = 1024; |
| 5460 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5461 | buffCI.queueFamilyIndexCount = 1; |
| 5462 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5463 | |
| 5464 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5465 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5466 | ASSERT_VK_SUCCESS(err); |
| 5467 | |
| 5468 | BeginCommandBuffer(); |
| 5469 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5470 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5471 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5472 | // Should error before calling to driver so don't care about actual data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5473 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 5474 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5475 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5476 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5477 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5478 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5479 | } |
| 5480 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5481 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 5482 | // Create an out-of-range queueFamilyIndex |
| 5483 | m_errorMonitor->SetDesiredFailureMsg( |
| 5484 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5485 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5486 | |
| 5487 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5488 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5489 | VkBufferCreateInfo buffCI = {}; |
| 5490 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5491 | buffCI.size = 1024; |
| 5492 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5493 | buffCI.queueFamilyIndexCount = 1; |
| 5494 | // Introduce failure by specifying invalid queue_family_index |
| 5495 | uint32_t qfi = 777; |
| 5496 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5497 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5498 | |
| 5499 | VkBuffer ib; |
| 5500 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 5501 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5502 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5503 | } |
| 5504 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5505 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 5506 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 5507 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5508 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5509 | m_errorMonitor->SetDesiredFailureMsg( |
| 5510 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5511 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5512 | |
| 5513 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5514 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5515 | |
| 5516 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5517 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5518 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 5519 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5520 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5521 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5522 | } |
| 5523 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5524 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5525 | // Create DS w/ layout of one type and attempt Update w/ mis-matched type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5526 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5527 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5528 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5529 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5530 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 5531 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5532 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5533 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5534 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5535 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5536 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5537 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5538 | |
| 5539 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5540 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5541 | ds_pool_ci.pNext = NULL; |
| 5542 | ds_pool_ci.maxSets = 1; |
| 5543 | ds_pool_ci.poolSizeCount = 1; |
| 5544 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5545 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5546 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5547 | err = |
| 5548 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5549 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5550 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5551 | dsl_binding.binding = 0; |
| 5552 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5553 | dsl_binding.descriptorCount = 1; |
| 5554 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5555 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5556 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5557 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5558 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5559 | ds_layout_ci.pNext = NULL; |
| 5560 | ds_layout_ci.bindingCount = 1; |
| 5561 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5562 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5563 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5564 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5565 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5566 | ASSERT_VK_SUCCESS(err); |
| 5567 | |
| 5568 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5569 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5570 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5571 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5572 | alloc_info.descriptorPool = ds_pool; |
| 5573 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5574 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5575 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5576 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5577 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 5578 | VkSamplerCreateInfo sampler_ci = {}; |
| 5579 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5580 | sampler_ci.pNext = NULL; |
| 5581 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5582 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5583 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5584 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5585 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5586 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5587 | sampler_ci.mipLodBias = 1.0; |
| 5588 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5589 | sampler_ci.maxAnisotropy = 1; |
| 5590 | sampler_ci.compareEnable = VK_FALSE; |
| 5591 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5592 | sampler_ci.minLod = 1.0; |
| 5593 | sampler_ci.maxLod = 1.0; |
| 5594 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5595 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 5596 | VkSampler sampler; |
| 5597 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 5598 | ASSERT_VK_SUCCESS(err); |
| 5599 | |
| 5600 | VkDescriptorImageInfo info = {}; |
| 5601 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5602 | |
| 5603 | VkWriteDescriptorSet descriptor_write; |
| 5604 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5605 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5606 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5607 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5608 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5609 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5610 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5611 | |
| 5612 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5613 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5614 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5615 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5616 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5617 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5618 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5619 | } |
| 5620 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5621 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5622 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5623 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5624 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5625 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5626 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5627 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 5628 | "starting at binding offset of 0 combined with update array element " |
| 5629 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5630 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5631 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5632 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5633 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5634 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5635 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5636 | |
| 5637 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5638 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5639 | ds_pool_ci.pNext = NULL; |
| 5640 | ds_pool_ci.maxSets = 1; |
| 5641 | ds_pool_ci.poolSizeCount = 1; |
| 5642 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5643 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5644 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5645 | err = |
| 5646 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5647 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5648 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5649 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5650 | dsl_binding.binding = 0; |
| 5651 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5652 | dsl_binding.descriptorCount = 1; |
| 5653 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5654 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5655 | |
| 5656 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5657 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5658 | ds_layout_ci.pNext = NULL; |
| 5659 | ds_layout_ci.bindingCount = 1; |
| 5660 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5661 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5662 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5663 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5664 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5665 | ASSERT_VK_SUCCESS(err); |
| 5666 | |
| 5667 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5668 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5669 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5670 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5671 | alloc_info.descriptorPool = ds_pool; |
| 5672 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5673 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5674 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5675 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5676 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 5677 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5678 | VkDescriptorBufferInfo buff_info = {}; |
| 5679 | buff_info.buffer = |
| 5680 | VkBuffer(0); // Don't care about buffer handle for this test |
| 5681 | buff_info.offset = 0; |
| 5682 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5683 | |
| 5684 | VkWriteDescriptorSet descriptor_write; |
| 5685 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5686 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5687 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5688 | descriptor_write.dstArrayElement = |
| 5689 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5690 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5691 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5692 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5693 | |
| 5694 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5695 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5696 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5697 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5698 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5699 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5700 | } |
| 5701 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5702 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 5703 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 5704 | // index 2 |
| 5705 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5706 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5707 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5708 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5709 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5710 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5711 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5712 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5713 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5714 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5715 | |
| 5716 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5717 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5718 | ds_pool_ci.pNext = NULL; |
| 5719 | ds_pool_ci.maxSets = 1; |
| 5720 | ds_pool_ci.poolSizeCount = 1; |
| 5721 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5722 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5723 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5724 | err = |
| 5725 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5726 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5727 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5728 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5729 | dsl_binding.binding = 0; |
| 5730 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5731 | dsl_binding.descriptorCount = 1; |
| 5732 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5733 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5734 | |
| 5735 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5736 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5737 | ds_layout_ci.pNext = NULL; |
| 5738 | ds_layout_ci.bindingCount = 1; |
| 5739 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5740 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5741 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5742 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5743 | ASSERT_VK_SUCCESS(err); |
| 5744 | |
| 5745 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5746 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5747 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5748 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5749 | alloc_info.descriptorPool = ds_pool; |
| 5750 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5751 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5752 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5753 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5754 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5755 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5756 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5757 | sampler_ci.pNext = NULL; |
| 5758 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5759 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5760 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5761 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5762 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5763 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5764 | sampler_ci.mipLodBias = 1.0; |
| 5765 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5766 | sampler_ci.maxAnisotropy = 1; |
| 5767 | sampler_ci.compareEnable = VK_FALSE; |
| 5768 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5769 | sampler_ci.minLod = 1.0; |
| 5770 | sampler_ci.maxLod = 1.0; |
| 5771 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5772 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5773 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5774 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5775 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5776 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5777 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5778 | VkDescriptorImageInfo info = {}; |
| 5779 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5780 | |
| 5781 | VkWriteDescriptorSet descriptor_write; |
| 5782 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5783 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5784 | descriptor_write.dstSet = descriptorSet; |
| 5785 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5786 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5787 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5788 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5789 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5790 | |
| 5791 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5792 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5793 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5794 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5795 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5796 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5797 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5798 | } |
| 5799 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5800 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 5801 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 5802 | // types |
| 5803 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5804 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5805 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5806 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5807 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5808 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5809 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5810 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5811 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5812 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5813 | |
| 5814 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5815 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5816 | ds_pool_ci.pNext = NULL; |
| 5817 | ds_pool_ci.maxSets = 1; |
| 5818 | ds_pool_ci.poolSizeCount = 1; |
| 5819 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5820 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5821 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5822 | err = |
| 5823 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5824 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5825 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5826 | dsl_binding.binding = 0; |
| 5827 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5828 | dsl_binding.descriptorCount = 1; |
| 5829 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5830 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5831 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5832 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5833 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5834 | ds_layout_ci.pNext = NULL; |
| 5835 | ds_layout_ci.bindingCount = 1; |
| 5836 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5837 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5838 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5839 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5840 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5841 | ASSERT_VK_SUCCESS(err); |
| 5842 | |
| 5843 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5844 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5845 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5846 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5847 | alloc_info.descriptorPool = ds_pool; |
| 5848 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5849 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5850 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5851 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5852 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5853 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5854 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5855 | sampler_ci.pNext = NULL; |
| 5856 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5857 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5858 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5859 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5860 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5861 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5862 | sampler_ci.mipLodBias = 1.0; |
| 5863 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5864 | sampler_ci.maxAnisotropy = 1; |
| 5865 | sampler_ci.compareEnable = VK_FALSE; |
| 5866 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5867 | sampler_ci.minLod = 1.0; |
| 5868 | sampler_ci.maxLod = 1.0; |
| 5869 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5870 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5871 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5872 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5873 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5874 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5875 | VkDescriptorImageInfo info = {}; |
| 5876 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5877 | |
| 5878 | VkWriteDescriptorSet descriptor_write; |
| 5879 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5880 | descriptor_write.sType = |
| 5881 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5882 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5883 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5884 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5885 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5886 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5887 | |
| 5888 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5889 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5890 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5891 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5892 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5893 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5894 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5895 | } |
| 5896 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5897 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5898 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5899 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5900 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5901 | m_errorMonitor->SetDesiredFailureMsg( |
| 5902 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5903 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5904 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5905 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5906 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 5907 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5908 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5909 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5910 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5911 | |
| 5912 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5913 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5914 | ds_pool_ci.pNext = NULL; |
| 5915 | ds_pool_ci.maxSets = 1; |
| 5916 | ds_pool_ci.poolSizeCount = 1; |
| 5917 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5918 | |
| 5919 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5920 | err = |
| 5921 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5922 | ASSERT_VK_SUCCESS(err); |
| 5923 | |
| 5924 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5925 | dsl_binding.binding = 0; |
| 5926 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5927 | dsl_binding.descriptorCount = 1; |
| 5928 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5929 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5930 | |
| 5931 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5932 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5933 | ds_layout_ci.pNext = NULL; |
| 5934 | ds_layout_ci.bindingCount = 1; |
| 5935 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5936 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5937 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5938 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5939 | ASSERT_VK_SUCCESS(err); |
| 5940 | |
| 5941 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5942 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5943 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5944 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5945 | alloc_info.descriptorPool = ds_pool; |
| 5946 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5947 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5948 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5949 | ASSERT_VK_SUCCESS(err); |
| 5950 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5951 | VkSampler sampler = |
| 5952 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5953 | |
| 5954 | VkDescriptorImageInfo descriptor_info; |
| 5955 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5956 | descriptor_info.sampler = sampler; |
| 5957 | |
| 5958 | VkWriteDescriptorSet descriptor_write; |
| 5959 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5960 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5961 | descriptor_write.dstSet = descriptorSet; |
| 5962 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5963 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5964 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5965 | descriptor_write.pImageInfo = &descriptor_info; |
| 5966 | |
| 5967 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5968 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5969 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5970 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5971 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5972 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5973 | } |
| 5974 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5975 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 5976 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 5977 | // imageView |
| 5978 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5979 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5980 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5981 | "Attempted write update to combined " |
| 5982 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 5983 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5984 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5985 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5986 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5987 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5988 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5989 | |
| 5990 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5991 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5992 | ds_pool_ci.pNext = NULL; |
| 5993 | ds_pool_ci.maxSets = 1; |
| 5994 | ds_pool_ci.poolSizeCount = 1; |
| 5995 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5996 | |
| 5997 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5998 | err = |
| 5999 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6000 | ASSERT_VK_SUCCESS(err); |
| 6001 | |
| 6002 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6003 | dsl_binding.binding = 0; |
| 6004 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 6005 | dsl_binding.descriptorCount = 1; |
| 6006 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6007 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6008 | |
| 6009 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6010 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6011 | ds_layout_ci.pNext = NULL; |
| 6012 | ds_layout_ci.bindingCount = 1; |
| 6013 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6014 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6015 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6016 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6017 | ASSERT_VK_SUCCESS(err); |
| 6018 | |
| 6019 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6020 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6021 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6022 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6023 | alloc_info.descriptorPool = ds_pool; |
| 6024 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6025 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6026 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6027 | ASSERT_VK_SUCCESS(err); |
| 6028 | |
| 6029 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6030 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6031 | sampler_ci.pNext = NULL; |
| 6032 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6033 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6034 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6035 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6036 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6037 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6038 | sampler_ci.mipLodBias = 1.0; |
| 6039 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6040 | sampler_ci.maxAnisotropy = 1; |
| 6041 | sampler_ci.compareEnable = VK_FALSE; |
| 6042 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6043 | sampler_ci.minLod = 1.0; |
| 6044 | sampler_ci.maxLod = 1.0; |
| 6045 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6046 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6047 | |
| 6048 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6049 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6050 | ASSERT_VK_SUCCESS(err); |
| 6051 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6052 | VkImageView view = |
| 6053 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6054 | |
| 6055 | VkDescriptorImageInfo descriptor_info; |
| 6056 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 6057 | descriptor_info.sampler = sampler; |
| 6058 | descriptor_info.imageView = view; |
| 6059 | |
| 6060 | VkWriteDescriptorSet descriptor_write; |
| 6061 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6062 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6063 | descriptor_write.dstSet = descriptorSet; |
| 6064 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6065 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6066 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 6067 | descriptor_write.pImageInfo = &descriptor_info; |
| 6068 | |
| 6069 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6070 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6071 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6072 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6073 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6074 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6075 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6076 | } |
| 6077 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6078 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 6079 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 6080 | // into the other |
| 6081 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6082 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6083 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6084 | " binding #1 with type " |
| 6085 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 6086 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6087 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6088 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6089 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6090 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6091 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6092 | ds_type_count[0].descriptorCount = 1; |
| 6093 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6094 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6095 | |
| 6096 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6097 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6098 | ds_pool_ci.pNext = NULL; |
| 6099 | ds_pool_ci.maxSets = 1; |
| 6100 | ds_pool_ci.poolSizeCount = 2; |
| 6101 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6102 | |
| 6103 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6104 | err = |
| 6105 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6106 | ASSERT_VK_SUCCESS(err); |
| 6107 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6108 | dsl_binding[0].binding = 0; |
| 6109 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6110 | dsl_binding[0].descriptorCount = 1; |
| 6111 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 6112 | dsl_binding[0].pImmutableSamplers = NULL; |
| 6113 | dsl_binding[1].binding = 1; |
| 6114 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6115 | dsl_binding[1].descriptorCount = 1; |
| 6116 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 6117 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6118 | |
| 6119 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6120 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6121 | ds_layout_ci.pNext = NULL; |
| 6122 | ds_layout_ci.bindingCount = 2; |
| 6123 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6124 | |
| 6125 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6126 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6127 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6128 | ASSERT_VK_SUCCESS(err); |
| 6129 | |
| 6130 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6131 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6132 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6133 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6134 | alloc_info.descriptorPool = ds_pool; |
| 6135 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6136 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6137 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6138 | ASSERT_VK_SUCCESS(err); |
| 6139 | |
| 6140 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6141 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6142 | sampler_ci.pNext = NULL; |
| 6143 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6144 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6145 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6146 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6147 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6148 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6149 | sampler_ci.mipLodBias = 1.0; |
| 6150 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6151 | sampler_ci.maxAnisotropy = 1; |
| 6152 | sampler_ci.compareEnable = VK_FALSE; |
| 6153 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6154 | sampler_ci.minLod = 1.0; |
| 6155 | sampler_ci.maxLod = 1.0; |
| 6156 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6157 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6158 | |
| 6159 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6160 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6161 | ASSERT_VK_SUCCESS(err); |
| 6162 | |
| 6163 | VkDescriptorImageInfo info = {}; |
| 6164 | info.sampler = sampler; |
| 6165 | |
| 6166 | VkWriteDescriptorSet descriptor_write; |
| 6167 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 6168 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6169 | descriptor_write.dstSet = descriptorSet; |
| 6170 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6171 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6172 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6173 | descriptor_write.pImageInfo = &info; |
| 6174 | // This write update should succeed |
| 6175 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6176 | // Now perform a copy update that fails due to type mismatch |
| 6177 | VkCopyDescriptorSet copy_ds_update; |
| 6178 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6179 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6180 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6181 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6182 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6183 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6184 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6185 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6186 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6187 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6188 | // Now perform a copy update that fails due to binding out of bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6189 | m_errorMonitor->SetDesiredFailureMsg( |
| 6190 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6191 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6192 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6193 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6194 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6195 | copy_ds_update.srcBinding = |
| 6196 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6197 | copy_ds_update.dstSet = descriptorSet; |
| 6198 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6199 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6200 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6201 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6202 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6203 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6204 | // Now perform a copy update that fails due to binding out of bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6205 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6206 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 6207 | "update array offset of 0 and update of " |
| 6208 | "5 descriptors oversteps total number " |
| 6209 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6210 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6211 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6212 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6213 | copy_ds_update.srcSet = descriptorSet; |
| 6214 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6215 | copy_ds_update.dstSet = descriptorSet; |
| 6216 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6217 | copy_ds_update.descriptorCount = |
| 6218 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6219 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6220 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6221 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6222 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6223 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6224 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6225 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6226 | } |
| 6227 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6228 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 6229 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 6230 | // sampleCount |
| 6231 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6232 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6233 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6234 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6235 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6236 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6237 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6238 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6239 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6240 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6241 | |
| 6242 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6243 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6244 | ds_pool_ci.pNext = NULL; |
| 6245 | ds_pool_ci.maxSets = 1; |
| 6246 | ds_pool_ci.poolSizeCount = 1; |
| 6247 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6248 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6249 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6250 | err = |
| 6251 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6252 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6253 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6254 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6255 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6256 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6257 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6258 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6259 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6260 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6261 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6262 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6263 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6264 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6265 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6266 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6267 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6268 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6269 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6270 | ASSERT_VK_SUCCESS(err); |
| 6271 | |
| 6272 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6273 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6274 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6275 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6276 | alloc_info.descriptorPool = ds_pool; |
| 6277 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6278 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6279 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6280 | ASSERT_VK_SUCCESS(err); |
| 6281 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6282 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6283 | pipe_ms_state_ci.sType = |
| 6284 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6285 | pipe_ms_state_ci.pNext = NULL; |
| 6286 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6287 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6288 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6289 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6290 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6291 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6292 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6293 | pipeline_layout_ci.pNext = NULL; |
| 6294 | pipeline_layout_ci.setLayoutCount = 1; |
| 6295 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6296 | |
| 6297 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6298 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6299 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6300 | ASSERT_VK_SUCCESS(err); |
| 6301 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6302 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6303 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6304 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6305 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6306 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6307 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6308 | VkPipelineObj pipe(m_device); |
| 6309 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6310 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6311 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6312 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6313 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6314 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6315 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6316 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6317 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6318 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6319 | // Render triangle (the error should trigger on the attempt to draw). |
| 6320 | Draw(3, 1, 0, 0); |
| 6321 | |
| 6322 | // Finalize recording of the command buffer |
| 6323 | EndCommandBuffer(); |
| 6324 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6325 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6326 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6327 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6328 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6329 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6330 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6331 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6332 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 6333 | // Create Pipeline where the number of blend attachments doesn't match the |
| 6334 | // number of color attachments. In this case, we don't add any color |
| 6335 | // blend attachments even though we have a color attachment. |
| 6336 | VkResult err; |
| 6337 | |
| 6338 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6339 | "Render pass subpass 0 mismatch with blending state defined and blend state attachment"); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6340 | |
| 6341 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6342 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6343 | VkDescriptorPoolSize ds_type_count = {}; |
| 6344 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6345 | ds_type_count.descriptorCount = 1; |
| 6346 | |
| 6347 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6348 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6349 | ds_pool_ci.pNext = NULL; |
| 6350 | ds_pool_ci.maxSets = 1; |
| 6351 | ds_pool_ci.poolSizeCount = 1; |
| 6352 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6353 | |
| 6354 | VkDescriptorPool ds_pool; |
| 6355 | err = |
| 6356 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6357 | ASSERT_VK_SUCCESS(err); |
| 6358 | |
| 6359 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6360 | dsl_binding.binding = 0; |
| 6361 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6362 | dsl_binding.descriptorCount = 1; |
| 6363 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6364 | dsl_binding.pImmutableSamplers = NULL; |
| 6365 | |
| 6366 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6367 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6368 | ds_layout_ci.pNext = NULL; |
| 6369 | ds_layout_ci.bindingCount = 1; |
| 6370 | ds_layout_ci.pBindings = &dsl_binding; |
| 6371 | |
| 6372 | VkDescriptorSetLayout ds_layout; |
| 6373 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6374 | &ds_layout); |
| 6375 | ASSERT_VK_SUCCESS(err); |
| 6376 | |
| 6377 | VkDescriptorSet descriptorSet; |
| 6378 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6379 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6380 | alloc_info.descriptorSetCount = 1; |
| 6381 | alloc_info.descriptorPool = ds_pool; |
| 6382 | alloc_info.pSetLayouts = &ds_layout; |
| 6383 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6384 | &descriptorSet); |
| 6385 | ASSERT_VK_SUCCESS(err); |
| 6386 | |
| 6387 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 6388 | pipe_ms_state_ci.sType = |
| 6389 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6390 | pipe_ms_state_ci.pNext = NULL; |
| 6391 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6392 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6393 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6394 | pipe_ms_state_ci.pSampleMask = NULL; |
| 6395 | |
| 6396 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6397 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6398 | pipeline_layout_ci.pNext = NULL; |
| 6399 | pipeline_layout_ci.setLayoutCount = 1; |
| 6400 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6401 | |
| 6402 | VkPipelineLayout pipeline_layout; |
| 6403 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6404 | &pipeline_layout); |
| 6405 | ASSERT_VK_SUCCESS(err); |
| 6406 | |
| 6407 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6408 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6409 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6410 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6411 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6412 | // but add it to be able to run on more devices |
| 6413 | VkPipelineObj pipe(m_device); |
| 6414 | pipe.AddShader(&vs); |
| 6415 | pipe.AddShader(&fs); |
| 6416 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6417 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 6418 | |
| 6419 | BeginCommandBuffer(); |
| 6420 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6421 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6422 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6423 | // Render triangle (the error should trigger on the attempt to draw). |
| 6424 | Draw(3, 1, 0, 0); |
| 6425 | |
| 6426 | // Finalize recording of the command buffer |
| 6427 | EndCommandBuffer(); |
| 6428 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6429 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6430 | |
| 6431 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6432 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6433 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6434 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6435 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6436 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 6437 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 6438 | // to issuing a Draw |
| 6439 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6440 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6441 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 6442 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6443 | "vkCmdClearAttachments() issued on CB object "); |
| 6444 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6445 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6446 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6447 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6448 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6449 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6450 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6451 | |
| 6452 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6453 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6454 | ds_pool_ci.pNext = NULL; |
| 6455 | ds_pool_ci.maxSets = 1; |
| 6456 | ds_pool_ci.poolSizeCount = 1; |
| 6457 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6458 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6459 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6460 | err = |
| 6461 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6462 | ASSERT_VK_SUCCESS(err); |
| 6463 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6464 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6465 | dsl_binding.binding = 0; |
| 6466 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6467 | dsl_binding.descriptorCount = 1; |
| 6468 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6469 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6470 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6471 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6472 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6473 | ds_layout_ci.pNext = NULL; |
| 6474 | ds_layout_ci.bindingCount = 1; |
| 6475 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6476 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6477 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6478 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6479 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6480 | ASSERT_VK_SUCCESS(err); |
| 6481 | |
| 6482 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6483 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6484 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6485 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6486 | alloc_info.descriptorPool = ds_pool; |
| 6487 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6488 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6489 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6490 | ASSERT_VK_SUCCESS(err); |
| 6491 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6492 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6493 | pipe_ms_state_ci.sType = |
| 6494 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6495 | pipe_ms_state_ci.pNext = NULL; |
| 6496 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6497 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6498 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6499 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6500 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6501 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6502 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6503 | pipeline_layout_ci.pNext = NULL; |
| 6504 | pipeline_layout_ci.setLayoutCount = 1; |
| 6505 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6506 | |
| 6507 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6508 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6509 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6510 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6511 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6512 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6513 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6514 | // We shouldn't need a fragment shader but add it to be able to run |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6515 | // on more devices |
| 6516 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6517 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6518 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6519 | VkPipelineObj pipe(m_device); |
| 6520 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6521 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6522 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6523 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6524 | |
| 6525 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6526 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6527 | // Main thing we care about for this test is that the VkImage obj we're |
| 6528 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6529 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6530 | VkClearAttachment color_attachment; |
| 6531 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6532 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 6533 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 6534 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 6535 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 6536 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6537 | VkClearRect clear_rect = { |
| 6538 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6539 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6540 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6541 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6542 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6543 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6544 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6545 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6546 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6547 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6548 | } |
| 6549 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6550 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 6551 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6552 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6553 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6554 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 6555 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6556 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6557 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6558 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6559 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6560 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6561 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6562 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6563 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6564 | |
| 6565 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6566 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6567 | ds_pool_ci.pNext = NULL; |
| 6568 | ds_pool_ci.maxSets = 1; |
| 6569 | ds_pool_ci.poolSizeCount = 1; |
| 6570 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6571 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6572 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6573 | err = |
| 6574 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6575 | ASSERT_VK_SUCCESS(err); |
| 6576 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6577 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6578 | dsl_binding.binding = 0; |
| 6579 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6580 | dsl_binding.descriptorCount = 1; |
| 6581 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6582 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6583 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6584 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6585 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6586 | ds_layout_ci.pNext = NULL; |
| 6587 | ds_layout_ci.bindingCount = 1; |
| 6588 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6589 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6590 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6591 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6592 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6593 | ASSERT_VK_SUCCESS(err); |
| 6594 | |
| 6595 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6596 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6597 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6598 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6599 | alloc_info.descriptorPool = ds_pool; |
| 6600 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6601 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6602 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6603 | ASSERT_VK_SUCCESS(err); |
| 6604 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6605 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6606 | pipe_ms_state_ci.sType = |
| 6607 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6608 | pipe_ms_state_ci.pNext = NULL; |
| 6609 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6610 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6611 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6612 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6613 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6614 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6615 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6616 | pipeline_layout_ci.pNext = NULL; |
| 6617 | pipeline_layout_ci.setLayoutCount = 1; |
| 6618 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6619 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6620 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6621 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6622 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6623 | ASSERT_VK_SUCCESS(err); |
| 6624 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6625 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6626 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6627 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6628 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6629 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6630 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6631 | VkPipelineObj pipe(m_device); |
| 6632 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6633 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6634 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6635 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6636 | pipe.SetViewport(m_viewports); |
| 6637 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6638 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6639 | |
| 6640 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6641 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6642 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6643 | // Don't care about actual data, just need to get to draw to flag error |
| 6644 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6645 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 6646 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6647 | BindVertexBuffer(&vbo, (VkDeviceSize)0, 1); // VBO idx 1, but no VBO in PSO |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 6648 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6649 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6650 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6651 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6652 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6653 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6654 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6655 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 6656 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 6657 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 6658 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 6659 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 6660 | "images in the wrong layout when they're copied or transitioned."); |
| 6661 | // 3 in ValidateCmdBufImageLayouts |
| 6662 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 6663 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 6664 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 6665 | m_errorMonitor->SetDesiredFailureMsg( |
| 6666 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6667 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 6668 | |
| 6669 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6670 | // Create src & dst images to use for copy operations |
| 6671 | VkImage src_image; |
| 6672 | VkImage dst_image; |
| 6673 | |
| 6674 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6675 | const int32_t tex_width = 32; |
| 6676 | const int32_t tex_height = 32; |
| 6677 | |
| 6678 | VkImageCreateInfo image_create_info = {}; |
| 6679 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6680 | image_create_info.pNext = NULL; |
| 6681 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6682 | image_create_info.format = tex_format; |
| 6683 | image_create_info.extent.width = tex_width; |
| 6684 | image_create_info.extent.height = tex_height; |
| 6685 | image_create_info.extent.depth = 1; |
| 6686 | image_create_info.mipLevels = 1; |
| 6687 | image_create_info.arrayLayers = 4; |
| 6688 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6689 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6690 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6691 | image_create_info.flags = 0; |
| 6692 | |
| 6693 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 6694 | ASSERT_VK_SUCCESS(err); |
| 6695 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 6696 | ASSERT_VK_SUCCESS(err); |
| 6697 | |
| 6698 | BeginCommandBuffer(); |
| 6699 | VkImageCopy copyRegion; |
| 6700 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6701 | copyRegion.srcSubresource.mipLevel = 0; |
| 6702 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 6703 | copyRegion.srcSubresource.layerCount = 1; |
| 6704 | copyRegion.srcOffset.x = 0; |
| 6705 | copyRegion.srcOffset.y = 0; |
| 6706 | copyRegion.srcOffset.z = 0; |
| 6707 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6708 | copyRegion.dstSubresource.mipLevel = 0; |
| 6709 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6710 | copyRegion.dstSubresource.layerCount = 1; |
| 6711 | copyRegion.dstOffset.x = 0; |
| 6712 | copyRegion.dstOffset.y = 0; |
| 6713 | copyRegion.dstOffset.z = 0; |
| 6714 | copyRegion.extent.width = 1; |
| 6715 | copyRegion.extent.height = 1; |
| 6716 | copyRegion.extent.depth = 1; |
| 6717 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6718 | m_errorMonitor->VerifyFound(); |
| 6719 | // Now cause error due to src image layout changing |
| 6720 | m_errorMonitor->SetDesiredFailureMsg( |
| 6721 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6722 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 6723 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6724 | m_errorMonitor->VerifyFound(); |
| 6725 | // Final src error is due to bad layout type |
| 6726 | m_errorMonitor->SetDesiredFailureMsg( |
| 6727 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6728 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 6729 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6730 | m_errorMonitor->VerifyFound(); |
| 6731 | // Now verify same checks for dst |
| 6732 | m_errorMonitor->SetDesiredFailureMsg( |
| 6733 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6734 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 6735 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6736 | m_errorMonitor->VerifyFound(); |
| 6737 | // Now cause error due to src image layout changing |
| 6738 | m_errorMonitor->SetDesiredFailureMsg( |
| 6739 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6740 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 6741 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 6742 | m_errorMonitor->VerifyFound(); |
| 6743 | m_errorMonitor->SetDesiredFailureMsg( |
| 6744 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6745 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 6746 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 6747 | m_errorMonitor->VerifyFound(); |
| 6748 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 6749 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 6750 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 6751 | image_barrier[0].image = src_image; |
| 6752 | image_barrier[0].subresourceRange.layerCount = 2; |
| 6753 | image_barrier[0].subresourceRange.levelCount = 2; |
| 6754 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6755 | m_errorMonitor->SetDesiredFailureMsg( |
| 6756 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6757 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 6758 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 6759 | m_errorMonitor->VerifyFound(); |
| 6760 | |
| 6761 | // Finally some layout errors at RenderPass create time |
| 6762 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 6763 | VkAttachmentReference attach = {}; |
| 6764 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 6765 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6766 | VkSubpassDescription subpass = {}; |
| 6767 | subpass.inputAttachmentCount = 1; |
| 6768 | subpass.pInputAttachments = &attach; |
| 6769 | VkRenderPassCreateInfo rpci = {}; |
| 6770 | rpci.subpassCount = 1; |
| 6771 | rpci.pSubpasses = &subpass; |
| 6772 | rpci.attachmentCount = 1; |
| 6773 | VkAttachmentDescription attach_desc = {}; |
| 6774 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 6775 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 6776 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 6777 | VkRenderPass rp; |
| 6778 | m_errorMonitor->SetDesiredFailureMsg( |
| 6779 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6780 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 6781 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6782 | m_errorMonitor->VerifyFound(); |
| 6783 | // error w/ non-general layout |
| 6784 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 6785 | |
| 6786 | m_errorMonitor->SetDesiredFailureMsg( |
| 6787 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6788 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 6789 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6790 | m_errorMonitor->VerifyFound(); |
| 6791 | subpass.inputAttachmentCount = 0; |
| 6792 | subpass.colorAttachmentCount = 1; |
| 6793 | subpass.pColorAttachments = &attach; |
| 6794 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6795 | // perf warning for GENERAL layout on color attachment |
| 6796 | m_errorMonitor->SetDesiredFailureMsg( |
| 6797 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6798 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 6799 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6800 | m_errorMonitor->VerifyFound(); |
| 6801 | // error w/ non-color opt or GENERAL layout for color attachment |
| 6802 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 6803 | m_errorMonitor->SetDesiredFailureMsg( |
| 6804 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6805 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 6806 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6807 | m_errorMonitor->VerifyFound(); |
| 6808 | subpass.colorAttachmentCount = 0; |
| 6809 | subpass.pDepthStencilAttachment = &attach; |
| 6810 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6811 | // perf warning for GENERAL layout on DS attachment |
| 6812 | m_errorMonitor->SetDesiredFailureMsg( |
| 6813 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6814 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 6815 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6816 | m_errorMonitor->VerifyFound(); |
| 6817 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 6818 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 6819 | m_errorMonitor->SetDesiredFailureMsg( |
| 6820 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6821 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 6822 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6823 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 6824 | // For this error we need a valid renderpass so create default one |
| 6825 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 6826 | attach.attachment = 0; |
| 6827 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6828 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6829 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 6830 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 6831 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 6832 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 6833 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 6834 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 6835 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6836 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6837 | " with invalid first layout " |
| 6838 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 6839 | "ONLY_OPTIMAL"); |
| 6840 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6841 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 6842 | |
| 6843 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 6844 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 6845 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6846 | #endif // DRAW_STATE_TESTS |
| 6847 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 6848 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6849 | #if GTEST_IS_THREADSAFE |
| 6850 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6851 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6852 | VkEvent event; |
| 6853 | bool bailout; |
| 6854 | }; |
| 6855 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6856 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 6857 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6858 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6859 | for (int i = 0; i < 10000; i++) { |
| 6860 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 6861 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6862 | if (data->bailout) { |
| 6863 | break; |
| 6864 | } |
| 6865 | } |
| 6866 | return NULL; |
| 6867 | } |
| 6868 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6869 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6870 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6871 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6872 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6873 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6874 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6875 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6876 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6877 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6878 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6879 | // Calls AllocateCommandBuffers |
| 6880 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6881 | |
| 6882 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6883 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6884 | |
| 6885 | VkEventCreateInfo event_info; |
| 6886 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6887 | VkResult err; |
| 6888 | |
| 6889 | memset(&event_info, 0, sizeof(event_info)); |
| 6890 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 6891 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6892 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6893 | ASSERT_VK_SUCCESS(err); |
| 6894 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6895 | err = vkResetEvent(device(), event); |
| 6896 | ASSERT_VK_SUCCESS(err); |
| 6897 | |
| 6898 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6899 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6900 | data.event = event; |
| 6901 | data.bailout = false; |
| 6902 | m_errorMonitor->SetBailout(&data.bailout); |
| 6903 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6904 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6905 | // Add many entries to command buffer from this thread at the same time. |
| 6906 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6907 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6908 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6909 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6910 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 6911 | m_errorMonitor->SetBailout(NULL); |
| 6912 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6913 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6914 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6915 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6916 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6917 | #endif // GTEST_IS_THREADSAFE |
| 6918 | #endif // THREADING_TESTS |
| 6919 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6920 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6921 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6922 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6923 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6924 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6925 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6926 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6927 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6928 | VkShaderModule module; |
| 6929 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6930 | struct icd_spv_header spv; |
| 6931 | |
| 6932 | spv.magic = ICD_SPV_MAGIC; |
| 6933 | spv.version = ICD_SPV_VERSION; |
| 6934 | spv.gen_magic = 0; |
| 6935 | |
| 6936 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6937 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6938 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6939 | moduleCreateInfo.codeSize = 4; |
| 6940 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6941 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6942 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6943 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6944 | } |
| 6945 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6946 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6947 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6948 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6949 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6950 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6951 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6952 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6953 | VkShaderModule module; |
| 6954 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6955 | struct icd_spv_header spv; |
| 6956 | |
| 6957 | spv.magic = ~ICD_SPV_MAGIC; |
| 6958 | spv.version = ICD_SPV_VERSION; |
| 6959 | spv.gen_magic = 0; |
| 6960 | |
| 6961 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6962 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6963 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6964 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6965 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6966 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6967 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6968 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6969 | } |
| 6970 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6971 | #if 0 |
| 6972 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6973 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6974 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6975 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6976 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6977 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6978 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6979 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6980 | VkShaderModule module; |
| 6981 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6982 | struct icd_spv_header spv; |
| 6983 | |
| 6984 | spv.magic = ICD_SPV_MAGIC; |
| 6985 | spv.version = ~ICD_SPV_VERSION; |
| 6986 | spv.gen_magic = 0; |
| 6987 | |
| 6988 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6989 | moduleCreateInfo.pNext = NULL; |
| 6990 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6991 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6992 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6993 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6994 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6995 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6996 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6997 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6998 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6999 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7000 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7001 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7002 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7003 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7004 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7005 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7006 | |
| 7007 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7008 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7009 | "\n" |
| 7010 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7011 | "out gl_PerVertex {\n" |
| 7012 | " vec4 gl_Position;\n" |
| 7013 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7014 | "void main(){\n" |
| 7015 | " gl_Position = vec4(1);\n" |
| 7016 | " x = 0;\n" |
| 7017 | "}\n"; |
| 7018 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7019 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7020 | "\n" |
| 7021 | "layout(location=0) out vec4 color;\n" |
| 7022 | "void main(){\n" |
| 7023 | " color = vec4(1);\n" |
| 7024 | "}\n"; |
| 7025 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7026 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7027 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7028 | |
| 7029 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7030 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7031 | pipe.AddShader(&vs); |
| 7032 | pipe.AddShader(&fs); |
| 7033 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7034 | VkDescriptorSetObj descriptorSet(m_device); |
| 7035 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7036 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7037 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7038 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7039 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7040 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7041 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7042 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7043 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7044 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7045 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7046 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7047 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7048 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7049 | |
| 7050 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7051 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7052 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7053 | "out gl_PerVertex {\n" |
| 7054 | " vec4 gl_Position;\n" |
| 7055 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7056 | "void main(){\n" |
| 7057 | " gl_Position = vec4(1);\n" |
| 7058 | "}\n"; |
| 7059 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7060 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7061 | "\n" |
| 7062 | "layout(location=0) in float x;\n" |
| 7063 | "layout(location=0) out vec4 color;\n" |
| 7064 | "void main(){\n" |
| 7065 | " color = vec4(x);\n" |
| 7066 | "}\n"; |
| 7067 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7068 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7069 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7070 | |
| 7071 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7072 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7073 | pipe.AddShader(&vs); |
| 7074 | pipe.AddShader(&fs); |
| 7075 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7076 | VkDescriptorSetObj descriptorSet(m_device); |
| 7077 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7078 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7079 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7080 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7081 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7082 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7083 | } |
| 7084 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7085 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7086 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7087 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7088 | |
| 7089 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7090 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7091 | |
| 7092 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7093 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7094 | "\n" |
| 7095 | "out gl_PerVertex {\n" |
| 7096 | " vec4 gl_Position;\n" |
| 7097 | "};\n" |
| 7098 | "void main(){\n" |
| 7099 | " gl_Position = vec4(1);\n" |
| 7100 | "}\n"; |
| 7101 | char const *fsSource = |
| 7102 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7103 | "\n" |
| 7104 | "in block { layout(location=0) float x; } ins;\n" |
| 7105 | "layout(location=0) out vec4 color;\n" |
| 7106 | "void main(){\n" |
| 7107 | " color = vec4(ins.x);\n" |
| 7108 | "}\n"; |
| 7109 | |
| 7110 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7111 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7112 | |
| 7113 | VkPipelineObj pipe(m_device); |
| 7114 | pipe.AddColorAttachment(); |
| 7115 | pipe.AddShader(&vs); |
| 7116 | pipe.AddShader(&fs); |
| 7117 | |
| 7118 | VkDescriptorSetObj descriptorSet(m_device); |
| 7119 | descriptorSet.AppendDummy(); |
| 7120 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7121 | |
| 7122 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7123 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7124 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7125 | } |
| 7126 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7127 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7128 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7129 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7130 | "output arr[2] of float32' vs 'ptr to " |
| 7131 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7132 | |
| 7133 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7134 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7135 | |
| 7136 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7137 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7138 | "\n" |
| 7139 | "layout(location=0) out float x[2];\n" |
| 7140 | "out gl_PerVertex {\n" |
| 7141 | " vec4 gl_Position;\n" |
| 7142 | "};\n" |
| 7143 | "void main(){\n" |
| 7144 | " x[0] = 0; x[1] = 0;\n" |
| 7145 | " gl_Position = vec4(1);\n" |
| 7146 | "}\n"; |
| 7147 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7148 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7149 | "\n" |
| 7150 | "layout(location=0) in float x[3];\n" |
| 7151 | "layout(location=0) out vec4 color;\n" |
| 7152 | "void main(){\n" |
| 7153 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 7154 | "}\n"; |
| 7155 | |
| 7156 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7157 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7158 | |
| 7159 | VkPipelineObj pipe(m_device); |
| 7160 | pipe.AddColorAttachment(); |
| 7161 | pipe.AddShader(&vs); |
| 7162 | pipe.AddShader(&fs); |
| 7163 | |
| 7164 | VkDescriptorSetObj descriptorSet(m_device); |
| 7165 | descriptorSet.AppendDummy(); |
| 7166 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7167 | |
| 7168 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7169 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7170 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7171 | } |
| 7172 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7173 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7174 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7175 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7176 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7177 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7178 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7179 | |
| 7180 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7181 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7182 | "\n" |
| 7183 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7184 | "out gl_PerVertex {\n" |
| 7185 | " vec4 gl_Position;\n" |
| 7186 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7187 | "void main(){\n" |
| 7188 | " x = 0;\n" |
| 7189 | " gl_Position = vec4(1);\n" |
| 7190 | "}\n"; |
| 7191 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7192 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7193 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7194 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7195 | "layout(location=0) out vec4 color;\n" |
| 7196 | "void main(){\n" |
| 7197 | " color = vec4(x);\n" |
| 7198 | "}\n"; |
| 7199 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7200 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7201 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7202 | |
| 7203 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7204 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7205 | pipe.AddShader(&vs); |
| 7206 | pipe.AddShader(&fs); |
| 7207 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7208 | VkDescriptorSetObj descriptorSet(m_device); |
| 7209 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7210 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7211 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7212 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7213 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7214 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7215 | } |
| 7216 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7217 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7218 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7219 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7220 | |
| 7221 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7222 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7223 | |
| 7224 | char const *vsSource = |
| 7225 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7226 | "\n" |
| 7227 | "out block { layout(location=0) int x; } outs;\n" |
| 7228 | "out gl_PerVertex {\n" |
| 7229 | " vec4 gl_Position;\n" |
| 7230 | "};\n" |
| 7231 | "void main(){\n" |
| 7232 | " outs.x = 0;\n" |
| 7233 | " gl_Position = vec4(1);\n" |
| 7234 | "}\n"; |
| 7235 | char const *fsSource = |
| 7236 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7237 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7238 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7239 | "layout(location=0) out vec4 color;\n" |
| 7240 | "void main(){\n" |
| 7241 | " color = vec4(ins.x);\n" |
| 7242 | "}\n"; |
| 7243 | |
| 7244 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7245 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7246 | |
| 7247 | VkPipelineObj pipe(m_device); |
| 7248 | pipe.AddColorAttachment(); |
| 7249 | pipe.AddShader(&vs); |
| 7250 | pipe.AddShader(&fs); |
| 7251 | |
| 7252 | VkDescriptorSetObj descriptorSet(m_device); |
| 7253 | descriptorSet.AppendDummy(); |
| 7254 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7255 | |
| 7256 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7257 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7258 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7259 | } |
| 7260 | |
| 7261 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 7262 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7263 | "location 0.0 which is not written by vertex shader"); |
| 7264 | |
| 7265 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7266 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7267 | |
| 7268 | char const *vsSource = |
| 7269 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7270 | "\n" |
| 7271 | "out block { layout(location=1) float x; } outs;\n" |
| 7272 | "out gl_PerVertex {\n" |
| 7273 | " vec4 gl_Position;\n" |
| 7274 | "};\n" |
| 7275 | "void main(){\n" |
| 7276 | " outs.x = 0;\n" |
| 7277 | " gl_Position = vec4(1);\n" |
| 7278 | "}\n"; |
| 7279 | char const *fsSource = |
| 7280 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7281 | "\n" |
| 7282 | "in block { layout(location=0) float x; } ins;\n" |
| 7283 | "layout(location=0) out vec4 color;\n" |
| 7284 | "void main(){\n" |
| 7285 | " color = vec4(ins.x);\n" |
| 7286 | "}\n"; |
| 7287 | |
| 7288 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7289 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7290 | |
| 7291 | VkPipelineObj pipe(m_device); |
| 7292 | pipe.AddColorAttachment(); |
| 7293 | pipe.AddShader(&vs); |
| 7294 | pipe.AddShader(&fs); |
| 7295 | |
| 7296 | VkDescriptorSetObj descriptorSet(m_device); |
| 7297 | descriptorSet.AppendDummy(); |
| 7298 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7299 | |
| 7300 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7301 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7302 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7303 | } |
| 7304 | |
| 7305 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 7306 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7307 | "location 0.1 which is not written by vertex shader"); |
| 7308 | |
| 7309 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7310 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7311 | |
| 7312 | char const *vsSource = |
| 7313 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7314 | "\n" |
| 7315 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 7316 | "out gl_PerVertex {\n" |
| 7317 | " vec4 gl_Position;\n" |
| 7318 | "};\n" |
| 7319 | "void main(){\n" |
| 7320 | " outs.x = 0;\n" |
| 7321 | " gl_Position = vec4(1);\n" |
| 7322 | "}\n"; |
| 7323 | char const *fsSource = |
| 7324 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7325 | "\n" |
| 7326 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 7327 | "layout(location=0) out vec4 color;\n" |
| 7328 | "void main(){\n" |
| 7329 | " color = vec4(ins.x);\n" |
| 7330 | "}\n"; |
| 7331 | |
| 7332 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7333 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7334 | |
| 7335 | VkPipelineObj pipe(m_device); |
| 7336 | pipe.AddColorAttachment(); |
| 7337 | pipe.AddShader(&vs); |
| 7338 | pipe.AddShader(&fs); |
| 7339 | |
| 7340 | VkDescriptorSetObj descriptorSet(m_device); |
| 7341 | descriptorSet.AppendDummy(); |
| 7342 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7343 | |
| 7344 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7345 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7346 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7347 | } |
| 7348 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7349 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7350 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7351 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7352 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7353 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7354 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7355 | |
| 7356 | VkVertexInputBindingDescription input_binding; |
| 7357 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7358 | |
| 7359 | VkVertexInputAttributeDescription input_attrib; |
| 7360 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7361 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7362 | |
| 7363 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7364 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7365 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7366 | "out gl_PerVertex {\n" |
| 7367 | " vec4 gl_Position;\n" |
| 7368 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7369 | "void main(){\n" |
| 7370 | " gl_Position = vec4(1);\n" |
| 7371 | "}\n"; |
| 7372 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7373 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7374 | "\n" |
| 7375 | "layout(location=0) out vec4 color;\n" |
| 7376 | "void main(){\n" |
| 7377 | " color = vec4(1);\n" |
| 7378 | "}\n"; |
| 7379 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7380 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7381 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7382 | |
| 7383 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7384 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7385 | pipe.AddShader(&vs); |
| 7386 | pipe.AddShader(&fs); |
| 7387 | |
| 7388 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7389 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7390 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7391 | VkDescriptorSetObj descriptorSet(m_device); |
| 7392 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7393 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7394 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7395 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7396 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7397 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7398 | } |
| 7399 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7400 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7401 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7402 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7403 | |
| 7404 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7405 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7406 | |
| 7407 | VkVertexInputBindingDescription input_binding; |
| 7408 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7409 | |
| 7410 | VkVertexInputAttributeDescription input_attrib; |
| 7411 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7412 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7413 | |
| 7414 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7415 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7416 | "\n" |
| 7417 | "layout(location=1) in float x;\n" |
| 7418 | "out gl_PerVertex {\n" |
| 7419 | " vec4 gl_Position;\n" |
| 7420 | "};\n" |
| 7421 | "void main(){\n" |
| 7422 | " gl_Position = vec4(x);\n" |
| 7423 | "}\n"; |
| 7424 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7425 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7426 | "\n" |
| 7427 | "layout(location=0) out vec4 color;\n" |
| 7428 | "void main(){\n" |
| 7429 | " color = vec4(1);\n" |
| 7430 | "}\n"; |
| 7431 | |
| 7432 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7433 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7434 | |
| 7435 | VkPipelineObj pipe(m_device); |
| 7436 | pipe.AddColorAttachment(); |
| 7437 | pipe.AddShader(&vs); |
| 7438 | pipe.AddShader(&fs); |
| 7439 | |
| 7440 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7441 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7442 | |
| 7443 | VkDescriptorSetObj descriptorSet(m_device); |
| 7444 | descriptorSet.AppendDummy(); |
| 7445 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7446 | |
| 7447 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7448 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7449 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7450 | } |
| 7451 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7452 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 7453 | m_errorMonitor->SetDesiredFailureMsg( |
| 7454 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7455 | "VS consumes input at location 0 but not provided"); |
| 7456 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7457 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7458 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7459 | |
| 7460 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7461 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7462 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7463 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7464 | "out gl_PerVertex {\n" |
| 7465 | " vec4 gl_Position;\n" |
| 7466 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7467 | "void main(){\n" |
| 7468 | " gl_Position = x;\n" |
| 7469 | "}\n"; |
| 7470 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7471 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7472 | "\n" |
| 7473 | "layout(location=0) out vec4 color;\n" |
| 7474 | "void main(){\n" |
| 7475 | " color = vec4(1);\n" |
| 7476 | "}\n"; |
| 7477 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7478 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7479 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7480 | |
| 7481 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7482 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7483 | pipe.AddShader(&vs); |
| 7484 | pipe.AddShader(&fs); |
| 7485 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7486 | VkDescriptorSetObj descriptorSet(m_device); |
| 7487 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7488 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7489 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7490 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7491 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7492 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7493 | } |
| 7494 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7495 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 7496 | m_errorMonitor->SetDesiredFailureMsg( |
| 7497 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7498 | "location 0 does not match VS input type"); |
| 7499 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7500 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7501 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7502 | |
| 7503 | VkVertexInputBindingDescription input_binding; |
| 7504 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7505 | |
| 7506 | VkVertexInputAttributeDescription input_attrib; |
| 7507 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7508 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7509 | |
| 7510 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7511 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7512 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7513 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7514 | "out gl_PerVertex {\n" |
| 7515 | " vec4 gl_Position;\n" |
| 7516 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7517 | "void main(){\n" |
| 7518 | " gl_Position = vec4(x);\n" |
| 7519 | "}\n"; |
| 7520 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7521 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7522 | "\n" |
| 7523 | "layout(location=0) out vec4 color;\n" |
| 7524 | "void main(){\n" |
| 7525 | " color = vec4(1);\n" |
| 7526 | "}\n"; |
| 7527 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7528 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7529 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7530 | |
| 7531 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7532 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7533 | pipe.AddShader(&vs); |
| 7534 | pipe.AddShader(&fs); |
| 7535 | |
| 7536 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7537 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7538 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7539 | VkDescriptorSetObj descriptorSet(m_device); |
| 7540 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7541 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7542 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7543 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7544 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7545 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7546 | } |
| 7547 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7548 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 7549 | m_errorMonitor->SetDesiredFailureMsg( |
| 7550 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7551 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 7552 | |
| 7553 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7554 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7555 | |
| 7556 | char const *vsSource = |
| 7557 | "#version 450\n" |
| 7558 | "\n" |
| 7559 | "out gl_PerVertex {\n" |
| 7560 | " vec4 gl_Position;\n" |
| 7561 | "};\n" |
| 7562 | "void main(){\n" |
| 7563 | " gl_Position = vec4(1);\n" |
| 7564 | "}\n"; |
| 7565 | char const *fsSource = |
| 7566 | "#version 450\n" |
| 7567 | "\n" |
| 7568 | "layout(location=0) out vec4 color;\n" |
| 7569 | "void main(){\n" |
| 7570 | " color = vec4(1);\n" |
| 7571 | "}\n"; |
| 7572 | |
| 7573 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7574 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7575 | |
| 7576 | VkPipelineObj pipe(m_device); |
| 7577 | pipe.AddColorAttachment(); |
| 7578 | pipe.AddShader(&vs); |
| 7579 | pipe.AddShader(&vs); |
| 7580 | pipe.AddShader(&fs); |
| 7581 | |
| 7582 | VkDescriptorSetObj descriptorSet(m_device); |
| 7583 | descriptorSet.AppendDummy(); |
| 7584 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7585 | |
| 7586 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7587 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7588 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7589 | } |
| 7590 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7591 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7592 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7593 | |
| 7594 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7595 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7596 | |
| 7597 | VkVertexInputBindingDescription input_binding; |
| 7598 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7599 | |
| 7600 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7601 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7602 | |
| 7603 | for (int i = 0; i < 2; i++) { |
| 7604 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7605 | input_attribs[i].location = i; |
| 7606 | } |
| 7607 | |
| 7608 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7609 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7610 | "\n" |
| 7611 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7612 | "out gl_PerVertex {\n" |
| 7613 | " vec4 gl_Position;\n" |
| 7614 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7615 | "void main(){\n" |
| 7616 | " gl_Position = x[0] + x[1];\n" |
| 7617 | "}\n"; |
| 7618 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7619 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7620 | "\n" |
| 7621 | "layout(location=0) out vec4 color;\n" |
| 7622 | "void main(){\n" |
| 7623 | " color = vec4(1);\n" |
| 7624 | "}\n"; |
| 7625 | |
| 7626 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7627 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7628 | |
| 7629 | VkPipelineObj pipe(m_device); |
| 7630 | pipe.AddColorAttachment(); |
| 7631 | pipe.AddShader(&vs); |
| 7632 | pipe.AddShader(&fs); |
| 7633 | |
| 7634 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7635 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7636 | |
| 7637 | VkDescriptorSetObj descriptorSet(m_device); |
| 7638 | descriptorSet.AppendDummy(); |
| 7639 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7640 | |
| 7641 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7642 | |
| 7643 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7644 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7645 | } |
| 7646 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7647 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 7648 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7649 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7650 | |
| 7651 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7652 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7653 | |
| 7654 | VkVertexInputBindingDescription input_binding; |
| 7655 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7656 | |
| 7657 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7658 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7659 | |
| 7660 | for (int i = 0; i < 2; i++) { |
| 7661 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7662 | input_attribs[i].location = i; |
| 7663 | } |
| 7664 | |
| 7665 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7666 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7667 | "\n" |
| 7668 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7669 | "out gl_PerVertex {\n" |
| 7670 | " vec4 gl_Position;\n" |
| 7671 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7672 | "void main(){\n" |
| 7673 | " gl_Position = x[0] + x[1];\n" |
| 7674 | "}\n"; |
| 7675 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7676 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7677 | "\n" |
| 7678 | "layout(location=0) out vec4 color;\n" |
| 7679 | "void main(){\n" |
| 7680 | " color = vec4(1);\n" |
| 7681 | "}\n"; |
| 7682 | |
| 7683 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7684 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7685 | |
| 7686 | VkPipelineObj pipe(m_device); |
| 7687 | pipe.AddColorAttachment(); |
| 7688 | pipe.AddShader(&vs); |
| 7689 | pipe.AddShader(&fs); |
| 7690 | |
| 7691 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7692 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7693 | |
| 7694 | VkDescriptorSetObj descriptorSet(m_device); |
| 7695 | descriptorSet.AppendDummy(); |
| 7696 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7697 | |
| 7698 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7699 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7700 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7701 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7702 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7703 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 7704 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7705 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7706 | |
| 7707 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7708 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7709 | |
| 7710 | char const *vsSource = |
| 7711 | "#version 450\n" |
| 7712 | "out gl_PerVertex {\n" |
| 7713 | " vec4 gl_Position;\n" |
| 7714 | "};\n" |
| 7715 | "void main(){\n" |
| 7716 | " gl_Position = vec4(0);\n" |
| 7717 | "}\n"; |
| 7718 | char const *fsSource = |
| 7719 | "#version 450\n" |
| 7720 | "\n" |
| 7721 | "layout(location=0) out vec4 color;\n" |
| 7722 | "void main(){\n" |
| 7723 | " color = vec4(1);\n" |
| 7724 | "}\n"; |
| 7725 | |
| 7726 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7727 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7728 | |
| 7729 | VkPipelineObj pipe(m_device); |
| 7730 | pipe.AddColorAttachment(); |
| 7731 | pipe.AddShader(&vs); |
| 7732 | pipe.AddShader(&fs); |
| 7733 | |
| 7734 | VkDescriptorSetObj descriptorSet(m_device); |
| 7735 | descriptorSet.AppendDummy(); |
| 7736 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7737 | |
| 7738 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7739 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7740 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7741 | } |
| 7742 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7743 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 7744 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7745 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7746 | |
| 7747 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 7748 | |
| 7749 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7750 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7751 | |
| 7752 | char const *vsSource = |
| 7753 | "#version 450\n" |
| 7754 | "out gl_PerVertex {\n" |
| 7755 | " vec4 gl_Position;\n" |
| 7756 | "};\n" |
| 7757 | "layout(location=0) out vec3 x;\n" |
| 7758 | "layout(location=1) out ivec3 y;\n" |
| 7759 | "layout(location=2) out vec3 z;\n" |
| 7760 | "void main(){\n" |
| 7761 | " gl_Position = vec4(0);\n" |
| 7762 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 7763 | "}\n"; |
| 7764 | char const *fsSource = |
| 7765 | "#version 450\n" |
| 7766 | "\n" |
| 7767 | "layout(location=0) out vec4 color;\n" |
| 7768 | "layout(location=0) in float x;\n" |
| 7769 | "layout(location=1) flat in int y;\n" |
| 7770 | "layout(location=2) in vec2 z;\n" |
| 7771 | "void main(){\n" |
| 7772 | " color = vec4(1 + x + y + z.x);\n" |
| 7773 | "}\n"; |
| 7774 | |
| 7775 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7776 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7777 | |
| 7778 | VkPipelineObj pipe(m_device); |
| 7779 | pipe.AddColorAttachment(); |
| 7780 | pipe.AddShader(&vs); |
| 7781 | pipe.AddShader(&fs); |
| 7782 | |
| 7783 | VkDescriptorSetObj descriptorSet(m_device); |
| 7784 | descriptorSet.AppendDummy(); |
| 7785 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7786 | |
| 7787 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7788 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7789 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7790 | } |
| 7791 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7792 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 7793 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7794 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7795 | |
| 7796 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7797 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7798 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7799 | if (!m_device->phy().features().tessellationShader) { |
| 7800 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7801 | return; |
| 7802 | } |
| 7803 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7804 | char const *vsSource = |
| 7805 | "#version 450\n" |
| 7806 | "void main(){}\n"; |
| 7807 | char const *tcsSource = |
| 7808 | "#version 450\n" |
| 7809 | "layout(location=0) out int x[];\n" |
| 7810 | "layout(vertices=3) out;\n" |
| 7811 | "void main(){\n" |
| 7812 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7813 | " gl_TessLevelInner[0] = 1;\n" |
| 7814 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7815 | "}\n"; |
| 7816 | char const *tesSource = |
| 7817 | "#version 450\n" |
| 7818 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7819 | "layout(location=0) in int x[];\n" |
| 7820 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7821 | "void main(){\n" |
| 7822 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7823 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 7824 | "}\n"; |
| 7825 | char const *fsSource = |
| 7826 | "#version 450\n" |
| 7827 | "layout(location=0) out vec4 color;\n" |
| 7828 | "void main(){\n" |
| 7829 | " color = vec4(1);\n" |
| 7830 | "}\n"; |
| 7831 | |
| 7832 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7833 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7834 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7835 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7836 | |
| 7837 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7838 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7839 | nullptr, |
| 7840 | 0, |
| 7841 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7842 | VK_FALSE}; |
| 7843 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7844 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7845 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7846 | nullptr, |
| 7847 | 0, |
| 7848 | 3}; |
| 7849 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7850 | VkPipelineObj pipe(m_device); |
| 7851 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7852 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7853 | pipe.AddColorAttachment(); |
| 7854 | pipe.AddShader(&vs); |
| 7855 | pipe.AddShader(&tcs); |
| 7856 | pipe.AddShader(&tes); |
| 7857 | pipe.AddShader(&fs); |
| 7858 | |
| 7859 | VkDescriptorSetObj descriptorSet(m_device); |
| 7860 | descriptorSet.AppendDummy(); |
| 7861 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7862 | |
| 7863 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7864 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7865 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7866 | } |
| 7867 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 7868 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 7869 | { |
| 7870 | m_errorMonitor->ExpectSuccess(); |
| 7871 | |
| 7872 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7873 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7874 | |
| 7875 | if (!m_device->phy().features().geometryShader) { |
| 7876 | printf("Device does not support geometry shaders; skipped.\n"); |
| 7877 | return; |
| 7878 | } |
| 7879 | |
| 7880 | char const *vsSource = |
| 7881 | "#version 450\n" |
| 7882 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 7883 | "void main(){\n" |
| 7884 | " vs_out.x = vec4(1);\n" |
| 7885 | "}\n"; |
| 7886 | char const *gsSource = |
| 7887 | "#version 450\n" |
| 7888 | "layout(triangles) in;\n" |
| 7889 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 7890 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 7891 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7892 | "void main() {\n" |
| 7893 | " gl_Position = gs_in[0].x;\n" |
| 7894 | " EmitVertex();\n" |
| 7895 | "}\n"; |
| 7896 | char const *fsSource = |
| 7897 | "#version 450\n" |
| 7898 | "layout(location=0) out vec4 color;\n" |
| 7899 | "void main(){\n" |
| 7900 | " color = vec4(1);\n" |
| 7901 | "}\n"; |
| 7902 | |
| 7903 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7904 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 7905 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7906 | |
| 7907 | VkPipelineObj pipe(m_device); |
| 7908 | pipe.AddColorAttachment(); |
| 7909 | pipe.AddShader(&vs); |
| 7910 | pipe.AddShader(&gs); |
| 7911 | pipe.AddShader(&fs); |
| 7912 | |
| 7913 | VkDescriptorSetObj descriptorSet(m_device); |
| 7914 | descriptorSet.AppendDummy(); |
| 7915 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7916 | |
| 7917 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7918 | |
| 7919 | m_errorMonitor->VerifyNotFound(); |
| 7920 | } |
| 7921 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7922 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 7923 | { |
| 7924 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7925 | "is per-vertex in tessellation control shader stage " |
| 7926 | "but per-patch in tessellation evaluation shader stage"); |
| 7927 | |
| 7928 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7929 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7930 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7931 | if (!m_device->phy().features().tessellationShader) { |
| 7932 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7933 | return; |
| 7934 | } |
| 7935 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7936 | char const *vsSource = |
| 7937 | "#version 450\n" |
| 7938 | "void main(){}\n"; |
| 7939 | char const *tcsSource = |
| 7940 | "#version 450\n" |
| 7941 | "layout(location=0) out int x[];\n" |
| 7942 | "layout(vertices=3) out;\n" |
| 7943 | "void main(){\n" |
| 7944 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7945 | " gl_TessLevelInner[0] = 1;\n" |
| 7946 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7947 | "}\n"; |
| 7948 | char const *tesSource = |
| 7949 | "#version 450\n" |
| 7950 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7951 | "layout(location=0) patch in int x;\n" |
| 7952 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7953 | "void main(){\n" |
| 7954 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7955 | " gl_Position.w = x;\n" |
| 7956 | "}\n"; |
| 7957 | char const *fsSource = |
| 7958 | "#version 450\n" |
| 7959 | "layout(location=0) out vec4 color;\n" |
| 7960 | "void main(){\n" |
| 7961 | " color = vec4(1);\n" |
| 7962 | "}\n"; |
| 7963 | |
| 7964 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7965 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7966 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7967 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7968 | |
| 7969 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7970 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7971 | nullptr, |
| 7972 | 0, |
| 7973 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7974 | VK_FALSE}; |
| 7975 | |
| 7976 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7977 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7978 | nullptr, |
| 7979 | 0, |
| 7980 | 3}; |
| 7981 | |
| 7982 | VkPipelineObj pipe(m_device); |
| 7983 | pipe.SetInputAssembly(&iasci); |
| 7984 | pipe.SetTessellation(&tsci); |
| 7985 | pipe.AddColorAttachment(); |
| 7986 | pipe.AddShader(&vs); |
| 7987 | pipe.AddShader(&tcs); |
| 7988 | pipe.AddShader(&tes); |
| 7989 | pipe.AddShader(&fs); |
| 7990 | |
| 7991 | VkDescriptorSetObj descriptorSet(m_device); |
| 7992 | descriptorSet.AppendDummy(); |
| 7993 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7994 | |
| 7995 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7996 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7997 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7998 | } |
| 7999 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8000 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 8001 | m_errorMonitor->SetDesiredFailureMsg( |
| 8002 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8003 | "Duplicate vertex input binding descriptions for binding 0"); |
| 8004 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8005 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8006 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8007 | |
| 8008 | /* Two binding descriptions for binding 0 */ |
| 8009 | VkVertexInputBindingDescription input_bindings[2]; |
| 8010 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 8011 | |
| 8012 | VkVertexInputAttributeDescription input_attrib; |
| 8013 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8014 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8015 | |
| 8016 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8017 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8018 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8019 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8020 | "out gl_PerVertex {\n" |
| 8021 | " vec4 gl_Position;\n" |
| 8022 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8023 | "void main(){\n" |
| 8024 | " gl_Position = vec4(x);\n" |
| 8025 | "}\n"; |
| 8026 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8027 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8028 | "\n" |
| 8029 | "layout(location=0) out vec4 color;\n" |
| 8030 | "void main(){\n" |
| 8031 | " color = vec4(1);\n" |
| 8032 | "}\n"; |
| 8033 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8034 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8035 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8036 | |
| 8037 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8038 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8039 | pipe.AddShader(&vs); |
| 8040 | pipe.AddShader(&fs); |
| 8041 | |
| 8042 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 8043 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8044 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8045 | VkDescriptorSetObj descriptorSet(m_device); |
| 8046 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8047 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8048 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8049 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8050 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8051 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8052 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 8053 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 8054 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 8055 | m_errorMonitor->ExpectSuccess(); |
| 8056 | |
| 8057 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8058 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8059 | |
| 8060 | if (!m_device->phy().features().tessellationShader) { |
| 8061 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 8062 | return; |
| 8063 | } |
| 8064 | |
| 8065 | VkVertexInputBindingDescription input_bindings[1]; |
| 8066 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 8067 | |
| 8068 | VkVertexInputAttributeDescription input_attribs[4]; |
| 8069 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 8070 | input_attribs[0].location = 0; |
| 8071 | input_attribs[0].offset = 0; |
| 8072 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8073 | input_attribs[1].location = 2; |
| 8074 | input_attribs[1].offset = 32; |
| 8075 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8076 | input_attribs[2].location = 4; |
| 8077 | input_attribs[2].offset = 64; |
| 8078 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8079 | input_attribs[3].location = 6; |
| 8080 | input_attribs[3].offset = 96; |
| 8081 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8082 | |
| 8083 | char const *vsSource = |
| 8084 | "#version 450\n" |
| 8085 | "\n" |
| 8086 | "layout(location=0) in dmat4 x;\n" |
| 8087 | "out gl_PerVertex {\n" |
| 8088 | " vec4 gl_Position;\n" |
| 8089 | "};\n" |
| 8090 | "void main(){\n" |
| 8091 | " gl_Position = vec4(x[0][0]);\n" |
| 8092 | "}\n"; |
| 8093 | char const *fsSource = |
| 8094 | "#version 450\n" |
| 8095 | "\n" |
| 8096 | "layout(location=0) out vec4 color;\n" |
| 8097 | "void main(){\n" |
| 8098 | " color = vec4(1);\n" |
| 8099 | "}\n"; |
| 8100 | |
| 8101 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8102 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8103 | |
| 8104 | VkPipelineObj pipe(m_device); |
| 8105 | pipe.AddColorAttachment(); |
| 8106 | pipe.AddShader(&vs); |
| 8107 | pipe.AddShader(&fs); |
| 8108 | |
| 8109 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 8110 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 8111 | |
| 8112 | VkDescriptorSetObj descriptorSet(m_device); |
| 8113 | descriptorSet.AppendDummy(); |
| 8114 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8115 | |
| 8116 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8117 | |
| 8118 | m_errorMonitor->VerifyNotFound(); |
| 8119 | } |
| 8120 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8121 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8122 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8123 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8124 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8125 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8126 | |
| 8127 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8128 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8129 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8130 | "out gl_PerVertex {\n" |
| 8131 | " vec4 gl_Position;\n" |
| 8132 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8133 | "void main(){\n" |
| 8134 | " gl_Position = vec4(1);\n" |
| 8135 | "}\n"; |
| 8136 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8137 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8138 | "\n" |
| 8139 | "void main(){\n" |
| 8140 | "}\n"; |
| 8141 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8142 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8143 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8144 | |
| 8145 | VkPipelineObj pipe(m_device); |
| 8146 | pipe.AddShader(&vs); |
| 8147 | pipe.AddShader(&fs); |
| 8148 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8149 | /* set up CB 0, not written */ |
| 8150 | pipe.AddColorAttachment(); |
| 8151 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8152 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8153 | VkDescriptorSetObj descriptorSet(m_device); |
| 8154 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8155 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8156 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8157 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8158 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8159 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8160 | } |
| 8161 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8162 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8163 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8164 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8165 | "FS writes to output location 1 with no matching attachment"); |
| 8166 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8167 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8168 | |
| 8169 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8170 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8171 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8172 | "out gl_PerVertex {\n" |
| 8173 | " vec4 gl_Position;\n" |
| 8174 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8175 | "void main(){\n" |
| 8176 | " gl_Position = vec4(1);\n" |
| 8177 | "}\n"; |
| 8178 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8179 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8180 | "\n" |
| 8181 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8182 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8183 | "void main(){\n" |
| 8184 | " x = vec4(1);\n" |
| 8185 | " y = vec4(1);\n" |
| 8186 | "}\n"; |
| 8187 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8188 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8189 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8190 | |
| 8191 | VkPipelineObj pipe(m_device); |
| 8192 | pipe.AddShader(&vs); |
| 8193 | pipe.AddShader(&fs); |
| 8194 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8195 | /* set up CB 0, not written */ |
| 8196 | pipe.AddColorAttachment(); |
| 8197 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8198 | /* FS writes CB 1, but we don't configure it */ |
| 8199 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8200 | VkDescriptorSetObj descriptorSet(m_device); |
| 8201 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8202 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8203 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8204 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8205 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8206 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8207 | } |
| 8208 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8209 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8210 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8211 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8212 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8213 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8214 | |
| 8215 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8216 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8217 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8218 | "out gl_PerVertex {\n" |
| 8219 | " vec4 gl_Position;\n" |
| 8220 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8221 | "void main(){\n" |
| 8222 | " gl_Position = vec4(1);\n" |
| 8223 | "}\n"; |
| 8224 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8225 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8226 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8227 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8228 | "void main(){\n" |
| 8229 | " x = ivec4(1);\n" |
| 8230 | "}\n"; |
| 8231 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8232 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8233 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8234 | |
| 8235 | VkPipelineObj pipe(m_device); |
| 8236 | pipe.AddShader(&vs); |
| 8237 | pipe.AddShader(&fs); |
| 8238 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8239 | /* set up CB 0; type is UNORM by default */ |
| 8240 | pipe.AddColorAttachment(); |
| 8241 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8242 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8243 | VkDescriptorSetObj descriptorSet(m_device); |
| 8244 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8245 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8246 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8247 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8248 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8249 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8250 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 8251 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8252 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8253 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8254 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8255 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8256 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8257 | |
| 8258 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8259 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8260 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8261 | "out gl_PerVertex {\n" |
| 8262 | " vec4 gl_Position;\n" |
| 8263 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8264 | "void main(){\n" |
| 8265 | " gl_Position = vec4(1);\n" |
| 8266 | "}\n"; |
| 8267 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8268 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8269 | "\n" |
| 8270 | "layout(location=0) out vec4 x;\n" |
| 8271 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 8272 | "void main(){\n" |
| 8273 | " x = vec4(bar.y);\n" |
| 8274 | "}\n"; |
| 8275 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8276 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8277 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8278 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8279 | VkPipelineObj pipe(m_device); |
| 8280 | pipe.AddShader(&vs); |
| 8281 | pipe.AddShader(&fs); |
| 8282 | |
| 8283 | /* set up CB 0; type is UNORM by default */ |
| 8284 | pipe.AddColorAttachment(); |
| 8285 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8286 | |
| 8287 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8288 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8289 | |
| 8290 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8291 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8292 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8293 | } |
| 8294 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8295 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 8296 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8297 | "not declared in layout"); |
| 8298 | |
| 8299 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8300 | |
| 8301 | char const *vsSource = |
| 8302 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8303 | "\n" |
| 8304 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 8305 | "out gl_PerVertex {\n" |
| 8306 | " vec4 gl_Position;\n" |
| 8307 | "};\n" |
| 8308 | "void main(){\n" |
| 8309 | " gl_Position = vec4(consts.x);\n" |
| 8310 | "}\n"; |
| 8311 | char const *fsSource = |
| 8312 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8313 | "\n" |
| 8314 | "layout(location=0) out vec4 x;\n" |
| 8315 | "void main(){\n" |
| 8316 | " x = vec4(1);\n" |
| 8317 | "}\n"; |
| 8318 | |
| 8319 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8320 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8321 | |
| 8322 | VkPipelineObj pipe(m_device); |
| 8323 | pipe.AddShader(&vs); |
| 8324 | pipe.AddShader(&fs); |
| 8325 | |
| 8326 | /* set up CB 0; type is UNORM by default */ |
| 8327 | pipe.AddColorAttachment(); |
| 8328 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8329 | |
| 8330 | VkDescriptorSetObj descriptorSet(m_device); |
| 8331 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8332 | |
| 8333 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8334 | |
| 8335 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8336 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8337 | } |
| 8338 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8339 | #endif // SHADER_CHECKER_TESTS |
| 8340 | |
| 8341 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 8342 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8343 | m_errorMonitor->SetDesiredFailureMsg( |
| 8344 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8345 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8346 | |
| 8347 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8348 | |
| 8349 | // Create an image |
| 8350 | VkImage image; |
| 8351 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8352 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8353 | const int32_t tex_width = 32; |
| 8354 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8355 | |
| 8356 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8357 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8358 | image_create_info.pNext = NULL; |
| 8359 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8360 | image_create_info.format = tex_format; |
| 8361 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8362 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8363 | image_create_info.extent.depth = 1; |
| 8364 | image_create_info.mipLevels = 1; |
| 8365 | image_create_info.arrayLayers = 1; |
| 8366 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8367 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8368 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8369 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8370 | |
| 8371 | // Introduce error by sending down a bogus width extent |
| 8372 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8373 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8374 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8375 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8376 | } |
| 8377 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 8378 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 8379 | m_errorMonitor->SetDesiredFailureMsg( |
| 8380 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8381 | "CreateImage extents is 0 for at least one required dimension"); |
| 8382 | |
| 8383 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8384 | |
| 8385 | // Create an image |
| 8386 | VkImage image; |
| 8387 | |
| 8388 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8389 | const int32_t tex_width = 32; |
| 8390 | const int32_t tex_height = 32; |
| 8391 | |
| 8392 | VkImageCreateInfo image_create_info = {}; |
| 8393 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8394 | image_create_info.pNext = NULL; |
| 8395 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8396 | image_create_info.format = tex_format; |
| 8397 | image_create_info.extent.width = tex_width; |
| 8398 | image_create_info.extent.height = tex_height; |
| 8399 | image_create_info.extent.depth = 1; |
| 8400 | image_create_info.mipLevels = 1; |
| 8401 | image_create_info.arrayLayers = 1; |
| 8402 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8403 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8404 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8405 | image_create_info.flags = 0; |
| 8406 | |
| 8407 | // Introduce error by sending down a bogus width extent |
| 8408 | image_create_info.extent.width = 0; |
| 8409 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 8410 | |
| 8411 | m_errorMonitor->VerifyFound(); |
| 8412 | } |
| 8413 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8414 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 8415 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8416 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8417 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8418 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8419 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8420 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8421 | |
| 8422 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8423 | vk_testing::Buffer buffer; |
| 8424 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 8425 | |
| 8426 | BeginCommandBuffer(); |
| 8427 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8428 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8429 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8430 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8431 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8432 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8433 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8434 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8435 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8436 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8437 | EndCommandBuffer(); |
| 8438 | } |
| 8439 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8440 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8441 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8442 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8443 | |
| 8444 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8445 | |
| 8446 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8447 | vk_testing::Buffer buffer; |
| 8448 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 8449 | |
| 8450 | BeginCommandBuffer(); |
| 8451 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8452 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8453 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8454 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8455 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8456 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8457 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8458 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8459 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8460 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8461 | m_errorMonitor->VerifyFound(); |
| 8462 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8463 | EndCommandBuffer(); |
| 8464 | } |
| 8465 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8466 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8467 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8468 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8469 | TEST_F(VkLayerTest, InvalidImageView) { |
| 8470 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8472 | m_errorMonitor->SetDesiredFailureMsg( |
| 8473 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8474 | "vkCreateImageView called with baseMipLevel 10 "); |
| 8475 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8476 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8477 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8478 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8479 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8480 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8481 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8482 | const int32_t tex_width = 32; |
| 8483 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8484 | |
| 8485 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8486 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8487 | image_create_info.pNext = NULL; |
| 8488 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8489 | image_create_info.format = tex_format; |
| 8490 | image_create_info.extent.width = tex_width; |
| 8491 | image_create_info.extent.height = tex_height; |
| 8492 | image_create_info.extent.depth = 1; |
| 8493 | image_create_info.mipLevels = 1; |
| 8494 | image_create_info.arrayLayers = 1; |
| 8495 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8496 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8497 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8498 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8499 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8500 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8501 | ASSERT_VK_SUCCESS(err); |
| 8502 | |
| 8503 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8504 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8505 | image_view_create_info.image = image; |
| 8506 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8507 | image_view_create_info.format = tex_format; |
| 8508 | image_view_create_info.subresourceRange.layerCount = 1; |
| 8509 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 8510 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8511 | image_view_create_info.subresourceRange.aspectMask = |
| 8512 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8513 | |
| 8514 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8515 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8516 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8517 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8518 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8519 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8520 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8521 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 8522 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8523 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8524 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8525 | "vkCreateImageView: Color image " |
| 8526 | "formats must have ONLY the " |
| 8527 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8528 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8529 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8530 | |
| 8531 | // Create an image and try to create a view with an invalid aspectMask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8532 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8533 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8534 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8535 | const int32_t tex_width = 32; |
| 8536 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8537 | |
| 8538 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8539 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8540 | image_create_info.pNext = NULL; |
| 8541 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8542 | image_create_info.format = tex_format; |
| 8543 | image_create_info.extent.width = tex_width; |
| 8544 | image_create_info.extent.height = tex_height; |
| 8545 | image_create_info.extent.depth = 1; |
| 8546 | image_create_info.mipLevels = 1; |
| 8547 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8548 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8549 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8550 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8551 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8552 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8553 | ASSERT_VK_SUCCESS(err); |
| 8554 | |
| 8555 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8556 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8557 | image_view_create_info.image = image; |
| 8558 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8559 | image_view_create_info.format = tex_format; |
| 8560 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 8561 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8562 | // Cause an error by setting an invalid image aspect |
| 8563 | image_view_create_info.subresourceRange.aspectMask = |
| 8564 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8565 | |
| 8566 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8567 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8568 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8569 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8570 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8571 | } |
| 8572 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8573 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8574 | VkResult err; |
| 8575 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8576 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8577 | m_errorMonitor->SetDesiredFailureMsg( |
| 8578 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8579 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8580 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8581 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8582 | |
| 8583 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8584 | VkImage srcImage; |
| 8585 | VkImage dstImage; |
| 8586 | VkDeviceMemory srcMem; |
| 8587 | VkDeviceMemory destMem; |
| 8588 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8589 | |
| 8590 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8591 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8592 | image_create_info.pNext = NULL; |
| 8593 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8594 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8595 | image_create_info.extent.width = 32; |
| 8596 | image_create_info.extent.height = 32; |
| 8597 | image_create_info.extent.depth = 1; |
| 8598 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8599 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8600 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8601 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8602 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8603 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8604 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8605 | err = |
| 8606 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8607 | ASSERT_VK_SUCCESS(err); |
| 8608 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8609 | err = |
| 8610 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8611 | ASSERT_VK_SUCCESS(err); |
| 8612 | |
| 8613 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8614 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8615 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8616 | memAlloc.pNext = NULL; |
| 8617 | memAlloc.allocationSize = 0; |
| 8618 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8619 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8620 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8621 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8622 | pass = |
| 8623 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8624 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8625 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8626 | ASSERT_VK_SUCCESS(err); |
| 8627 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8628 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8629 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8630 | pass = |
| 8631 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8632 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8633 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8634 | ASSERT_VK_SUCCESS(err); |
| 8635 | |
| 8636 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8637 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8638 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8639 | ASSERT_VK_SUCCESS(err); |
| 8640 | |
| 8641 | BeginCommandBuffer(); |
| 8642 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8643 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8644 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8645 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8646 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8647 | copyRegion.srcOffset.x = 0; |
| 8648 | copyRegion.srcOffset.y = 0; |
| 8649 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8650 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8651 | copyRegion.dstSubresource.mipLevel = 0; |
| 8652 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8653 | // Introduce failure by forcing the dst layerCount to differ from src |
| 8654 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8655 | copyRegion.dstOffset.x = 0; |
| 8656 | copyRegion.dstOffset.y = 0; |
| 8657 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8658 | copyRegion.extent.width = 1; |
| 8659 | copyRegion.extent.height = 1; |
| 8660 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8661 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8662 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8663 | EndCommandBuffer(); |
| 8664 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8665 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8666 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8667 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8668 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8669 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8670 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8671 | } |
| 8672 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 8673 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 8674 | |
| 8675 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 8676 | |
| 8677 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8678 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8679 | VkImageObj image(m_device); |
| 8680 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8681 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 8682 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 8683 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 8684 | ASSERT_TRUE(image.initialized()); |
| 8685 | |
| 8686 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 8687 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 8688 | VkFormat format = static_cast<VkFormat>(f); |
| 8689 | VkFormatProperties fProps = m_device->format_properties(format); |
| 8690 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 8691 | fProps.optimalTilingFeatures == 0) { |
| 8692 | unsupported = format; |
| 8693 | break; |
| 8694 | } |
| 8695 | } |
| 8696 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 8697 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8698 | "vkCreateImage parameter, " |
| 8699 | "VkFormat pCreateInfo->format, " |
| 8700 | "contains unsupported format"); |
| 8701 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 8702 | VkImageCreateInfo image_create_info; |
| 8703 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8704 | image_create_info.pNext = NULL; |
| 8705 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8706 | image_create_info.format = unsupported; |
| 8707 | image_create_info.extent.width = 32; |
| 8708 | image_create_info.extent.height = 32; |
| 8709 | image_create_info.extent.depth = 1; |
| 8710 | image_create_info.mipLevels = 1; |
| 8711 | image_create_info.arrayLayers = 1; |
| 8712 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8713 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8714 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8715 | image_create_info.flags = 0; |
| 8716 | |
| 8717 | VkImage localImage; |
| 8718 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 8719 | m_errorMonitor->VerifyFound(); |
| 8720 | |
| 8721 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8722 | "vkCreateRenderPass parameter, " |
| 8723 | "VkFormat in " |
| 8724 | "pCreateInfo->pAttachments"); |
| 8725 | // Create renderpass with unsupported format - Expect FORMAT_UNSUPPORTED |
| 8726 | VkAttachmentDescription att; |
| 8727 | att.format = unsupported; |
| 8728 | att.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8729 | att.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; |
| 8730 | att.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 8731 | att.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 8732 | att.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 8733 | att.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8734 | att.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8735 | |
| 8736 | VkRenderPassCreateInfo rp_info = {}; |
| 8737 | VkRenderPass rp; |
| 8738 | rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 8739 | rp_info.attachmentCount = 1; |
| 8740 | rp_info.pAttachments = &att; |
| 8741 | rp_info.subpassCount = 0; |
| 8742 | rp_info.pSubpasses = NULL; |
| 8743 | vkCreateRenderPass(m_device->handle(), &rp_info, NULL, &rp); |
| 8744 | m_errorMonitor->VerifyFound(); |
| 8745 | } |
| 8746 | } |
| 8747 | |
| 8748 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 8749 | VkResult ret; |
| 8750 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 8751 | |
| 8752 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8753 | |
| 8754 | VkImageObj image(m_device); |
| 8755 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8756 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 8757 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 8758 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 8759 | ASSERT_TRUE(image.initialized()); |
| 8760 | |
| 8761 | VkImageView imgView; |
| 8762 | VkImageViewCreateInfo imgViewInfo = {}; |
| 8763 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 8764 | imgViewInfo.image = image.handle(); |
| 8765 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8766 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8767 | imgViewInfo.subresourceRange.layerCount = 1; |
| 8768 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 8769 | imgViewInfo.subresourceRange.levelCount = 1; |
| 8770 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8771 | |
| 8772 | m_errorMonitor->SetDesiredFailureMsg( |
| 8773 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8774 | "vkCreateImageView called with baseMipLevel"); |
| 8775 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 8776 | // VIEW_CREATE_ERROR |
| 8777 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 8778 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8779 | m_errorMonitor->VerifyFound(); |
| 8780 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 8781 | |
| 8782 | m_errorMonitor->SetDesiredFailureMsg( |
| 8783 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8784 | "vkCreateImageView called with baseArrayLayer"); |
| 8785 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 8786 | // VIEW_CREATE_ERROR |
| 8787 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 8788 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8789 | m_errorMonitor->VerifyFound(); |
| 8790 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 8791 | |
| 8792 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8793 | "vkCreateImageView called with 0 in " |
| 8794 | "pCreateInfo->subresourceRange." |
| 8795 | "levelCount"); |
| 8796 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 8797 | imgViewInfo.subresourceRange.levelCount = 0; |
| 8798 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8799 | m_errorMonitor->VerifyFound(); |
| 8800 | imgViewInfo.subresourceRange.levelCount = 1; |
| 8801 | |
| 8802 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8803 | "vkCreateImageView called with 0 in " |
| 8804 | "pCreateInfo->subresourceRange." |
| 8805 | "layerCount"); |
| 8806 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 8807 | imgViewInfo.subresourceRange.layerCount = 0; |
| 8808 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8809 | m_errorMonitor->VerifyFound(); |
| 8810 | imgViewInfo.subresourceRange.layerCount = 1; |
| 8811 | |
| 8812 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8813 | "but both must be color formats"); |
| 8814 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 8815 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8816 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8817 | m_errorMonitor->VerifyFound(); |
| 8818 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8819 | |
| 8820 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8821 | "Formats MUST be IDENTICAL unless " |
| 8822 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 8823 | "was set on image creation."); |
| 8824 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 8825 | // VIEW_CREATE_ERROR |
| 8826 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 8827 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8828 | m_errorMonitor->VerifyFound(); |
| 8829 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8830 | |
| 8831 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8832 | "can support ImageViews with " |
| 8833 | "differing formats but they must be " |
| 8834 | "in the same compatibility class."); |
| 8835 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 8836 | // VIEW_CREATE_ERROR |
| 8837 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 8838 | VkImage mutImage; |
| 8839 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 8840 | assert( |
| 8841 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 8842 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 8843 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 8844 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8845 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 8846 | ASSERT_VK_SUCCESS(ret); |
| 8847 | imgViewInfo.image = mutImage; |
| 8848 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8849 | m_errorMonitor->VerifyFound(); |
| 8850 | imgViewInfo.image = image.handle(); |
| 8851 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 8852 | } |
| 8853 | |
| 8854 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 8855 | |
| 8856 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 8857 | |
| 8858 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8859 | |
| 8860 | VkImageObj image(m_device); |
| 8861 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8862 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 8863 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 8864 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 8865 | ASSERT_TRUE(image.initialized()); |
| 8866 | |
| 8867 | m_errorMonitor->SetDesiredFailureMsg( |
| 8868 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8869 | "number of layers in image subresource is zero"); |
| 8870 | vk_testing::Buffer buffer; |
| 8871 | VkMemoryPropertyFlags reqs = 0; |
| 8872 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 8873 | VkBufferImageCopy region = {}; |
| 8874 | region.bufferRowLength = 128; |
| 8875 | region.bufferImageHeight = 128; |
| 8876 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8877 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 8878 | region.imageSubresource.layerCount = 0; |
| 8879 | region.imageExtent.height = 4; |
| 8880 | region.imageExtent.width = 4; |
| 8881 | region.imageExtent.depth = 1; |
| 8882 | m_commandBuffer->BeginCommandBuffer(); |
| 8883 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 8884 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 8885 | 1, ®ion); |
| 8886 | m_errorMonitor->VerifyFound(); |
| 8887 | region.imageSubresource.layerCount = 1; |
| 8888 | |
| 8889 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8890 | "aspectMasks for each region must " |
| 8891 | "specify only COLOR or DEPTH or " |
| 8892 | "STENCIL"); |
| 8893 | // Expect MISMATCHED_IMAGE_ASPECT |
| 8894 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 8895 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 8896 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 8897 | 1, ®ion); |
| 8898 | m_errorMonitor->VerifyFound(); |
| 8899 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8900 | |
| 8901 | m_errorMonitor->SetDesiredFailureMsg( |
| 8902 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8903 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 8904 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 8905 | // Expect INVALID_FILTER |
| 8906 | VkImageObj intImage1(m_device); |
| 8907 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 8908 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 8909 | 0); |
| 8910 | VkImageObj intImage2(m_device); |
| 8911 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 8912 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 8913 | 0); |
| 8914 | VkImageBlit blitRegion = {}; |
| 8915 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8916 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 8917 | blitRegion.srcSubresource.layerCount = 1; |
| 8918 | blitRegion.srcSubresource.mipLevel = 0; |
| 8919 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8920 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 8921 | blitRegion.dstSubresource.layerCount = 1; |
| 8922 | blitRegion.dstSubresource.mipLevel = 0; |
| 8923 | |
| 8924 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 8925 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 8926 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 8927 | m_errorMonitor->VerifyFound(); |
| 8928 | |
| 8929 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8930 | "called with 0 in ppMemoryBarriers"); |
| 8931 | VkImageMemoryBarrier img_barrier; |
| 8932 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 8933 | img_barrier.pNext = NULL; |
| 8934 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 8935 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 8936 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8937 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8938 | img_barrier.image = image.handle(); |
| 8939 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8940 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8941 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8942 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 8943 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 8944 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 8945 | img_barrier.subresourceRange.layerCount = 0; |
| 8946 | img_barrier.subresourceRange.levelCount = 1; |
| 8947 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8948 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8949 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 8950 | nullptr, 1, &img_barrier); |
| 8951 | m_errorMonitor->VerifyFound(); |
| 8952 | img_barrier.subresourceRange.layerCount = 1; |
| 8953 | } |
| 8954 | |
| 8955 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 8956 | |
| 8957 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 8958 | |
| 8959 | m_errorMonitor->SetDesiredFailureMsg( |
| 8960 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8961 | "CreateImage extents exceed allowable limits for format"); |
| 8962 | VkImageCreateInfo image_create_info = {}; |
| 8963 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8964 | image_create_info.pNext = NULL; |
| 8965 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8966 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8967 | image_create_info.extent.width = 32; |
| 8968 | image_create_info.extent.height = 32; |
| 8969 | image_create_info.extent.depth = 1; |
| 8970 | image_create_info.mipLevels = 1; |
| 8971 | image_create_info.arrayLayers = 1; |
| 8972 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8973 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8974 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8975 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 8976 | image_create_info.flags = 0; |
| 8977 | |
| 8978 | VkImage nullImg; |
| 8979 | VkImageFormatProperties imgFmtProps; |
| 8980 | vkGetPhysicalDeviceImageFormatProperties( |
| 8981 | gpu(), image_create_info.format, image_create_info.imageType, |
| 8982 | image_create_info.tiling, image_create_info.usage, |
| 8983 | image_create_info.flags, &imgFmtProps); |
| 8984 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 8985 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 8986 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 8987 | m_errorMonitor->VerifyFound(); |
| 8988 | image_create_info.extent.depth = 1; |
| 8989 | |
| 8990 | m_errorMonitor->SetDesiredFailureMsg( |
| 8991 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8992 | "exceeds allowable maximum supported by format of"); |
| 8993 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 8994 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 8995 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 8996 | m_errorMonitor->VerifyFound(); |
| 8997 | image_create_info.mipLevels = 1; |
| 8998 | |
| 8999 | m_errorMonitor->SetDesiredFailureMsg( |
| 9000 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9001 | "exceeds allowable maximum supported by format of"); |
| 9002 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 9003 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 9004 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9005 | m_errorMonitor->VerifyFound(); |
| 9006 | image_create_info.arrayLayers = 1; |
| 9007 | |
| 9008 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9009 | "is not supported by format"); |
| 9010 | int samples = imgFmtProps.sampleCounts >> 1; |
| 9011 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 9012 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 9013 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9014 | m_errorMonitor->VerifyFound(); |
| 9015 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9016 | |
| 9017 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9018 | "pCreateInfo->initialLayout, must be " |
| 9019 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 9020 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 9021 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9022 | // Expect INVALID_LAYOUT |
| 9023 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9024 | m_errorMonitor->VerifyFound(); |
| 9025 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 9026 | } |
| 9027 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9028 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9029 | VkResult err; |
| 9030 | bool pass; |
| 9031 | |
| 9032 | // Create color images with different format sizes and try to copy between them |
| 9033 | m_errorMonitor->SetDesiredFailureMsg( |
| 9034 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9035 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 9036 | |
| 9037 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9038 | |
| 9039 | // Create two images of different types and try to copy between them |
| 9040 | VkImage srcImage; |
| 9041 | VkImage dstImage; |
| 9042 | VkDeviceMemory srcMem; |
| 9043 | VkDeviceMemory destMem; |
| 9044 | VkMemoryRequirements memReqs; |
| 9045 | |
| 9046 | VkImageCreateInfo image_create_info = {}; |
| 9047 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9048 | image_create_info.pNext = NULL; |
| 9049 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9050 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9051 | image_create_info.extent.width = 32; |
| 9052 | image_create_info.extent.height = 32; |
| 9053 | image_create_info.extent.depth = 1; |
| 9054 | image_create_info.mipLevels = 1; |
| 9055 | image_create_info.arrayLayers = 1; |
| 9056 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9057 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9058 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9059 | image_create_info.flags = 0; |
| 9060 | |
| 9061 | err = |
| 9062 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 9063 | ASSERT_VK_SUCCESS(err); |
| 9064 | |
| 9065 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 9066 | // Introduce failure by creating second image with a different-sized format. |
| 9067 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 9068 | |
| 9069 | err = |
| 9070 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 9071 | ASSERT_VK_SUCCESS(err); |
| 9072 | |
| 9073 | // Allocate memory |
| 9074 | VkMemoryAllocateInfo memAlloc = {}; |
| 9075 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9076 | memAlloc.pNext = NULL; |
| 9077 | memAlloc.allocationSize = 0; |
| 9078 | memAlloc.memoryTypeIndex = 0; |
| 9079 | |
| 9080 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 9081 | memAlloc.allocationSize = memReqs.size; |
| 9082 | pass = |
| 9083 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 9084 | ASSERT_TRUE(pass); |
| 9085 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 9086 | ASSERT_VK_SUCCESS(err); |
| 9087 | |
| 9088 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 9089 | memAlloc.allocationSize = memReqs.size; |
| 9090 | pass = |
| 9091 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 9092 | ASSERT_TRUE(pass); |
| 9093 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 9094 | ASSERT_VK_SUCCESS(err); |
| 9095 | |
| 9096 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9097 | ASSERT_VK_SUCCESS(err); |
| 9098 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 9099 | ASSERT_VK_SUCCESS(err); |
| 9100 | |
| 9101 | BeginCommandBuffer(); |
| 9102 | VkImageCopy copyRegion; |
| 9103 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9104 | copyRegion.srcSubresource.mipLevel = 0; |
| 9105 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 9106 | copyRegion.srcSubresource.layerCount = 0; |
| 9107 | copyRegion.srcOffset.x = 0; |
| 9108 | copyRegion.srcOffset.y = 0; |
| 9109 | copyRegion.srcOffset.z = 0; |
| 9110 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9111 | copyRegion.dstSubresource.mipLevel = 0; |
| 9112 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 9113 | copyRegion.dstSubresource.layerCount = 0; |
| 9114 | copyRegion.dstOffset.x = 0; |
| 9115 | copyRegion.dstOffset.y = 0; |
| 9116 | copyRegion.dstOffset.z = 0; |
| 9117 | copyRegion.extent.width = 1; |
| 9118 | copyRegion.extent.height = 1; |
| 9119 | copyRegion.extent.depth = 1; |
| 9120 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9121 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 9122 | EndCommandBuffer(); |
| 9123 | |
| 9124 | m_errorMonitor->VerifyFound(); |
| 9125 | |
| 9126 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 9127 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 9128 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9129 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9130 | } |
| 9131 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9132 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 9133 | VkResult err; |
| 9134 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9135 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9136 | // Create a color image and a depth/stencil image and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9137 | m_errorMonitor->SetDesiredFailureMsg( |
| 9138 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9139 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9140 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9141 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9142 | |
| 9143 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9144 | VkImage srcImage; |
| 9145 | VkImage dstImage; |
| 9146 | VkDeviceMemory srcMem; |
| 9147 | VkDeviceMemory destMem; |
| 9148 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9149 | |
| 9150 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9151 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9152 | image_create_info.pNext = NULL; |
| 9153 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9154 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9155 | image_create_info.extent.width = 32; |
| 9156 | image_create_info.extent.height = 32; |
| 9157 | image_create_info.extent.depth = 1; |
| 9158 | image_create_info.mipLevels = 1; |
| 9159 | image_create_info.arrayLayers = 1; |
| 9160 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9161 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9162 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9163 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9165 | err = |
| 9166 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9167 | ASSERT_VK_SUCCESS(err); |
| 9168 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9169 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 9170 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9171 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9172 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9173 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 9174 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9175 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9176 | err = |
| 9177 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9178 | ASSERT_VK_SUCCESS(err); |
| 9179 | |
| 9180 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9181 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9182 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9183 | memAlloc.pNext = NULL; |
| 9184 | memAlloc.allocationSize = 0; |
| 9185 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9186 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9187 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9188 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9189 | pass = |
| 9190 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9191 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9192 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9193 | ASSERT_VK_SUCCESS(err); |
| 9194 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9195 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9196 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9197 | pass = |
| 9198 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9199 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9200 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9201 | ASSERT_VK_SUCCESS(err); |
| 9202 | |
| 9203 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9204 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9205 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9206 | ASSERT_VK_SUCCESS(err); |
| 9207 | |
| 9208 | BeginCommandBuffer(); |
| 9209 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9210 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9211 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9212 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9213 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9214 | copyRegion.srcOffset.x = 0; |
| 9215 | copyRegion.srcOffset.y = 0; |
| 9216 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9217 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9218 | copyRegion.dstSubresource.mipLevel = 0; |
| 9219 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 9220 | copyRegion.dstSubresource.layerCount = 0; |
| 9221 | copyRegion.dstOffset.x = 0; |
| 9222 | copyRegion.dstOffset.y = 0; |
| 9223 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9224 | copyRegion.extent.width = 1; |
| 9225 | copyRegion.extent.height = 1; |
| 9226 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9227 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9228 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9229 | EndCommandBuffer(); |
| 9230 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9231 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9232 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9233 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9234 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9235 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9236 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9237 | } |
| 9238 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9239 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 9240 | VkResult err; |
| 9241 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9242 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9243 | m_errorMonitor->SetDesiredFailureMsg( |
| 9244 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9245 | "vkCmdResolveImage called with source sample count less than 2."); |
| 9246 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9247 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9248 | |
| 9249 | // Create two images of sample count 1 and try to Resolve between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9250 | VkImage srcImage; |
| 9251 | VkImage dstImage; |
| 9252 | VkDeviceMemory srcMem; |
| 9253 | VkDeviceMemory destMem; |
| 9254 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9255 | |
| 9256 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9257 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9258 | image_create_info.pNext = NULL; |
| 9259 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9260 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9261 | image_create_info.extent.width = 32; |
| 9262 | image_create_info.extent.height = 1; |
| 9263 | image_create_info.extent.depth = 1; |
| 9264 | image_create_info.mipLevels = 1; |
| 9265 | image_create_info.arrayLayers = 1; |
| 9266 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9267 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9268 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9269 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9270 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9271 | err = |
| 9272 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9273 | ASSERT_VK_SUCCESS(err); |
| 9274 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9275 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9276 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9277 | err = |
| 9278 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9279 | ASSERT_VK_SUCCESS(err); |
| 9280 | |
| 9281 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9282 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9283 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9284 | memAlloc.pNext = NULL; |
| 9285 | memAlloc.allocationSize = 0; |
| 9286 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9287 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9288 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9289 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9290 | pass = |
| 9291 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9292 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9293 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9294 | ASSERT_VK_SUCCESS(err); |
| 9295 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9296 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9297 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9298 | pass = |
| 9299 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9300 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9301 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9302 | ASSERT_VK_SUCCESS(err); |
| 9303 | |
| 9304 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9305 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9306 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9307 | ASSERT_VK_SUCCESS(err); |
| 9308 | |
| 9309 | BeginCommandBuffer(); |
| 9310 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9311 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9312 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9313 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9314 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9315 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9316 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9317 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9318 | resolveRegion.srcOffset.x = 0; |
| 9319 | resolveRegion.srcOffset.y = 0; |
| 9320 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9321 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9322 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9323 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9324 | resolveRegion.dstSubresource.layerCount = 0; |
| 9325 | resolveRegion.dstOffset.x = 0; |
| 9326 | resolveRegion.dstOffset.y = 0; |
| 9327 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9328 | resolveRegion.extent.width = 1; |
| 9329 | resolveRegion.extent.height = 1; |
| 9330 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9331 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9332 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9333 | EndCommandBuffer(); |
| 9334 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9335 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9336 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9337 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9338 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9339 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9340 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9341 | } |
| 9342 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9343 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 9344 | VkResult err; |
| 9345 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9346 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9347 | m_errorMonitor->SetDesiredFailureMsg( |
| 9348 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9349 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 9350 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9351 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9352 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 9353 | // Create two images of sample count 4 and try to Resolve between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9354 | VkImage srcImage; |
| 9355 | VkImage dstImage; |
| 9356 | VkDeviceMemory srcMem; |
| 9357 | VkDeviceMemory destMem; |
| 9358 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9359 | |
| 9360 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9361 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9362 | image_create_info.pNext = NULL; |
| 9363 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9364 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9365 | image_create_info.extent.width = 32; |
| 9366 | image_create_info.extent.height = 1; |
| 9367 | image_create_info.extent.depth = 1; |
| 9368 | image_create_info.mipLevels = 1; |
| 9369 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 9370 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9371 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9372 | // Note: Some implementations expect color attachment usage for any |
| 9373 | // multisample surface |
| 9374 | image_create_info.usage = |
| 9375 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9376 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9377 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9378 | err = |
| 9379 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9380 | ASSERT_VK_SUCCESS(err); |
| 9381 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9382 | // Note: Some implementations expect color attachment usage for any |
| 9383 | // multisample surface |
| 9384 | image_create_info.usage = |
| 9385 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9386 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9387 | err = |
| 9388 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9389 | ASSERT_VK_SUCCESS(err); |
| 9390 | |
| 9391 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9392 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9393 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9394 | memAlloc.pNext = NULL; |
| 9395 | memAlloc.allocationSize = 0; |
| 9396 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9397 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9398 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9399 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9400 | pass = |
| 9401 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9402 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9403 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9404 | ASSERT_VK_SUCCESS(err); |
| 9405 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9406 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9407 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9408 | pass = |
| 9409 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9410 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9411 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9412 | ASSERT_VK_SUCCESS(err); |
| 9413 | |
| 9414 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9415 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9416 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9417 | ASSERT_VK_SUCCESS(err); |
| 9418 | |
| 9419 | BeginCommandBuffer(); |
| 9420 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9421 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9422 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9423 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9424 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9425 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9426 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9427 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9428 | resolveRegion.srcOffset.x = 0; |
| 9429 | resolveRegion.srcOffset.y = 0; |
| 9430 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9431 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9432 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9433 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9434 | resolveRegion.dstSubresource.layerCount = 0; |
| 9435 | resolveRegion.dstOffset.x = 0; |
| 9436 | resolveRegion.dstOffset.y = 0; |
| 9437 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9438 | resolveRegion.extent.width = 1; |
| 9439 | resolveRegion.extent.height = 1; |
| 9440 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9441 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9442 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9443 | EndCommandBuffer(); |
| 9444 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9445 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9446 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9447 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9448 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9449 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9450 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9451 | } |
| 9452 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9453 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 9454 | VkResult err; |
| 9455 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9456 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9457 | m_errorMonitor->SetDesiredFailureMsg( |
| 9458 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9459 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 9460 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9461 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9462 | |
| 9463 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9464 | VkImage srcImage; |
| 9465 | VkImage dstImage; |
| 9466 | VkDeviceMemory srcMem; |
| 9467 | VkDeviceMemory destMem; |
| 9468 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9469 | |
| 9470 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9471 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9472 | image_create_info.pNext = NULL; |
| 9473 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9474 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9475 | image_create_info.extent.width = 32; |
| 9476 | image_create_info.extent.height = 1; |
| 9477 | image_create_info.extent.depth = 1; |
| 9478 | image_create_info.mipLevels = 1; |
| 9479 | image_create_info.arrayLayers = 1; |
| 9480 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 9481 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9482 | // Note: Some implementations expect color attachment usage for any |
| 9483 | // multisample surface |
| 9484 | image_create_info.usage = |
| 9485 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9486 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9487 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9488 | err = |
| 9489 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9490 | ASSERT_VK_SUCCESS(err); |
| 9491 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9492 | // Set format to something other than source image |
| 9493 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 9494 | // Note: Some implementations expect color attachment usage for any |
| 9495 | // multisample surface |
| 9496 | image_create_info.usage = |
| 9497 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9498 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9499 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9500 | err = |
| 9501 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9502 | ASSERT_VK_SUCCESS(err); |
| 9503 | |
| 9504 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9505 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9506 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9507 | memAlloc.pNext = NULL; |
| 9508 | memAlloc.allocationSize = 0; |
| 9509 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9510 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9511 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9512 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9513 | pass = |
| 9514 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9515 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9516 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9517 | ASSERT_VK_SUCCESS(err); |
| 9518 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9519 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9520 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9521 | pass = |
| 9522 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9523 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9524 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9525 | ASSERT_VK_SUCCESS(err); |
| 9526 | |
| 9527 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9528 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9529 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9530 | ASSERT_VK_SUCCESS(err); |
| 9531 | |
| 9532 | BeginCommandBuffer(); |
| 9533 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9534 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9535 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9536 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9537 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9538 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9539 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9540 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9541 | resolveRegion.srcOffset.x = 0; |
| 9542 | resolveRegion.srcOffset.y = 0; |
| 9543 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9544 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9545 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9546 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9547 | resolveRegion.dstSubresource.layerCount = 0; |
| 9548 | resolveRegion.dstOffset.x = 0; |
| 9549 | resolveRegion.dstOffset.y = 0; |
| 9550 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9551 | resolveRegion.extent.width = 1; |
| 9552 | resolveRegion.extent.height = 1; |
| 9553 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9554 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9555 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9556 | EndCommandBuffer(); |
| 9557 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9558 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9559 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9560 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9561 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9562 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9563 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9564 | } |
| 9565 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9566 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 9567 | VkResult err; |
| 9568 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9569 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9570 | m_errorMonitor->SetDesiredFailureMsg( |
| 9571 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9572 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 9573 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9574 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9575 | |
| 9576 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9577 | VkImage srcImage; |
| 9578 | VkImage dstImage; |
| 9579 | VkDeviceMemory srcMem; |
| 9580 | VkDeviceMemory destMem; |
| 9581 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9582 | |
| 9583 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9584 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9585 | image_create_info.pNext = NULL; |
| 9586 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9587 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9588 | image_create_info.extent.width = 32; |
| 9589 | image_create_info.extent.height = 1; |
| 9590 | image_create_info.extent.depth = 1; |
| 9591 | image_create_info.mipLevels = 1; |
| 9592 | image_create_info.arrayLayers = 1; |
| 9593 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 9594 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9595 | // Note: Some implementations expect color attachment usage for any |
| 9596 | // multisample surface |
| 9597 | image_create_info.usage = |
| 9598 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9599 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9600 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9601 | err = |
| 9602 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9603 | ASSERT_VK_SUCCESS(err); |
| 9604 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9605 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 9606 | // Note: Some implementations expect color attachment usage for any |
| 9607 | // multisample surface |
| 9608 | image_create_info.usage = |
| 9609 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9610 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9611 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9612 | err = |
| 9613 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9614 | ASSERT_VK_SUCCESS(err); |
| 9615 | |
| 9616 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9617 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9618 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9619 | memAlloc.pNext = NULL; |
| 9620 | memAlloc.allocationSize = 0; |
| 9621 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9622 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9623 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9624 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9625 | pass = |
| 9626 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9627 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9628 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9629 | ASSERT_VK_SUCCESS(err); |
| 9630 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9631 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9632 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9633 | pass = |
| 9634 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9635 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9636 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9637 | ASSERT_VK_SUCCESS(err); |
| 9638 | |
| 9639 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9640 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9641 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9642 | ASSERT_VK_SUCCESS(err); |
| 9643 | |
| 9644 | BeginCommandBuffer(); |
| 9645 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9646 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9647 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9648 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9649 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9650 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9651 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9652 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9653 | resolveRegion.srcOffset.x = 0; |
| 9654 | resolveRegion.srcOffset.y = 0; |
| 9655 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9656 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9657 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9658 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9659 | resolveRegion.dstSubresource.layerCount = 0; |
| 9660 | resolveRegion.dstOffset.x = 0; |
| 9661 | resolveRegion.dstOffset.y = 0; |
| 9662 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9663 | resolveRegion.extent.width = 1; |
| 9664 | resolveRegion.extent.height = 1; |
| 9665 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9666 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9667 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9668 | EndCommandBuffer(); |
| 9669 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9670 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9671 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9672 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9673 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9674 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9675 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9676 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9677 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9678 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9679 | // Create a single Image descriptor and cause it to first hit an error due |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9680 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 9681 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9682 | // The image format check comes 2nd in validation so we trigger it first, |
| 9683 | // then when we cause aspect fail next, bad format check will be preempted |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9684 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9685 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9686 | m_errorMonitor->SetDesiredFailureMsg( |
| 9687 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9688 | "Combination depth/stencil image formats can have only the "); |
| 9689 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9690 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9691 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9692 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9693 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 9694 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9695 | |
| 9696 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9697 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9698 | ds_pool_ci.pNext = NULL; |
| 9699 | ds_pool_ci.maxSets = 1; |
| 9700 | ds_pool_ci.poolSizeCount = 1; |
| 9701 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9702 | |
| 9703 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9704 | err = |
| 9705 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9706 | ASSERT_VK_SUCCESS(err); |
| 9707 | |
| 9708 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9709 | dsl_binding.binding = 0; |
| 9710 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 9711 | dsl_binding.descriptorCount = 1; |
| 9712 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9713 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9714 | |
| 9715 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9716 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9717 | ds_layout_ci.pNext = NULL; |
| 9718 | ds_layout_ci.bindingCount = 1; |
| 9719 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9720 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9721 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9722 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9723 | ASSERT_VK_SUCCESS(err); |
| 9724 | |
| 9725 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9726 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9727 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9728 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9729 | alloc_info.descriptorPool = ds_pool; |
| 9730 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9731 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9732 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9733 | ASSERT_VK_SUCCESS(err); |
| 9734 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9735 | VkImage image_bad; |
| 9736 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9737 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9738 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9739 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9740 | const int32_t tex_width = 32; |
| 9741 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9742 | |
| 9743 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9744 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9745 | image_create_info.pNext = NULL; |
| 9746 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9747 | image_create_info.format = tex_format_bad; |
| 9748 | image_create_info.extent.width = tex_width; |
| 9749 | image_create_info.extent.height = tex_height; |
| 9750 | image_create_info.extent.depth = 1; |
| 9751 | image_create_info.mipLevels = 1; |
| 9752 | image_create_info.arrayLayers = 1; |
| 9753 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9754 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9755 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 9756 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 9757 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9758 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9759 | err = |
| 9760 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9761 | ASSERT_VK_SUCCESS(err); |
| 9762 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9763 | image_create_info.usage = |
| 9764 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9765 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 9766 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9767 | ASSERT_VK_SUCCESS(err); |
| 9768 | |
| 9769 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9770 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9771 | image_view_create_info.image = image_bad; |
| 9772 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9773 | image_view_create_info.format = tex_format_bad; |
| 9774 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 9775 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 9776 | image_view_create_info.subresourceRange.layerCount = 1; |
| 9777 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9778 | image_view_create_info.subresourceRange.aspectMask = |
| 9779 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9780 | |
| 9781 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9782 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9783 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9784 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9785 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9786 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9787 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 9788 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9789 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9790 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9791 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9792 | #endif // IMAGE_TESTS |
| 9793 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9794 | int main(int argc, char **argv) { |
| 9795 | int result; |
| 9796 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 9797 | #ifdef ANDROID |
| 9798 | int vulkanSupport = InitVulkan(); |
| 9799 | if (vulkanSupport == 0) |
| 9800 | return 1; |
| 9801 | #endif |
| 9802 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9803 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 9804 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9805 | |
| 9806 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 9807 | |
| 9808 | result = RUN_ALL_TESTS(); |
| 9809 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 9810 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9811 | return result; |
| 9812 | } |