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 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | * of this software and/or associated documentation files (the "Materials"), to |
| 9 | * deal in the Materials without restriction, including without limitation the |
| 10 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 11 | * sell copies of the Materials, and to permit persons to whom the Materials are |
| 12 | * furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice(s) and this permission notice shall be included in |
| 15 | * all copies or substantial portions of the Materials. |
| 16 | * |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 17 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 | * |
| 21 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 24 | * USE OR OTHER DEALINGS IN THE MATERIALS. |
| 25 | * |
| 26 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 27 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 28 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 29 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 30 | * Author: Mike Stroyan <mike@LunarG.com> |
| 31 | * Author: Tobin Ehlis <tobine@google.com> |
| 32 | * Author: Tony Barbour <tony@LunarG.com> |
| 33 | */ |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 34 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 35 | #ifdef ANDROID |
| 36 | #include "vulkan_wrapper.h" |
| 37 | #else |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 38 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 39 | #endif |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 40 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 41 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 42 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 43 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | #define GLM_FORCE_RADIANS |
| 46 | #include "glm/glm.hpp" |
| 47 | #include <glm/gtc/matrix_transform.hpp> |
| 48 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 49 | #define MEM_TRACKER_TESTS 1 |
| 50 | #define OBJ_TRACKER_TESTS 1 |
| 51 | #define DRAW_STATE_TESTS 1 |
| 52 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 53 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 54 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 55 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 56 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 57 | //-------------------------------------------------------------------------------------- |
| 58 | // Mesh and VertexFormat Data |
| 59 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 60 | struct Vertex { |
| 61 | float posX, posY, posZ, posW; // Position data |
| 62 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 63 | }; |
| 64 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 65 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 66 | |
| 67 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 68 | BsoFailNone = 0x00000000, |
| 69 | BsoFailLineWidth = 0x00000001, |
| 70 | BsoFailDepthBias = 0x00000002, |
| 71 | BsoFailViewport = 0x00000004, |
| 72 | BsoFailScissor = 0x00000008, |
| 73 | BsoFailBlend = 0x00000010, |
| 74 | BsoFailDepthBounds = 0x00000020, |
| 75 | BsoFailStencilReadMask = 0x00000040, |
| 76 | BsoFailStencilWriteMask = 0x00000080, |
| 77 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 78 | } BsoFailSelect; |
| 79 | |
| 80 | struct vktriangle_vs_uniform { |
| 81 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 82 | float mvp[4][4]; |
| 83 | float position[3][4]; |
| 84 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 85 | }; |
| 86 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 87 | static const char bindStateVertShaderText[] = |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 88 | "#version 400\n" |
| 89 | "#extension GL_ARB_separate_shader_objects : require\n" |
| 90 | "#extension GL_ARB_shading_language_420pack : require\n" |
| 91 | "vec2 vertices[3];\n" |
| 92 | "out gl_PerVertex {\n" |
| 93 | " vec4 gl_Position;\n" |
| 94 | "};\n" |
| 95 | "void main() {\n" |
| 96 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 97 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 98 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 99 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 100 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 101 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 102 | static const char bindStateFragShaderText[] = |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 103 | "#version 400\n" |
| 104 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 105 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 106 | "\n" |
| 107 | "layout(location = 0) out vec4 uFragColor;\n" |
| 108 | "void main(){\n" |
| 109 | " uFragColor = vec4(0,1,0,1);\n" |
| 110 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 111 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 112 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 113 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 114 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 115 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 116 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 117 | // ******************************************************** |
| 118 | // ErrorMonitor Usage: |
| 119 | // |
| 120 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 121 | // encountered log messages. Passing NULL will match all log messages. |
| 122 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 123 | // |
| 124 | // Call DesiredMsgFound to determine if the desired failure message |
| 125 | // was encountered. |
| 126 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 127 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 128 | public: |
| 129 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 130 | test_platform_thread_create_mutex(&m_mutex); |
| 131 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 132 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 133 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 134 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 135 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 136 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 137 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 138 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 139 | m_desiredMsg.clear(); |
| 140 | m_failureMsg.clear(); |
| 141 | m_otherMsgs.clear(); |
| 142 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 143 | m_msgFound = VK_FALSE; |
| 144 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 145 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 146 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 147 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 148 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 149 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 150 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 151 | if (m_bailout != NULL) { |
| 152 | *m_bailout = true; |
| 153 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 154 | string errorString(msgString); |
| 155 | if (msgFlags & m_msgFlags) { |
| 156 | if (errorString.find(m_desiredMsg) != string::npos) { |
| 157 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 158 | m_msgFound = VK_TRUE; |
| 159 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 160 | } else { |
| 161 | m_otherMsgs.push_back(errorString); |
| 162 | } |
| 163 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 164 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 165 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 166 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 167 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 168 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 169 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 170 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 171 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 172 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 174 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 175 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 176 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 177 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 178 | cout << "Other error messages logged for this test were:" << endl; |
| 179 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 180 | cout << " " << *iter << endl; |
| 181 | } |
| 182 | } |
| 183 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 184 | private: |
| 185 | VkFlags m_msgFlags; |
| 186 | string m_desiredMsg; |
| 187 | string m_failureMsg; |
| 188 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 189 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 190 | bool *m_bailout; |
| 191 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 192 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 193 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 194 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 195 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 196 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 197 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 198 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 199 | (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] | 200 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 201 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 202 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 203 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 204 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 205 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 206 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 207 | class VkLayerTest : public VkRenderFramework { |
| 208 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 209 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 210 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 211 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 212 | BsoFailSelect failMask); |
| 213 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 214 | VkPipelineObj &pipelineobj, |
| 215 | VkDescriptorSetObj &descriptorSet, |
| 216 | BsoFailSelect failMask); |
| 217 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 218 | VkDescriptorSetObj &descriptorSet, |
| 219 | BsoFailSelect failMask) { |
| 220 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 221 | failMask); |
| 222 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 223 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 224 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 225 | VkResult BeginCommandBuffer() { |
| 226 | return BeginCommandBuffer(*m_commandBuffer); |
| 227 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 228 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 229 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 230 | uint32_t firstVertex, uint32_t firstInstance) { |
| 231 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 232 | firstInstance); |
| 233 | } |
| 234 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 235 | uint32_t firstIndex, int32_t vertexOffset, |
| 236 | uint32_t firstInstance) { |
| 237 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 238 | vertexOffset, firstInstance); |
| 239 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 240 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 241 | void QueueCommandBuffer(const VkFence &fence) { |
| 242 | m_commandBuffer->QueueCommandBuffer(fence); |
| 243 | } |
| 244 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 245 | VkDeviceSize offset, uint32_t binding) { |
| 246 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 247 | } |
| 248 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 249 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 250 | } |
| 251 | |
| 252 | protected: |
| 253 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 254 | |
| 255 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 256 | std::vector<const char *> instance_layer_names; |
| 257 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 258 | std::vector<const char *> instance_extension_names; |
| 259 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 260 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 261 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 262 | /* |
| 263 | * Since CreateDbgMsgCallback is an instance level extension call |
| 264 | * any extension / layer that utilizes that feature also needs |
| 265 | * to be enabled at create instance time. |
| 266 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 267 | // Use Threading layer first to protect others from |
| 268 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 269 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 270 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 271 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 272 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 273 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 274 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 275 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 276 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 277 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 278 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 279 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 280 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 281 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 282 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 283 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 284 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 285 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 286 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 287 | this->app_info.pApplicationName = "layer_tests"; |
| 288 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 289 | this->app_info.pEngineName = "unittest"; |
| 290 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 291 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 292 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 293 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 294 | InitFramework(instance_layer_names, device_layer_names, |
| 295 | instance_extension_names, device_extension_names, |
| 296 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | virtual void TearDown() { |
| 300 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 301 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 302 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 303 | } |
| 304 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 305 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 306 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 307 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 308 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 309 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 310 | |
| 311 | /* |
| 312 | * For render test all drawing happens in a single render pass |
| 313 | * on a single command buffer. |
| 314 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 315 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 316 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | return result; |
| 320 | } |
| 321 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 322 | VkResult VkLayerTest::EndCommandBuffer(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 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 325 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 326 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 327 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 328 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 329 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 330 | |
| 331 | return result; |
| 332 | } |
| 333 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 334 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 335 | const char *fragShaderText, |
| 336 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 337 | // Create identity matrix |
| 338 | int i; |
| 339 | struct vktriangle_vs_uniform data; |
| 340 | |
| 341 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 342 | glm::mat4 View = glm::mat4(1.0f); |
| 343 | glm::mat4 Model = glm::mat4(1.0f); |
| 344 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 345 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 346 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 347 | |
| 348 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 349 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 350 | static const Vertex tri_data[] = { |
| 351 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 352 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 353 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 354 | }; |
| 355 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 356 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 357 | data.position[i][0] = tri_data[i].posX; |
| 358 | data.position[i][1] = tri_data[i].posY; |
| 359 | data.position[i][2] = tri_data[i].posZ; |
| 360 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 361 | data.color[i][0] = tri_data[i].r; |
| 362 | data.color[i][1] = tri_data[i].g; |
| 363 | data.color[i][2] = tri_data[i].b; |
| 364 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 368 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 369 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 370 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 371 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 372 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 373 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 374 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 375 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 376 | |
| 377 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 378 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 379 | pipelineobj.AddShader(&vs); |
| 380 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 381 | if (failMask & BsoFailLineWidth) { |
| 382 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
| 383 | } |
| 384 | if (failMask & BsoFailDepthBias) { |
| 385 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
| 386 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 387 | // Viewport and scissors must stay in synch or other errors will occur than |
| 388 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 389 | if (failMask & BsoFailViewport) { |
| 390 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 391 | m_viewports.clear(); |
| 392 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 393 | } |
| 394 | if (failMask & BsoFailScissor) { |
| 395 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 396 | m_scissors.clear(); |
| 397 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 398 | } |
| 399 | if (failMask & BsoFailBlend) { |
| 400 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
| 401 | } |
| 402 | if (failMask & BsoFailDepthBounds) { |
| 403 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 404 | } |
| 405 | if (failMask & BsoFailStencilReadMask) { |
| 406 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 407 | } |
| 408 | if (failMask & BsoFailStencilWriteMask) { |
| 409 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 410 | } |
| 411 | if (failMask & BsoFailStencilReference) { |
| 412 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 413 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 414 | |
| 415 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 416 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 417 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 418 | |
| 419 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 420 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 421 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 422 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 423 | |
| 424 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 425 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 426 | |
| 427 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 428 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 429 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 430 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 431 | } |
| 432 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 433 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 434 | VkPipelineObj &pipelineobj, |
| 435 | VkDescriptorSetObj &descriptorSet, |
| 436 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 437 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 438 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 439 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 440 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 441 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 442 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 443 | } |
| 444 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 445 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 446 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 447 | // correctly |
| 448 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 449 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 450 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 451 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 452 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 453 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 454 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 455 | |
| 456 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 457 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 458 | ds_ci.pNext = NULL; |
| 459 | ds_ci.depthTestEnable = VK_FALSE; |
| 460 | ds_ci.depthWriteEnable = VK_TRUE; |
| 461 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 462 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
| 463 | ds_ci.stencilTestEnable = VK_TRUE; |
| 464 | ds_ci.front = stencil; |
| 465 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 466 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 467 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 468 | pipelineobj.SetViewport(m_viewports); |
| 469 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 470 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 471 | VkResult err = pipelineobj.CreateVKPipeline( |
| 472 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 473 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 474 | commandBuffer->BindPipeline(pipelineobj); |
| 475 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | // ******************************************************************************************************************** |
| 479 | // ******************************************************************************************************************** |
| 480 | // ******************************************************************************************************************** |
| 481 | // ******************************************************************************************************************** |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 482 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 483 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 484 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 485 | { |
| 486 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 487 | VkFenceCreateInfo fenceInfo = {}; |
| 488 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 489 | fenceInfo.pNext = NULL; |
| 490 | fenceInfo.flags = 0; |
| 491 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 492 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 493 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 494 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 495 | |
| 496 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 497 | vk_testing::Buffer buffer; |
| 498 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 499 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 500 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 501 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 502 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 503 | |
| 504 | testFence.init(*m_device, fenceInfo); |
| 505 | |
| 506 | // Bypass framework since it does the waits automatically |
| 507 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 508 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 509 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 510 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 511 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 512 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 513 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 514 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 515 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 516 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 517 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 518 | |
| 519 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 520 | ASSERT_VK_SUCCESS( err ); |
| 521 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 522 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 523 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 524 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 525 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 526 | FAIL() << "Did not receive Error 'Resetting CB (0xaddress) before it has completed. You must check CB flag before.'"; |
| 527 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 528 | } |
| 529 | } |
| 530 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 531 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 532 | { |
| 533 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 534 | VkFenceCreateInfo fenceInfo = {}; |
| 535 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 536 | fenceInfo.pNext = NULL; |
| 537 | fenceInfo.flags = 0; |
| 538 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 539 | 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] | 540 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 541 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 542 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 543 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 544 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 545 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 546 | 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] | 547 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 548 | |
| 549 | testFence.init(*m_device, fenceInfo); |
| 550 | |
| 551 | // Bypass framework since it does the waits automatically |
| 552 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 553 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 554 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 555 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 556 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 557 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 558 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 559 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 560 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 561 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 562 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 563 | |
| 564 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 565 | ASSERT_VK_SUCCESS( err ); |
| 566 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 567 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 568 | VkCommandBufferBeginInfo info = {}; |
| 569 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 570 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 571 | info.renderPass = VK_NULL_HANDLE; |
| 572 | info.subpass = 0; |
| 573 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 574 | info.occlusionQueryEnable = VK_FALSE; |
| 575 | info.queryFlags = 0; |
| 576 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 577 | |
| 578 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 579 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 580 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 581 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 582 | FAIL() << "Did not receive Error 'Calling vkBeginCommandBuffer() on an active CB (0xaddress) before it has completed'"; |
| 583 | m_errorMonitor->DumpFailureMsgs(); |
| 584 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 585 | } |
| 586 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 587 | #endif |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 588 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 589 | VkResult err; |
| 590 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 591 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 592 | m_errorMonitor->SetDesiredFailureMsg( |
| 593 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 594 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 595 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 596 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 597 | |
| 598 | // 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] | 599 | VkImage image; |
| 600 | VkDeviceMemory mem; |
| 601 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 602 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 603 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 604 | const int32_t tex_width = 32; |
| 605 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 606 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 607 | VkImageCreateInfo image_create_info = {}; |
| 608 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 609 | image_create_info.pNext = NULL; |
| 610 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 611 | image_create_info.format = tex_format; |
| 612 | image_create_info.extent.width = tex_width; |
| 613 | image_create_info.extent.height = tex_height; |
| 614 | image_create_info.extent.depth = 1; |
| 615 | image_create_info.mipLevels = 1; |
| 616 | image_create_info.arrayLayers = 1; |
| 617 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 618 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 619 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 620 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 621 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 622 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 623 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 624 | mem_alloc.pNext = NULL; |
| 625 | mem_alloc.allocationSize = 0; |
| 626 | // Introduce failure, do NOT set memProps to |
| 627 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 628 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 629 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 630 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 631 | ASSERT_VK_SUCCESS(err); |
| 632 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 633 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 634 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 635 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 636 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 637 | pass = |
| 638 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 639 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 640 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 641 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 642 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 643 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 644 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 645 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 646 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 647 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 648 | ASSERT_VK_SUCCESS(err); |
| 649 | |
| 650 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 651 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 652 | ASSERT_VK_SUCCESS(err); |
| 653 | |
| 654 | // Map memory as if to initialize the image |
| 655 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 656 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 657 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 658 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 659 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 660 | FAIL() << "Did not receive Error 'Error received did not match " |
| 661 | "expected error message from vkMapMemory in MemTracker'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 662 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 663 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 664 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 665 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 666 | } |
| 667 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 668 | // TODO : Is this test still valid. Not sure it is with updates to memory |
| 669 | // binding model |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 670 | // Verify and delete the test of fix the check |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 671 | // TEST_F(VkLayerTest, FreeBoundMemory) |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 672 | //{ |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 673 | // VkResult err; |
| 674 | // |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 675 | // m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 676 | // "Freeing memory object while it still has references"); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 677 | // |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 678 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 679 | |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 680 | // // Create an image, allocate memory, free it, and then try to bind it |
| 681 | // VkImage image; |
| 682 | // VkDeviceMemory mem; |
| 683 | // VkMemoryRequirements mem_reqs; |
| 684 | // |
| 685 | // const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 686 | // const int32_t tex_width = 32; |
| 687 | // const int32_t tex_height = 32; |
| 688 | // |
| 689 | // const VkImageCreateInfo image_create_info = { |
| 690 | // .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 691 | // .pNext = NULL, |
| 692 | // .imageType = VK_IMAGE_TYPE_2D, |
| 693 | // .format = tex_format, |
| 694 | // .extent = { tex_width, tex_height, 1 }, |
| 695 | // .mipLevels = 1, |
| 696 | // .arraySize = 1, |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 697 | // .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 698 | // .tiling = VK_IMAGE_TILING_LINEAR, |
| 699 | // .usage = VK_IMAGE_USAGE_SAMPLED_BIT, |
| 700 | // .flags = 0, |
| 701 | // }; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 702 | // VkMemoryAllocateInfo mem_alloc = { |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 703 | // .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 704 | // .pNext = NULL, |
| 705 | // .allocationSize = 0, |
| 706 | // .memoryTypeIndex = 0, |
| 707 | // }; |
| 708 | // |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 709 | // err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 710 | // ASSERT_VK_SUCCESS(err); |
| 711 | // |
| 712 | // err = vkGetImageMemoryRequirements(m_device->device(), |
| 713 | // image, |
| 714 | // &mem_reqs); |
| 715 | // ASSERT_VK_SUCCESS(err); |
| 716 | // |
| 717 | // mem_alloc.allocationSize = mem_reqs.size; |
| 718 | // |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 719 | // err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 720 | // 0); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 721 | // ASSERT_VK_SUCCESS(err); |
| 722 | // |
| 723 | // // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 724 | // err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 725 | // ASSERT_VK_SUCCESS(err); |
| 726 | // |
| 727 | // // Bind memory to Image object |
| 728 | // err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 729 | // ASSERT_VK_SUCCESS(err); |
| 730 | // |
| 731 | // // Introduce validation failure, free memory while still bound to object |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 732 | // vkFreeMemory(m_device->device(), mem, NULL); |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 733 | // |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 734 | // if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 735 | // FAIL() << "Did not receive Warning 'Freeing memory object while it |
| 736 | // still has references'"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 737 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 738 | // } |
| 739 | //} |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 740 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 741 | TEST_F(VkLayerTest, RebindMemory) { |
| 742 | VkResult err; |
| 743 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 744 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 745 | m_errorMonitor->SetDesiredFailureMsg( |
| 746 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 747 | "which has already been bound to mem object"); |
| 748 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 749 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 750 | |
| 751 | // 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] | 752 | VkImage image; |
| 753 | VkDeviceMemory mem1; |
| 754 | VkDeviceMemory mem2; |
| 755 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 756 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 757 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 758 | const int32_t tex_width = 32; |
| 759 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 760 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 761 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 762 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 763 | image_create_info.pNext = NULL; |
| 764 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 765 | image_create_info.format = tex_format; |
| 766 | image_create_info.extent.width = tex_width; |
| 767 | image_create_info.extent.height = tex_height; |
| 768 | image_create_info.extent.depth = 1; |
| 769 | image_create_info.mipLevels = 1; |
| 770 | image_create_info.arrayLayers = 1; |
| 771 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 772 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 773 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 774 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 775 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 776 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 777 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 778 | mem_alloc.pNext = NULL; |
| 779 | mem_alloc.allocationSize = 0; |
| 780 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 781 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 782 | // Introduce failure, do NOT set memProps to |
| 783 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 784 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 785 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 786 | ASSERT_VK_SUCCESS(err); |
| 787 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 788 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 789 | |
| 790 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 791 | pass = |
| 792 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 793 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 794 | |
| 795 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 796 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 797 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 798 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 799 | ASSERT_VK_SUCCESS(err); |
| 800 | |
| 801 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 802 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 803 | ASSERT_VK_SUCCESS(err); |
| 804 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 805 | // Introduce validation failure, try to bind a different memory object to |
| 806 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 807 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 808 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 809 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 810 | FAIL() << "Did not receive Error when rebinding memory to an object"; |
| 811 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 812 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 813 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 814 | vkDestroyImage(m_device->device(), image, NULL); |
| 815 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 816 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 817 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 818 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 819 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 820 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 821 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 822 | m_errorMonitor->SetDesiredFailureMsg( |
| 823 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 824 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 825 | |
| 826 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 827 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 828 | fenceInfo.pNext = NULL; |
| 829 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 830 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 831 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 832 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 833 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 834 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 835 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 836 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 837 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 838 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 839 | |
| 840 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 841 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 842 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 843 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 844 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 845 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 846 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 847 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 848 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 849 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 850 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 851 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 852 | |
| 853 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 854 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 855 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 856 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 857 | FAIL() << "Did not receive Error 'VkQueueSubmit with fence in " |
| 858 | "SIGNALED_STATE'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 859 | m_errorMonitor->DumpFailureMsgs(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 860 | } |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 861 | } |
| 862 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 863 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 864 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 865 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 866 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 867 | fenceInfo.pNext = NULL; |
| 868 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 869 | // TODO: verify that this matches layer |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 870 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 871 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 872 | "submitted to VkResetFences in UNSIGNALED STATE"); |
| 873 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 874 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 875 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 876 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 877 | vkResetFences(m_device->device(), 1, fences); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 878 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 879 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 880 | FAIL() << "Did not receive Error 'VkResetFences with fence in " |
| 881 | "UNSIGNALED_STATE'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 882 | m_errorMonitor->DumpFailureMsgs(); |
| 883 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 884 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 885 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 886 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 887 | #if 0 |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 888 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 889 | { |
| 890 | // Initiate Draw w/o a PSO bound |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 891 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 892 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 893 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 894 | |
| 895 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 896 | VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 897 | BeginCommandBuffer(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 898 | |
| 899 | const VkExtent3D e3d = { |
| 900 | .width = 128, |
| 901 | .height = 128, |
| 902 | .depth = 1, |
| 903 | }; |
| 904 | const VkImageCreateInfo ici = { |
| 905 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 906 | .pNext = NULL, |
| 907 | .imageType = VK_IMAGE_TYPE_2D, |
| 908 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 909 | .extent = e3d, |
| 910 | .mipLevels = 1, |
| 911 | .arraySize = 1, |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 912 | .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 913 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | 660f0ca | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 914 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 915 | .flags = 0, |
| 916 | }; |
| 917 | |
| 918 | VkImage dsi; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 919 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 920 | VkDepthStencilView dsv; |
| 921 | const VkDepthStencilViewCreateInfo dsvci = { |
| 922 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 923 | .pNext = NULL, |
| 924 | .image = dsi, |
| 925 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 4a26189 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 926 | .baseArrayLayer = 0, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 927 | .arraySize = 1, |
| 928 | .flags = 0, |
| 929 | }; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 930 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 931 | |
| 932 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 933 | FAIL() << "Error received was not 'Invalid usage flag for image...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 934 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 935 | } |
| 936 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 937 | #endif // 0 |
| 938 | #endif // MEM_TRACKER_TESTS |
| 939 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 940 | #if OBJ_TRACKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 941 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 942 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 943 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 944 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 945 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 946 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 947 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 948 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 949 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 950 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 951 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 952 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 953 | |
| 954 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 955 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 956 | ds_pool_ci.pNext = NULL; |
| 957 | ds_pool_ci.maxSets = 1; |
| 958 | ds_pool_ci.poolSizeCount = 1; |
| 959 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 960 | |
| 961 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 962 | err = |
| 963 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 964 | ASSERT_VK_SUCCESS(err); |
| 965 | |
| 966 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 967 | dsl_binding.binding = 0; |
| 968 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 969 | dsl_binding.descriptorCount = 1; |
| 970 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 971 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 972 | |
| 973 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 974 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 975 | ds_layout_ci.pNext = NULL; |
| 976 | ds_layout_ci.bindingCount = 1; |
| 977 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 978 | |
| 979 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 980 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 981 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 982 | ASSERT_VK_SUCCESS(err); |
| 983 | |
| 984 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 985 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 986 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 987 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 988 | alloc_info.descriptorPool = ds_pool; |
| 989 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 990 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 991 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 992 | ASSERT_VK_SUCCESS(err); |
| 993 | |
| 994 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 995 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 996 | pipeline_layout_ci.pNext = NULL; |
| 997 | pipeline_layout_ci.setLayoutCount = 1; |
| 998 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 999 | |
| 1000 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1001 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1002 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1003 | ASSERT_VK_SUCCESS(err); |
| 1004 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 1005 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1006 | |
| 1007 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1008 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1009 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1010 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1011 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1012 | FAIL() |
| 1013 | << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be'" |
| 1014 | << endl; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1015 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1016 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1017 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1018 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1019 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1020 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1021 | } |
| 1022 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1023 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 1024 | VkResult err; |
| 1025 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1026 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1027 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1028 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1029 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1030 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1031 | |
| 1032 | // 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] | 1033 | VkImage image; |
| 1034 | VkDeviceMemory mem; |
| 1035 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1036 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1037 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1038 | const int32_t tex_width = 32; |
| 1039 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1040 | |
| 1041 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1042 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1043 | image_create_info.pNext = NULL; |
| 1044 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1045 | image_create_info.format = tex_format; |
| 1046 | image_create_info.extent.width = tex_width; |
| 1047 | image_create_info.extent.height = tex_height; |
| 1048 | image_create_info.extent.depth = 1; |
| 1049 | image_create_info.mipLevels = 1; |
| 1050 | image_create_info.arrayLayers = 1; |
| 1051 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1052 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1053 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1054 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1055 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1056 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1057 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1058 | mem_alloc.pNext = NULL; |
| 1059 | mem_alloc.allocationSize = 0; |
| 1060 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1061 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1062 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1063 | ASSERT_VK_SUCCESS(err); |
| 1064 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1065 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1066 | |
| 1067 | mem_alloc.allocationSize = mem_reqs.size; |
| 1068 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1069 | pass = |
| 1070 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1071 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1072 | |
| 1073 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1074 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1075 | ASSERT_VK_SUCCESS(err); |
| 1076 | |
| 1077 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1078 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1079 | |
| 1080 | // Try to bind free memory that has been freed |
| 1081 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1082 | // This may very well return an error. |
| 1083 | (void)err; |
| 1084 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1085 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1086 | FAIL() << "Did not receive Error 'Invalid VkDeviceMemory Object " |
| 1087 | "0x<handle>'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1088 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1089 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1090 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1091 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1092 | } |
| 1093 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1094 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1095 | VkResult err; |
| 1096 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1097 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1098 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1099 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1100 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1101 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1102 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1103 | // Create an image object, allocate memory, destroy the object and then try |
| 1104 | // to bind it |
| 1105 | VkImage image; |
| 1106 | VkDeviceMemory mem; |
| 1107 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1108 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1109 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1110 | const int32_t tex_width = 32; |
| 1111 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1112 | |
| 1113 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1114 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1115 | image_create_info.pNext = NULL; |
| 1116 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1117 | image_create_info.format = tex_format; |
| 1118 | image_create_info.extent.width = tex_width; |
| 1119 | image_create_info.extent.height = tex_height; |
| 1120 | image_create_info.extent.depth = 1; |
| 1121 | image_create_info.mipLevels = 1; |
| 1122 | image_create_info.arrayLayers = 1; |
| 1123 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1124 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1125 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1126 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1127 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1128 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1129 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1130 | mem_alloc.pNext = NULL; |
| 1131 | mem_alloc.allocationSize = 0; |
| 1132 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1133 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1134 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1135 | ASSERT_VK_SUCCESS(err); |
| 1136 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1137 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1138 | |
| 1139 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1140 | pass = |
| 1141 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1142 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1143 | |
| 1144 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1145 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1146 | ASSERT_VK_SUCCESS(err); |
| 1147 | |
| 1148 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1149 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1150 | ASSERT_VK_SUCCESS(err); |
| 1151 | |
| 1152 | // Now Try to bind memory to this destroyed object |
| 1153 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1154 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1155 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1156 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1157 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1158 | FAIL() << "Did not receive Error 'Invalid VkImage Object 0x<handle>'"; |
| 1159 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1160 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1161 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1162 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1163 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1164 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1165 | #endif // OBJ_TRACKER_TESTS |
| 1166 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1167 | #if DRAW_STATE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1168 | TEST_F(VkLayerTest, LineWidthStateNotBound) { |
| 1169 | m_errorMonitor->SetDesiredFailureMsg( |
| 1170 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1171 | "Dynamic line width state not set for this command buffer"); |
| 1172 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1173 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line " |
| 1174 | "width state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1175 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1176 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1177 | BsoFailLineWidth); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1178 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1179 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1180 | FAIL() << "Did not receive Error 'Dynamic line width state not set for " |
| 1181 | "this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1182 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1183 | } |
| 1184 | } |
| 1185 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1186 | TEST_F(VkLayerTest, DepthBiasStateNotBound) { |
| 1187 | m_errorMonitor->SetDesiredFailureMsg( |
| 1188 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1189 | "Dynamic depth bias state not set for this command buffer"); |
| 1190 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1191 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth " |
| 1192 | "bias state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1193 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1194 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1195 | BsoFailDepthBias); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1196 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1197 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1198 | FAIL() << "Did not receive Error 'Dynamic depth bias state not set for " |
| 1199 | "this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1200 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1201 | } |
| 1202 | } |
| 1203 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1204 | // Disable these two tests until we can sort out how to track multiple layer |
| 1205 | // errors |
| 1206 | TEST_F(VkLayerTest, ViewportStateNotBound) { |
| 1207 | m_errorMonitor->SetDesiredFailureMsg( |
| 1208 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1209 | "Dynamic viewport state not set for this command buffer"); |
| 1210 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1211 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport " |
| 1212 | "state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1213 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1214 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1215 | BsoFailViewport); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1216 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1217 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1218 | FAIL() << "Did not recieve Error 'Dynamic scissor state not set for " |
| 1219 | "this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1220 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1221 | } |
| 1222 | } |
| 1223 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1224 | TEST_F(VkLayerTest, ScissorStateNotBound) { |
| 1225 | m_errorMonitor->SetDesiredFailureMsg( |
| 1226 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1227 | "Dynamic scissor state not set for this command buffer"); |
| 1228 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1229 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport " |
| 1230 | "state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1231 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1232 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1233 | BsoFailScissor); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1234 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1235 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1236 | FAIL() << "Did not recieve Error ' Expected: 'Dynamic scissor state " |
| 1237 | "not set for this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1238 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1239 | } |
| 1240 | } |
| 1241 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1242 | TEST_F(VkLayerTest, BlendStateNotBound) { |
| 1243 | m_errorMonitor->SetDesiredFailureMsg( |
| 1244 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1245 | "Dynamic blend object state not set for this command buffer"); |
| 1246 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1247 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend " |
| 1248 | "state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1249 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1250 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1251 | BsoFailBlend); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1252 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1253 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1254 | FAIL() << "Did not recieve Error 'Dynamic blend object state not set " |
| 1255 | "for this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1256 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1257 | } |
| 1258 | } |
| 1259 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1260 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) { |
| 1261 | m_errorMonitor->SetDesiredFailureMsg( |
| 1262 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1263 | "Dynamic depth bounds state not set for this command buffer"); |
| 1264 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1265 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth " |
| 1266 | "bounds state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1267 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1268 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1269 | BsoFailDepthBounds); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1270 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1271 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1272 | FAIL() << "Did not receive Error 'Dynamic depth bounds state not set " |
| 1273 | "for this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1274 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1275 | } |
| 1276 | } |
| 1277 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1278 | TEST_F(VkLayerTest, StencilReadMaskNotSet) { |
| 1279 | m_errorMonitor->SetDesiredFailureMsg( |
| 1280 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1281 | "Dynamic stencil read mask state not set for this command buffer"); |
| 1282 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1283 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1284 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1285 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1286 | "read mask is not set beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1287 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1288 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1289 | BsoFailStencilReadMask); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1290 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1291 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1292 | FAIL() << "Did not receive Error 'Dynamic stencil read mask state not " |
| 1293 | "set for this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1294 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1295 | } |
| 1296 | } |
| 1297 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1298 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) { |
| 1299 | m_errorMonitor->SetDesiredFailureMsg( |
| 1300 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1301 | "Dynamic stencil write mask state not set for this command buffer"); |
| 1302 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1303 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1304 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1305 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1306 | "write mask is not set beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1307 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1308 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1309 | BsoFailStencilWriteMask); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1310 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1311 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1312 | FAIL() << "Did not receive Error 'Dynamic stencil write mask state not " |
| 1313 | "set for this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1314 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1315 | } |
| 1316 | } |
| 1317 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1318 | TEST_F(VkLayerTest, StencilReferenceNotSet) { |
| 1319 | m_errorMonitor->SetDesiredFailureMsg( |
| 1320 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1321 | "Dynamic stencil reference state not set for this command buffer"); |
| 1322 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1323 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1324 | "reference is not set beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1325 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1326 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1327 | BsoFailStencilReference); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1328 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1329 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1330 | FAIL() << "Did not receive Error 'Dynamic stencil reference state not " |
| 1331 | "set for this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1332 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1333 | } |
| 1334 | } |
| 1335 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1336 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1337 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1338 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1339 | m_errorMonitor->SetDesiredFailureMsg( |
| 1340 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1341 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 1342 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1343 | |
| 1344 | VkFenceCreateInfo fenceInfo = {}; |
| 1345 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1346 | fenceInfo.pNext = NULL; |
| 1347 | fenceInfo.flags = 0; |
| 1348 | |
| 1349 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1350 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1351 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1352 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1353 | // We luck out b/c by default the framework creates CB w/ the |
| 1354 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1355 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1356 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 1357 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1358 | EndCommandBuffer(); |
| 1359 | |
| 1360 | testFence.init(*m_device, fenceInfo); |
| 1361 | |
| 1362 | // Bypass framework since it does the waits automatically |
| 1363 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1364 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1365 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1366 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1367 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1368 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1369 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1370 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1371 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1372 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1373 | submit_info.pSignalSemaphores = NULL; |
| 1374 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1375 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 1376 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1377 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1378 | // Cause validation error by re-submitting cmd buffer that should only be |
| 1379 | // submitted once |
| 1380 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1381 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1382 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1383 | FAIL() << "Did not receive Error 'CB (0xaddress) was created w/ " |
| 1384 | "VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1385 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1386 | } |
| 1387 | } |
| 1388 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1389 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1390 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1391 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1392 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1393 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1394 | "Unable to allocate 1 descriptors of " |
| 1395 | "type " |
| 1396 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1397 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1398 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1399 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1401 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 1402 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1403 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1404 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1405 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1406 | |
| 1407 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1408 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1409 | ds_pool_ci.pNext = NULL; |
| 1410 | ds_pool_ci.flags = 0; |
| 1411 | ds_pool_ci.maxSets = 1; |
| 1412 | ds_pool_ci.poolSizeCount = 1; |
| 1413 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1414 | |
| 1415 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1416 | err = |
| 1417 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1418 | ASSERT_VK_SUCCESS(err); |
| 1419 | |
| 1420 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1421 | dsl_binding.binding = 0; |
| 1422 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1423 | dsl_binding.descriptorCount = 1; |
| 1424 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1425 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1426 | |
| 1427 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1428 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1429 | ds_layout_ci.pNext = NULL; |
| 1430 | ds_layout_ci.bindingCount = 1; |
| 1431 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1432 | |
| 1433 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1434 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1435 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1436 | ASSERT_VK_SUCCESS(err); |
| 1437 | |
| 1438 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1439 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1440 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1441 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1442 | alloc_info.descriptorPool = ds_pool; |
| 1443 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1444 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1445 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1446 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1447 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1448 | FAIL() << "Did not receive Error 'Unable to allocate 1 descriptors of " |
| 1449 | "type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1450 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1451 | } |
| 1452 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1453 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1454 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1455 | } |
| 1456 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1457 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 1458 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1459 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1460 | m_errorMonitor->SetDesiredFailureMsg( |
| 1461 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1462 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 1463 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1464 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1465 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1466 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1467 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1468 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1469 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1470 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1471 | |
| 1472 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1473 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1474 | ds_pool_ci.pNext = NULL; |
| 1475 | ds_pool_ci.maxSets = 1; |
| 1476 | ds_pool_ci.poolSizeCount = 1; |
| 1477 | ds_pool_ci.flags = 0; |
| 1478 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1479 | // app can only call vkResetDescriptorPool on this pool.; |
| 1480 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1481 | |
| 1482 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1483 | err = |
| 1484 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1485 | ASSERT_VK_SUCCESS(err); |
| 1486 | |
| 1487 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1488 | dsl_binding.binding = 0; |
| 1489 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1490 | dsl_binding.descriptorCount = 1; |
| 1491 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1492 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1493 | |
| 1494 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1495 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1496 | ds_layout_ci.pNext = NULL; |
| 1497 | ds_layout_ci.bindingCount = 1; |
| 1498 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1499 | |
| 1500 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1501 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1502 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1503 | ASSERT_VK_SUCCESS(err); |
| 1504 | |
| 1505 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1506 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1507 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1508 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1509 | alloc_info.descriptorPool = ds_pool; |
| 1510 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1511 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1512 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1513 | ASSERT_VK_SUCCESS(err); |
| 1514 | |
| 1515 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1516 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1517 | FAIL() << "Did not receive Error 'It is invalid to call " |
| 1518 | "vkFreeDescriptorSets() with a pool created with...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1519 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1520 | } |
| 1521 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1522 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1523 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1524 | } |
| 1525 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1526 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
| 1527 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 1528 | // catch this case |
| 1529 | // The DS check for this is after driver has been called to validate DS |
| 1530 | // internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1531 | // Attempt to clear DS Pool with bad object |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1532 | /* |
| 1533 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1534 | "Unable to find pool node for pool 0xbaad6001 specified in |
| 1535 | vkResetDescriptorPool() call"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1536 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1537 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1538 | vkResetDescriptorPool(device(), badPool); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1539 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1540 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1541 | FAIL() << "Did not receive Error 'Unable to find pool node for pool |
| 1542 | 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1543 | m_errorMonitor->DumpFailureMsgs(); |
| 1544 | }*/ |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1545 | } |
| 1546 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1547 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
| 1548 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 1549 | // catch this case |
| 1550 | // The DS check for this is after driver has been called to validate DS |
| 1551 | // internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1552 | // Create a valid cmd buffer |
| 1553 | // call vkCmdBindDescriptorSets w/ false DS |
| 1554 | } |
| 1555 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1556 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
| 1557 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 1558 | // catch this case |
| 1559 | // The DS check for this is after driver has been called to validate DS |
| 1560 | // internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1561 | } |
| 1562 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1563 | TEST_F(VkLayerTest, InvalidPipeline) { |
| 1564 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 1565 | // catch this case |
| 1566 | // The DS check for this is after driver has been called to validate DS |
| 1567 | // internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1568 | // Create a valid cmd buffer |
| 1569 | // call vkCmdBindPipeline w/ false Pipeline |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1570 | // |
| 1571 | // m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1572 | // "Attempt to bind Pipeline "); |
| 1573 | // |
| 1574 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1575 | // VkCommandBufferObj commandBuffer(m_device); |
| 1576 | // BeginCommandBuffer(); |
| 1577 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 1578 | // vkCmdBindPipeline(commandBuffer.GetBufferHandle(), |
| 1579 | // VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
| 1580 | // |
| 1581 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 1582 | // FAIL() << "Did not receive Error 'Attempt to bind Pipeline |
| 1583 | // 0xbaadb1be that doesn't exist!'"; |
| 1584 | // m_errorMonitor->DumpFailureMsgs(); |
| 1585 | // } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1586 | } |
| 1587 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1588 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 1589 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 1590 | // CommandBuffer |
| 1591 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1592 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1593 | // TODO: verify that this matches layer |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 1594 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1595 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1596 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1597 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1598 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1599 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1600 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1601 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1602 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1603 | |
| 1604 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1605 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1606 | ds_pool_ci.pNext = NULL; |
| 1607 | ds_pool_ci.maxSets = 1; |
| 1608 | ds_pool_ci.poolSizeCount = 1; |
| 1609 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1610 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1611 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1612 | err = |
| 1613 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1614 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1615 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1616 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1617 | dsl_binding.binding = 0; |
| 1618 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1619 | dsl_binding.descriptorCount = 1; |
| 1620 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1621 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1622 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1623 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1624 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1625 | ds_layout_ci.pNext = NULL; |
| 1626 | ds_layout_ci.bindingCount = 1; |
| 1627 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1628 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1629 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1630 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1631 | ASSERT_VK_SUCCESS(err); |
| 1632 | |
| 1633 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1634 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1635 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1636 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1637 | alloc_info.descriptorPool = ds_pool; |
| 1638 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1639 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1640 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1641 | ASSERT_VK_SUCCESS(err); |
| 1642 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1643 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1644 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1645 | pipeline_layout_ci.pNext = NULL; |
| 1646 | pipeline_layout_ci.setLayoutCount = 1; |
| 1647 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1648 | |
| 1649 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1650 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1651 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1652 | ASSERT_VK_SUCCESS(err); |
| 1653 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1654 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 1655 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1656 | // TODO - We shouldn't need a fragment shader but add it to be able to run |
| 1657 | // on more devices |
| 1658 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 1659 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1660 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1661 | VkPipelineObj pipe(m_device); |
| 1662 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1663 | pipe.AddShader(&fs); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1664 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1665 | |
| 1666 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1667 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1668 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1669 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1670 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1671 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1672 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1673 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1674 | FAIL() << "Did not recieve Warning 'DS <blah> bound but it was never " |
| 1675 | "updated. You may want to either update it or not bind it.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1676 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1677 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1678 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1679 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1680 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1681 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1682 | } |
| 1683 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1684 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1685 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1686 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1687 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1688 | m_errorMonitor->SetDesiredFailureMsg( |
| 1689 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1690 | "Attempt to update descriptor with invalid bufferView "); |
| 1691 | |
| 1692 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1693 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1694 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1695 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1696 | |
| 1697 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1698 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1699 | ds_pool_ci.pNext = NULL; |
| 1700 | ds_pool_ci.maxSets = 1; |
| 1701 | ds_pool_ci.poolSizeCount = 1; |
| 1702 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1703 | |
| 1704 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1705 | err = |
| 1706 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1707 | ASSERT_VK_SUCCESS(err); |
| 1708 | |
| 1709 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1710 | dsl_binding.binding = 0; |
| 1711 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1712 | dsl_binding.descriptorCount = 1; |
| 1713 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1714 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1715 | |
| 1716 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1717 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1718 | ds_layout_ci.pNext = NULL; |
| 1719 | ds_layout_ci.bindingCount = 1; |
| 1720 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1721 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1722 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1723 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1724 | ASSERT_VK_SUCCESS(err); |
| 1725 | |
| 1726 | VkDescriptorSet descriptorSet; |
| 1727 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1728 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1729 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1730 | alloc_info.descriptorPool = ds_pool; |
| 1731 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1732 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1733 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1734 | ASSERT_VK_SUCCESS(err); |
| 1735 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1736 | VkBufferView view = |
| 1737 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1738 | VkWriteDescriptorSet descriptor_write; |
| 1739 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1740 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1741 | descriptor_write.dstSet = descriptorSet; |
| 1742 | descriptor_write.dstBinding = 0; |
| 1743 | descriptor_write.descriptorCount = 1; |
| 1744 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1745 | descriptor_write.pTexelBufferView = &view; |
| 1746 | |
| 1747 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1748 | |
| 1749 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1750 | FAIL() << "Did not receive Error 'Attempt to update descriptor with " |
| 1751 | "invalid bufferView'"; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1752 | m_errorMonitor->DumpFailureMsgs(); |
| 1753 | } |
| 1754 | |
| 1755 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1756 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1757 | } |
| 1758 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1759 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 1760 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 1761 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1762 | // 1. No dynamicOffset supplied |
| 1763 | // 2. Too many dynamicOffsets supplied |
| 1764 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1765 | VkResult err; |
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 | " requires 1 dynamicOffsets, but only " |
| 1768 | "0 dynamicOffsets are left in " |
| 1769 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1770 | |
| 1771 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1772 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1773 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1774 | |
| 1775 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1776 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1777 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1778 | |
| 1779 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1780 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1781 | ds_pool_ci.pNext = NULL; |
| 1782 | ds_pool_ci.maxSets = 1; |
| 1783 | ds_pool_ci.poolSizeCount = 1; |
| 1784 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1785 | |
| 1786 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1787 | err = |
| 1788 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1789 | ASSERT_VK_SUCCESS(err); |
| 1790 | |
| 1791 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1792 | dsl_binding.binding = 0; |
| 1793 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1794 | dsl_binding.descriptorCount = 1; |
| 1795 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1796 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1797 | |
| 1798 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1799 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1800 | ds_layout_ci.pNext = NULL; |
| 1801 | ds_layout_ci.bindingCount = 1; |
| 1802 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1803 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1804 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1805 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1806 | ASSERT_VK_SUCCESS(err); |
| 1807 | |
| 1808 | VkDescriptorSet descriptorSet; |
| 1809 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1810 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1811 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1812 | alloc_info.descriptorPool = ds_pool; |
| 1813 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1814 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1815 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1816 | ASSERT_VK_SUCCESS(err); |
| 1817 | |
| 1818 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1819 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1820 | pipeline_layout_ci.pNext = NULL; |
| 1821 | pipeline_layout_ci.setLayoutCount = 1; |
| 1822 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1823 | |
| 1824 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1825 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1826 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1827 | ASSERT_VK_SUCCESS(err); |
| 1828 | |
| 1829 | // Create a buffer to update the descriptor with |
| 1830 | uint32_t qfi = 0; |
| 1831 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1832 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1833 | buffCI.size = 1024; |
| 1834 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1835 | buffCI.queueFamilyIndexCount = 1; |
| 1836 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1837 | |
| 1838 | VkBuffer dyub; |
| 1839 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 1840 | ASSERT_VK_SUCCESS(err); |
| 1841 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 1842 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1843 | buffInfo.buffer = dyub; |
| 1844 | buffInfo.offset = 0; |
| 1845 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1846 | |
| 1847 | VkWriteDescriptorSet descriptor_write; |
| 1848 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1849 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1850 | descriptor_write.dstSet = descriptorSet; |
| 1851 | descriptor_write.dstBinding = 0; |
| 1852 | descriptor_write.descriptorCount = 1; |
| 1853 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1854 | descriptor_write.pBufferInfo = &buffInfo; |
| 1855 | |
| 1856 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1857 | |
| 1858 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1859 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1860 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1861 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1862 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1863 | FAIL() << "Error received was not 'descriptorSet #0 (0x<ADDR>) " |
| 1864 | "requires 1 dynamicOffsets, but only 0 dynamicOffsets are " |
| 1865 | "left in pDynamicOffsets array...'"; |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1866 | m_errorMonitor->DumpFailureMsgs(); |
| 1867 | } |
| 1868 | uint32_t pDynOff[2] = {512, 756}; |
| 1869 | // 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] | 1870 | m_errorMonitor->SetDesiredFailureMsg( |
| 1871 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1872 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1873 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1874 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1875 | 1, &descriptorSet, 2, pDynOff); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1876 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1877 | FAIL() << "Error received was not 'Attempting to bind 1 descriptorSets " |
| 1878 | "with 1 dynamic descriptors, but dynamicOffsetCount is 0...'"; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1879 | m_errorMonitor->DumpFailureMsgs(); |
| 1880 | } |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1881 | // Finally cause error due to dynamicOffset being too big |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1882 | m_errorMonitor->SetDesiredFailureMsg( |
| 1883 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1884 | " from its update, this oversteps its buffer ("); |
| 1885 | // Create PSO to be used for draw-time errors below |
| 1886 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1887 | "#version 400\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1888 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 1889 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 1890 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1891 | "out gl_PerVertex { \n" |
| 1892 | " vec4 gl_Position;\n" |
| 1893 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1894 | "void main(){\n" |
| 1895 | " gl_Position = vec4(1);\n" |
| 1896 | "}\n"; |
| 1897 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1898 | "#version 400\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1899 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 1900 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 1901 | "\n" |
| 1902 | "layout(location=0) out vec4 x;\n" |
| 1903 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 1904 | "void main(){\n" |
| 1905 | " x = vec4(bar.y);\n" |
| 1906 | "}\n"; |
| 1907 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1908 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 1909 | VkPipelineObj pipe(m_device); |
| 1910 | pipe.AddShader(&vs); |
| 1911 | pipe.AddShader(&fs); |
| 1912 | pipe.AddColorAttachment(); |
| 1913 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 1914 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1915 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1916 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1917 | // This update should succeed, but offset size of 512 will overstep buffer |
| 1918 | // /w range 1024 & size 1024 |
| 1919 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1920 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1921 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1922 | Draw(1, 0, 0, 0); |
| 1923 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1924 | FAIL() << "Error received was not 'VkDescriptorSet (0x<ADDR>) bound as " |
| 1925 | "set #0 has dynamic offset 512. Combined with offet 0 and " |
| 1926 | "range 1024 from its update, this oversteps...'"; |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1927 | m_errorMonitor->DumpFailureMsgs(); |
| 1928 | } |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1929 | |
| 1930 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1931 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1932 | } |
| 1933 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 1934 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 1935 | // Hit push constant error cases: |
| 1936 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 1937 | // 2. Incorrectly set push constant size to 0 |
| 1938 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 1939 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 1940 | VkResult err; |
| 1941 | m_errorMonitor->SetDesiredFailureMsg( |
| 1942 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1943 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 1944 | |
| 1945 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1946 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1947 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1948 | |
| 1949 | VkPushConstantRange pc_range = {}; |
| 1950 | pc_range.size = 0xFFFFFFFFu; |
| 1951 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 1952 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1953 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1954 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 1955 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 1956 | |
| 1957 | VkPipelineLayout pipeline_layout; |
| 1958 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1959 | &pipeline_layout); |
| 1960 | |
| 1961 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1962 | FAIL() << "Error received was not 'vkCreatePipelineLayout() call has " |
| 1963 | "push constants with offset 0...'"; |
| 1964 | m_errorMonitor->DumpFailureMsgs(); |
| 1965 | } |
| 1966 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 1967 | pc_range.size = 0; |
| 1968 | m_errorMonitor->SetDesiredFailureMsg( |
| 1969 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1970 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 1971 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1972 | &pipeline_layout); |
| 1973 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1974 | FAIL() << "Error received was not 'vkCreatePipelineLayout() call has " |
| 1975 | "push constant index 0 with size 0...'"; |
| 1976 | m_errorMonitor->DumpFailureMsgs(); |
| 1977 | } |
| 1978 | pc_range.size = 1; |
| 1979 | m_errorMonitor->SetDesiredFailureMsg( |
| 1980 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1981 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 1982 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1983 | &pipeline_layout); |
| 1984 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1985 | FAIL() << "Error received was not 'vkCreatePipelineLayout() call has " |
| 1986 | "push constant index 0 with size 0...'"; |
| 1987 | m_errorMonitor->DumpFailureMsgs(); |
| 1988 | } |
| 1989 | // Cause error due to bad size in vkCmdPushConstants() call |
| 1990 | m_errorMonitor->SetDesiredFailureMsg( |
| 1991 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1992 | "vkCmdPushConstants() call has push constants with offset "); |
| 1993 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 1994 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 1995 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1996 | &pipeline_layout); |
| 1997 | ASSERT_VK_SUCCESS(err); |
| 1998 | BeginCommandBuffer(); |
| 1999 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 2000 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
| 2001 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2002 | FAIL() << "Error received was not 'vkCmdPushConstants() call has push " |
| 2003 | "constants with offset 0...'"; |
| 2004 | m_errorMonitor->DumpFailureMsgs(); |
| 2005 | } |
| 2006 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2007 | } |
| 2008 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2009 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2010 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2011 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2012 | |
| 2013 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2014 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2015 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2016 | |
| 2017 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 2018 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2019 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2020 | ds_type_count[0].descriptorCount = 10; |
| 2021 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 2022 | ds_type_count[1].descriptorCount = 2; |
| 2023 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 2024 | ds_type_count[2].descriptorCount = 2; |
| 2025 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2026 | ds_type_count[3].descriptorCount = 5; |
| 2027 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 2028 | // type |
| 2029 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 2030 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 2031 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2032 | |
| 2033 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2034 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2035 | ds_pool_ci.pNext = NULL; |
| 2036 | ds_pool_ci.maxSets = 5; |
| 2037 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 2038 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2039 | |
| 2040 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2041 | err = |
| 2042 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2043 | ASSERT_VK_SUCCESS(err); |
| 2044 | |
| 2045 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 2046 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2047 | dsl_binding[0].binding = 0; |
| 2048 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2049 | dsl_binding[0].descriptorCount = 5; |
| 2050 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 2051 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2052 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2053 | // Create layout identical to set0 layout but w/ different stageFlags |
| 2054 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2055 | dsl_fs_stage_only.binding = 0; |
| 2056 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2057 | dsl_fs_stage_only.descriptorCount = 5; |
| 2058 | dsl_fs_stage_only.stageFlags = |
| 2059 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 2060 | // bind time |
| 2061 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2062 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2063 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2064 | ds_layout_ci.pNext = NULL; |
| 2065 | ds_layout_ci.bindingCount = 1; |
| 2066 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2067 | static const uint32_t NUM_LAYOUTS = 4; |
| 2068 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2069 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2070 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 2071 | // layout for error case |
| 2072 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2073 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2074 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2075 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2076 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2077 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2078 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2079 | dsl_binding[0].binding = 0; |
| 2080 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2081 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2082 | dsl_binding[1].binding = 1; |
| 2083 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 2084 | dsl_binding[1].descriptorCount = 2; |
| 2085 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 2086 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2087 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2088 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2089 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2090 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2091 | ASSERT_VK_SUCCESS(err); |
| 2092 | dsl_binding[0].binding = 0; |
| 2093 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2094 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2095 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2096 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2097 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2098 | ASSERT_VK_SUCCESS(err); |
| 2099 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2100 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2101 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2102 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2103 | ASSERT_VK_SUCCESS(err); |
| 2104 | |
| 2105 | static const uint32_t NUM_SETS = 4; |
| 2106 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 2107 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2108 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2109 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2110 | alloc_info.descriptorPool = ds_pool; |
| 2111 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2112 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2113 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2114 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2115 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2116 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2117 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2118 | err = |
| 2119 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2120 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2121 | |
| 2122 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2123 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2124 | pipeline_layout_ci.pNext = NULL; |
| 2125 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 2126 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2127 | |
| 2128 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2129 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2130 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2131 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2132 | // Create pipelineLayout with only one setLayout |
| 2133 | pipeline_layout_ci.setLayoutCount = 1; |
| 2134 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2135 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2136 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2137 | ASSERT_VK_SUCCESS(err); |
| 2138 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 2139 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 2140 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2141 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2142 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2143 | ASSERT_VK_SUCCESS(err); |
| 2144 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 2145 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 2146 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2147 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2148 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2149 | ASSERT_VK_SUCCESS(err); |
| 2150 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 2151 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 2152 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2153 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2154 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2155 | ASSERT_VK_SUCCESS(err); |
| 2156 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 2157 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 2158 | pl_bad_s0[0] = ds_layout_fs_only; |
| 2159 | pl_bad_s0[1] = ds_layout[1]; |
| 2160 | pipeline_layout_ci.setLayoutCount = 2; |
| 2161 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 2162 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2163 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2164 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2165 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2166 | |
| 2167 | // Create a buffer to update the descriptor with |
| 2168 | uint32_t qfi = 0; |
| 2169 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2170 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2171 | buffCI.size = 1024; |
| 2172 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 2173 | buffCI.queueFamilyIndexCount = 1; |
| 2174 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2175 | |
| 2176 | VkBuffer dyub; |
| 2177 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 2178 | ASSERT_VK_SUCCESS(err); |
| 2179 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 2180 | static const uint32_t NUM_BUFFS = 5; |
| 2181 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2182 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2183 | buffInfo[i].buffer = dyub; |
| 2184 | buffInfo[i].offset = 0; |
| 2185 | buffInfo[i].range = 1024; |
| 2186 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2187 | VkImage image; |
| 2188 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2189 | const int32_t tex_width = 32; |
| 2190 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2191 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2192 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2193 | image_create_info.pNext = NULL; |
| 2194 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2195 | image_create_info.format = tex_format; |
| 2196 | image_create_info.extent.width = tex_width; |
| 2197 | image_create_info.extent.height = tex_height; |
| 2198 | image_create_info.extent.depth = 1; |
| 2199 | image_create_info.mipLevels = 1; |
| 2200 | image_create_info.arrayLayers = 1; |
| 2201 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2202 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2203 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2204 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2205 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 2206 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2208 | VkMemoryRequirements memReqs; |
| 2209 | VkDeviceMemory imageMem; |
| 2210 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2211 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2212 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2213 | memAlloc.pNext = NULL; |
| 2214 | memAlloc.allocationSize = 0; |
| 2215 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2216 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 2217 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2218 | pass = |
| 2219 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2220 | ASSERT_TRUE(pass); |
| 2221 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 2222 | ASSERT_VK_SUCCESS(err); |
| 2223 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 2224 | ASSERT_VK_SUCCESS(err); |
| 2225 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2226 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2227 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2228 | image_view_create_info.image = image; |
| 2229 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2230 | image_view_create_info.format = tex_format; |
| 2231 | image_view_create_info.subresourceRange.layerCount = 1; |
| 2232 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 2233 | image_view_create_info.subresourceRange.levelCount = 1; |
| 2234 | image_view_create_info.subresourceRange.aspectMask = |
| 2235 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2236 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2237 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2238 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 2239 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2240 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2241 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2242 | imageInfo[0].imageView = view; |
| 2243 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2244 | imageInfo[1].imageView = view; |
| 2245 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2246 | imageInfo[2].imageView = view; |
| 2247 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2248 | imageInfo[3].imageView = view; |
| 2249 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2250 | |
| 2251 | static const uint32_t NUM_SET_UPDATES = 3; |
| 2252 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 2253 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2254 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 2255 | descriptor_write[0].dstBinding = 0; |
| 2256 | descriptor_write[0].descriptorCount = 5; |
| 2257 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2258 | descriptor_write[0].pBufferInfo = buffInfo; |
| 2259 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2260 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 2261 | descriptor_write[1].dstBinding = 0; |
| 2262 | descriptor_write[1].descriptorCount = 2; |
| 2263 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 2264 | descriptor_write[1].pImageInfo = imageInfo; |
| 2265 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2266 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 2267 | descriptor_write[2].dstBinding = 1; |
| 2268 | descriptor_write[2].descriptorCount = 2; |
| 2269 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2270 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2271 | |
| 2272 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2273 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2274 | // Create PSO to be used for draw-time errors below |
| 2275 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2276 | "#version 400\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2277 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 2278 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 2279 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2280 | "out gl_PerVertex {\n" |
| 2281 | " vec4 gl_Position;\n" |
| 2282 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2283 | "void main(){\n" |
| 2284 | " gl_Position = vec4(1);\n" |
| 2285 | "}\n"; |
| 2286 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2287 | "#version 400\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2288 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 2289 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 2290 | "\n" |
| 2291 | "layout(location=0) out vec4 x;\n" |
| 2292 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 2293 | "void main(){\n" |
| 2294 | " x = vec4(bar.y);\n" |
| 2295 | "}\n"; |
| 2296 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2297 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2298 | VkPipelineObj pipe(m_device); |
| 2299 | pipe.AddShader(&vs); |
| 2300 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2301 | pipe.AddColorAttachment(); |
| 2302 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2303 | |
| 2304 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2305 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2306 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2307 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2308 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 2309 | // of PSO |
| 2310 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 2311 | // cmd_pipeline.c |
| 2312 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 2313 | // cmd_bind_graphics_pipeline() |
| 2314 | // TODO : Want to cause various binding incompatibility issues here to test |
| 2315 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2316 | // First cause various verify_layout_compatibility() fails |
| 2317 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2318 | // verify_set_layout_compatibility fail cases: |
| 2319 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2320 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2321 | " due to: invalid VkPipelineLayout "); |
| 2322 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2323 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2324 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 2325 | &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2326 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2327 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2328 | "descriptorSets with invalid VkPipelineLayout."; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2329 | m_errorMonitor->DumpFailureMsgs(); |
| 2330 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2331 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2332 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2333 | " attempting to bind set to index 1"); |
| 2334 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2335 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 2336 | 0, 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2337 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2338 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2339 | "descriptorSet to index 1 when pipelineLayout only has index " |
| 2340 | "0."; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2341 | m_errorMonitor->DumpFailureMsgs(); |
| 2342 | } |
| 2343 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2344 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 2345 | // descriptors |
| 2346 | m_errorMonitor->SetDesiredFailureMsg( |
| 2347 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2348 | ", but corresponding set being bound has 5 descriptors."); |
| 2349 | vkCmdBindDescriptorSets( |
| 2350 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2351 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2352 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2353 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2354 | "descriptorSet w/ 5 descriptors to pipelineLayout with only " |
| 2355 | "2 descriptors."; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2356 | m_errorMonitor->DumpFailureMsgs(); |
| 2357 | } |
| 2358 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 2359 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2360 | m_errorMonitor->SetDesiredFailureMsg( |
| 2361 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2362 | " descriptor from pipelineLayout is type 'VK_DESCRIPTOR_TYPE_SAMPLER'"); |
| 2363 | vkCmdBindDescriptorSets( |
| 2364 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2365 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2366 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2367 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2368 | "UNIFORM_BUFFER descriptorSet to pipelineLayout with " |
| 2369 | "overlapping SAMPLER type."; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2370 | m_errorMonitor->DumpFailureMsgs(); |
| 2371 | } |
| 2372 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 2373 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2374 | m_errorMonitor->SetDesiredFailureMsg( |
| 2375 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2376 | " descriptor from pipelineLayout has stageFlags "); |
| 2377 | vkCmdBindDescriptorSets( |
| 2378 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2379 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2380 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2381 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2382 | "UNIFORM_BUFFER descriptorSet with ALL stageFlags to " |
| 2383 | "pipelineLayout with FS-only stageFlags."; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2384 | m_errorMonitor->DumpFailureMsgs(); |
| 2385 | } |
| 2386 | // Cause INFO messages due to disturbing previously bound Sets |
| 2387 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2388 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2389 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2390 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2391 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2392 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2393 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2394 | " previously bound as set #0 was disturbed "); |
| 2395 | vkCmdBindDescriptorSets( |
| 2396 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2397 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2398 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2399 | FAIL() << "Did not receive correct info msg when binding Set1 w/ " |
| 2400 | "pipelineLayout that should disturb Set0."; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2401 | m_errorMonitor->DumpFailureMsgs(); |
| 2402 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2403 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2404 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2405 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2406 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2407 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2408 | " newly bound as set #0 so set #1 and " |
| 2409 | "any subsequent sets were disturbed "); |
| 2410 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2411 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2412 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2413 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2414 | FAIL() << "Did not receive correct info msg when re-binding Set0 w/ " |
| 2415 | "pipelineLayout that should disturb Set1."; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2416 | m_errorMonitor->DumpFailureMsgs(); |
| 2417 | } |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2418 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2419 | // 1. Error due to not binding required set (we actually use same code as |
| 2420 | // above to disturb set0) |
| 2421 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2422 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2423 | 2, &descriptorSet[0], 0, NULL); |
| 2424 | vkCmdBindDescriptorSets( |
| 2425 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2426 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 2427 | m_errorMonitor->SetDesiredFailureMsg( |
| 2428 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2429 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2430 | Draw(1, 0, 0, 0); |
| 2431 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2432 | FAIL() << "Did not receive correct error msg when attempting draw " |
| 2433 | "requiring Set0 but Set0 is not bound."; |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2434 | m_errorMonitor->DumpFailureMsgs(); |
| 2435 | } |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2436 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2437 | // 2. Error due to bound set not being compatible with PSO's |
| 2438 | // VkPipelineLayout (diff stageFlags in this case) |
| 2439 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2440 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2441 | 2, &descriptorSet[0], 0, NULL); |
| 2442 | m_errorMonitor->SetDesiredFailureMsg( |
| 2443 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2444 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2445 | Draw(1, 0, 0, 0); |
| 2446 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2447 | FAIL() << "Did not receive correct error msg when attempted draw where " |
| 2448 | "bound Set0 layout is not compatible PSO Set0 layout."; |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2449 | m_errorMonitor->DumpFailureMsgs(); |
| 2450 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2451 | // Remaining clean-up |
| 2452 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2453 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2454 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 2455 | } |
| 2456 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
| 2457 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, descriptorSet); |
| 2458 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2459 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2460 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2461 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2462 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2463 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2464 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2465 | m_errorMonitor->SetDesiredFailureMsg( |
| 2466 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2467 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2468 | |
| 2469 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2470 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2471 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2472 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2473 | |
| 2474 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2475 | FAIL() << "Did not recieve Error 'You must call vkBeginCommandBuffer() " |
| 2476 | "before this call to vkEndCommandBuffer()'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2477 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2478 | } |
| 2479 | } |
| 2480 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2481 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 2482 | VkResult err; |
| 2483 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2484 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2485 | m_errorMonitor->SetDesiredFailureMsg( |
| 2486 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 2487 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2488 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2489 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2490 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2491 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2492 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2493 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2494 | cmd.commandPool = m_commandPool; |
| 2495 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2496 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2497 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2498 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2499 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2500 | |
| 2501 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2502 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2503 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2504 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2505 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2506 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 2507 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2508 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2509 | |
| 2510 | // The error should be caught by validation of the BeginCommandBuffer call |
| 2511 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 2512 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2513 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2514 | FAIL() << "Did not receive Error 'vkBeginCommandBuffer(): Secondary " |
| 2515 | "Command Buffers (0x<ADDR>) must specify a valid renderpass " |
| 2516 | "parameter.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2517 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2518 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2519 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2520 | } |
| 2521 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2522 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2523 | // Cause error due to Begin while recording CB |
| 2524 | // Then cause 2 errors for attempting to reset CB w/o having |
| 2525 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 2526 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2527 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2528 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2529 | |
| 2530 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2531 | |
| 2532 | // Calls AllocateCommandBuffers |
| 2533 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 2534 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2535 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 2536 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2537 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2538 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2539 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2540 | cmd_buf_info.pNext = NULL; |
| 2541 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2542 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2543 | |
| 2544 | // Begin CB to transition to recording state |
| 2545 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2546 | // Can't re-begin. This should trigger error |
| 2547 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2548 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2549 | FAIL() << "Did not receive Error 'Cannot call Begin on CB (0x<ADDR>) " |
| 2550 | "in the RECORDING state...'"; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2551 | m_errorMonitor->DumpFailureMsgs(); |
| 2552 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2553 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2554 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2555 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 2556 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 2557 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
| 2558 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2559 | FAIL() << "Did not receive Error 'Attempt to reset command buffer " |
| 2560 | "(0x<ADDR>) created from command pool...'"; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2561 | m_errorMonitor->DumpFailureMsgs(); |
| 2562 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2563 | m_errorMonitor->SetDesiredFailureMsg( |
| 2564 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2565 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2566 | // Transition CB to RECORDED state |
| 2567 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 2568 | // Now attempting to Begin will implicitly reset, which triggers error |
| 2569 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2570 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2571 | FAIL() << "Did not receive Error 'Call to vkBeginCommandBuffer() on " |
| 2572 | "command buffer (0x<ADDR>) attempts to implicitly reset...'"; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2573 | m_errorMonitor->DumpFailureMsgs(); |
| 2574 | } |
| 2575 | } |
| 2576 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2577 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2578 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2579 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2580 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2581 | m_errorMonitor->SetDesiredFailureMsg( |
| 2582 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2583 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 2584 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2585 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2586 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2587 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2588 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2589 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2590 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2591 | |
| 2592 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2593 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2594 | ds_pool_ci.pNext = NULL; |
| 2595 | ds_pool_ci.maxSets = 1; |
| 2596 | ds_pool_ci.poolSizeCount = 1; |
| 2597 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2598 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2599 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2600 | err = |
| 2601 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2602 | ASSERT_VK_SUCCESS(err); |
| 2603 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2604 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2605 | dsl_binding.binding = 0; |
| 2606 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2607 | dsl_binding.descriptorCount = 1; |
| 2608 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2609 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2610 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2611 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2612 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2613 | ds_layout_ci.pNext = NULL; |
| 2614 | ds_layout_ci.bindingCount = 1; |
| 2615 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2616 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2617 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2618 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2619 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2620 | ASSERT_VK_SUCCESS(err); |
| 2621 | |
| 2622 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2623 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2624 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2625 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2626 | alloc_info.descriptorPool = ds_pool; |
| 2627 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2628 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2629 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2630 | ASSERT_VK_SUCCESS(err); |
| 2631 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2632 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2633 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2634 | pipeline_layout_ci.setLayoutCount = 1; |
| 2635 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2636 | |
| 2637 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2638 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2639 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2640 | ASSERT_VK_SUCCESS(err); |
| 2641 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2642 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2643 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2644 | |
| 2645 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2646 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2647 | vp_state_ci.scissorCount = 1; |
| 2648 | vp_state_ci.pScissors = ≻ |
| 2649 | vp_state_ci.viewportCount = 1; |
| 2650 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2651 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2652 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 2653 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 2654 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 2655 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 2656 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 2657 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 2658 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 2659 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 2660 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2661 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2662 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2663 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2664 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2665 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2666 | gp_ci.layout = pipeline_layout; |
| 2667 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2668 | |
| 2669 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2670 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2671 | pc_ci.initialDataSize = 0; |
| 2672 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2673 | |
| 2674 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2675 | VkPipelineCache pipelineCache; |
| 2676 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2677 | err = |
| 2678 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2679 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2680 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2681 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2682 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2683 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2684 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: " |
| 2685 | "Vtx Shader required'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2686 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2687 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2688 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2689 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2690 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2691 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2692 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2693 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2694 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 2695 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 2696 | { |
| 2697 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2698 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2699 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2700 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2701 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 2702 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2703 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2704 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2705 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2706 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2707 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2708 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2709 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2710 | |
| 2711 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2712 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2713 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2714 | ds_pool_ci.poolSizeCount = 1; |
| 2715 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2716 | |
| 2717 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2718 | err = vkCreateDescriptorPool(m_device->device(), |
| 2719 | 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] | 2720 | ASSERT_VK_SUCCESS(err); |
| 2721 | |
| 2722 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2723 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2724 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2725 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2726 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2727 | dsl_binding.pImmutableSamplers = NULL; |
| 2728 | |
| 2729 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2730 | ds_layout_ci.sType = |
| 2731 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2732 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2733 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2734 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2735 | |
| 2736 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2737 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2738 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2739 | ASSERT_VK_SUCCESS(err); |
| 2740 | |
| 2741 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2742 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 2743 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2744 | ASSERT_VK_SUCCESS(err); |
| 2745 | |
| 2746 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2747 | pipeline_layout_ci.sType = |
| 2748 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2749 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2750 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2751 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2752 | |
| 2753 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2754 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2755 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2756 | ASSERT_VK_SUCCESS(err); |
| 2757 | |
| 2758 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 2759 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 2760 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2761 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 2762 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2763 | // 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] | 2764 | VkShaderObj |
| 2765 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 2766 | this); |
| 2767 | VkShaderObj |
| 2768 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 2769 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2770 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2771 | shaderStages[0].sType = |
| 2772 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2773 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2774 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2775 | shaderStages[1].sType = |
| 2776 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2777 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2778 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2779 | shaderStages[2].sType = |
| 2780 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2781 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2782 | shaderStages[2].shader = te.handle(); |
| 2783 | |
| 2784 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2785 | iaCI.sType = |
| 2786 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2787 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2788 | |
| 2789 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 2790 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 2791 | tsCI.patchControlPoints = 0; // This will cause an error |
| 2792 | |
| 2793 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2794 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2795 | gp_ci.pNext = NULL; |
| 2796 | gp_ci.stageCount = 3; |
| 2797 | gp_ci.pStages = shaderStages; |
| 2798 | gp_ci.pVertexInputState = NULL; |
| 2799 | gp_ci.pInputAssemblyState = &iaCI; |
| 2800 | gp_ci.pTessellationState = &tsCI; |
| 2801 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2802 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2803 | gp_ci.pMultisampleState = NULL; |
| 2804 | gp_ci.pDepthStencilState = NULL; |
| 2805 | gp_ci.pColorBlendState = NULL; |
| 2806 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2807 | gp_ci.layout = pipeline_layout; |
| 2808 | gp_ci.renderPass = renderPass(); |
| 2809 | |
| 2810 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2811 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2812 | pc_ci.pNext = NULL; |
| 2813 | pc_ci.initialSize = 0; |
| 2814 | pc_ci.initialData = 0; |
| 2815 | pc_ci.maxSize = 0; |
| 2816 | |
| 2817 | VkPipeline pipeline; |
| 2818 | VkPipelineCache pipelineCache; |
| 2819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2820 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 2821 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2822 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2823 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2824 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2825 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2826 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2827 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: |
| 2828 | VK_PRIMITIVE_TOPOLOGY_PATCH primitive...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2829 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2830 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2831 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2832 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2833 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2834 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2835 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2836 | } |
| 2837 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2838 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2839 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2840 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2841 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2842 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2843 | m_errorMonitor->SetDesiredFailureMsg( |
| 2844 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2845 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2846 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2847 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2848 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2849 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2850 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2851 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2852 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2853 | |
| 2854 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2855 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2856 | ds_pool_ci.maxSets = 1; |
| 2857 | ds_pool_ci.poolSizeCount = 1; |
| 2858 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2859 | |
| 2860 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2861 | err = |
| 2862 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2863 | ASSERT_VK_SUCCESS(err); |
| 2864 | |
| 2865 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2866 | dsl_binding.binding = 0; |
| 2867 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2868 | dsl_binding.descriptorCount = 1; |
| 2869 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2870 | |
| 2871 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2872 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2873 | ds_layout_ci.bindingCount = 1; |
| 2874 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2875 | |
| 2876 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2877 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2878 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2879 | ASSERT_VK_SUCCESS(err); |
| 2880 | |
| 2881 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2882 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2883 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2884 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2885 | alloc_info.descriptorPool = ds_pool; |
| 2886 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2887 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2888 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2889 | ASSERT_VK_SUCCESS(err); |
| 2890 | |
| 2891 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2892 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2893 | pipeline_layout_ci.setLayoutCount = 1; |
| 2894 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2895 | |
| 2896 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2897 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2898 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2899 | ASSERT_VK_SUCCESS(err); |
| 2900 | |
| 2901 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2902 | |
| 2903 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2904 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2905 | vp_state_ci.scissorCount = 0; |
| 2906 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2907 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2908 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2909 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 2910 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 2911 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 2912 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 2913 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 2914 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 2915 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 2916 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 2917 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2918 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2919 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2920 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2921 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 2922 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2923 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 2924 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 2925 | this); // TODO - We shouldn't need a fragment shader |
| 2926 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2927 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2928 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2929 | |
| 2930 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2931 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2932 | gp_ci.stageCount = 2; |
| 2933 | gp_ci.pStages = shaderStages; |
| 2934 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2935 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2936 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2937 | gp_ci.layout = pipeline_layout; |
| 2938 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2939 | |
| 2940 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2941 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2942 | |
| 2943 | VkPipeline pipeline; |
| 2944 | VkPipelineCache pipelineCache; |
| 2945 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2946 | err = |
| 2947 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2948 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2949 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2950 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2951 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2952 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2953 | FAIL() << "Did not receive Error 'Gfx Pipeline viewport count (1) must " |
| 2954 | "match scissor count (0).'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2955 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2956 | } |
| 2957 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2958 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2959 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2960 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2961 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2962 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2963 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 2964 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2965 | // 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] | 2966 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2967 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2968 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2969 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2970 | m_errorMonitor->SetDesiredFailureMsg( |
| 2971 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2972 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2973 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2974 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2975 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2976 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2977 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2978 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2979 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2980 | |
| 2981 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2982 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2983 | ds_pool_ci.maxSets = 1; |
| 2984 | ds_pool_ci.poolSizeCount = 1; |
| 2985 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2986 | |
| 2987 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2988 | err = |
| 2989 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2990 | ASSERT_VK_SUCCESS(err); |
| 2991 | |
| 2992 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2993 | dsl_binding.binding = 0; |
| 2994 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2995 | dsl_binding.descriptorCount = 1; |
| 2996 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2997 | |
| 2998 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2999 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3000 | ds_layout_ci.bindingCount = 1; |
| 3001 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3002 | |
| 3003 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3004 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3005 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3006 | ASSERT_VK_SUCCESS(err); |
| 3007 | |
| 3008 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3009 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3010 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3011 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3012 | alloc_info.descriptorPool = ds_pool; |
| 3013 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3014 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3015 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3016 | ASSERT_VK_SUCCESS(err); |
| 3017 | |
| 3018 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3019 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3020 | pipeline_layout_ci.setLayoutCount = 1; |
| 3021 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3022 | |
| 3023 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3024 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3025 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3026 | ASSERT_VK_SUCCESS(err); |
| 3027 | |
| 3028 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 3029 | // Set scissor as dynamic to avoid second error |
| 3030 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3031 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3032 | dyn_state_ci.dynamicStateCount = 1; |
| 3033 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3034 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3035 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3036 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3037 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3038 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3039 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3040 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3041 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 3042 | this); // TODO - We shouldn't need a fragment shader |
| 3043 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3044 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3045 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3046 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3047 | |
| 3048 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 3049 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3050 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 3051 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 3052 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 3053 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 3054 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 3055 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 3056 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3057 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3058 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3059 | gp_ci.stageCount = 2; |
| 3060 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3061 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3062 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 3063 | // should cause validation error |
| 3064 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3065 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3066 | gp_ci.layout = pipeline_layout; |
| 3067 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3068 | |
| 3069 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3070 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3071 | |
| 3072 | VkPipeline pipeline; |
| 3073 | VkPipelineCache pipelineCache; |
| 3074 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3075 | err = |
| 3076 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3077 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3078 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3079 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3080 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3081 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3082 | FAIL() << "Did not receive Error 'Gfx Pipeline pViewportState is null. " |
| 3083 | "Even if...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3084 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3085 | } |
| 3086 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3087 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3088 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3089 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3090 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3091 | } |
| 3092 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3093 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 3094 | // count |
| 3095 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 3096 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3097 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3098 | m_errorMonitor->SetDesiredFailureMsg( |
| 3099 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3100 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 3101 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3102 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3103 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3104 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3105 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3106 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3107 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3108 | |
| 3109 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3110 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3111 | ds_pool_ci.maxSets = 1; |
| 3112 | ds_pool_ci.poolSizeCount = 1; |
| 3113 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3114 | |
| 3115 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3116 | err = |
| 3117 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3118 | ASSERT_VK_SUCCESS(err); |
| 3119 | |
| 3120 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3121 | dsl_binding.binding = 0; |
| 3122 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3123 | dsl_binding.descriptorCount = 1; |
| 3124 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3125 | |
| 3126 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3127 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3128 | ds_layout_ci.bindingCount = 1; |
| 3129 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3130 | |
| 3131 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3132 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3133 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3134 | ASSERT_VK_SUCCESS(err); |
| 3135 | |
| 3136 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3137 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3138 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3139 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3140 | alloc_info.descriptorPool = ds_pool; |
| 3141 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3142 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3143 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3144 | ASSERT_VK_SUCCESS(err); |
| 3145 | |
| 3146 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3147 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3148 | pipeline_layout_ci.setLayoutCount = 1; |
| 3149 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3150 | |
| 3151 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3152 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3153 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3154 | ASSERT_VK_SUCCESS(err); |
| 3155 | |
| 3156 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3157 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3158 | vp_state_ci.viewportCount = 1; |
| 3159 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 3160 | vp_state_ci.scissorCount = 1; |
| 3161 | vp_state_ci.pScissors = |
| 3162 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3163 | |
| 3164 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 3165 | // Set scissor as dynamic to avoid that error |
| 3166 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3167 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3168 | dyn_state_ci.dynamicStateCount = 1; |
| 3169 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3170 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3171 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3172 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3174 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3175 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3176 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3177 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 3178 | this); // TODO - We shouldn't need a fragment shader |
| 3179 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3180 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3181 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3182 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3183 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 3184 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 3185 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3186 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3187 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3188 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3189 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 3190 | |
| 3191 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 3192 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 3193 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 3194 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3195 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3196 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3197 | rs_ci.pNext = nullptr; |
| 3198 | |
| 3199 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 3200 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 3201 | cb_ci.pNext = nullptr; |
| 3202 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3203 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3204 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3205 | gp_ci.stageCount = 2; |
| 3206 | gp_ci.pStages = shaderStages; |
| 3207 | gp_ci.pVertexInputState = &vi_ci; |
| 3208 | gp_ci.pInputAssemblyState = &ia_ci; |
| 3209 | gp_ci.pViewportState = &vp_state_ci; |
| 3210 | gp_ci.pRasterizationState = &rs_ci; |
| 3211 | gp_ci.pColorBlendState = &cb_ci; |
| 3212 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3213 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3214 | gp_ci.layout = pipeline_layout; |
| 3215 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3216 | |
| 3217 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3218 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3219 | |
| 3220 | VkPipeline pipeline; |
| 3221 | VkPipelineCache pipelineCache; |
| 3222 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3223 | err = |
| 3224 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3225 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3226 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3227 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3228 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3229 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3230 | FAIL() << "Did not recieve Error 'Gfx Pipeline viewportCount is 1, but " |
| 3231 | "pViewports is NULL...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3232 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3233 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3234 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3235 | // 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] | 3236 | // First need to successfully create the PSO from above by setting |
| 3237 | // pViewports |
| 3238 | m_errorMonitor->SetDesiredFailureMsg( |
| 3239 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3240 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 3241 | "scissorCount is 1. These counts must match."); |
| 3242 | |
| 3243 | VkViewport vp = {}; // Just need dummy vp to point to |
| 3244 | vp_state_ci.pViewports = &vp; |
| 3245 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3246 | &gp_ci, NULL, &pipeline); |
| 3247 | ASSERT_VK_SUCCESS(err); |
| 3248 | BeginCommandBuffer(); |
| 3249 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3250 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 3251 | VkRect2D scissors[2] = {}; // don't care about data |
| 3252 | // Count of 2 doesn't match PSO count of 1 |
| 3253 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 3254 | Draw(1, 0, 0, 0); |
| 3255 | |
| 3256 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3257 | FAIL() << "Did not receive Error 'Dynamic scissorCount from " |
| 3258 | "vkCmdSetScissor() is 2, but PSO scissorCount is 1...'"; |
| 3259 | m_errorMonitor->DumpFailureMsgs(); |
| 3260 | } |
| 3261 | |
| 3262 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3263 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3264 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3265 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3266 | } |
| 3267 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 3268 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 3269 | // viewportCount |
| 3270 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 3271 | VkResult err; |
| 3272 | |
| 3273 | m_errorMonitor->SetDesiredFailureMsg( |
| 3274 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3275 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 3276 | |
| 3277 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3278 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3279 | |
| 3280 | VkDescriptorPoolSize ds_type_count = {}; |
| 3281 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3282 | ds_type_count.descriptorCount = 1; |
| 3283 | |
| 3284 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3285 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3286 | ds_pool_ci.maxSets = 1; |
| 3287 | ds_pool_ci.poolSizeCount = 1; |
| 3288 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 3289 | |
| 3290 | VkDescriptorPool ds_pool; |
| 3291 | err = |
| 3292 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 3293 | ASSERT_VK_SUCCESS(err); |
| 3294 | |
| 3295 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3296 | dsl_binding.binding = 0; |
| 3297 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3298 | dsl_binding.descriptorCount = 1; |
| 3299 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3300 | |
| 3301 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3302 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3303 | ds_layout_ci.bindingCount = 1; |
| 3304 | ds_layout_ci.pBindings = &dsl_binding; |
| 3305 | |
| 3306 | VkDescriptorSetLayout ds_layout; |
| 3307 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3308 | &ds_layout); |
| 3309 | ASSERT_VK_SUCCESS(err); |
| 3310 | |
| 3311 | VkDescriptorSet descriptorSet; |
| 3312 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 3313 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 3314 | alloc_info.descriptorSetCount = 1; |
| 3315 | alloc_info.descriptorPool = ds_pool; |
| 3316 | alloc_info.pSetLayouts = &ds_layout; |
| 3317 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3318 | &descriptorSet); |
| 3319 | ASSERT_VK_SUCCESS(err); |
| 3320 | |
| 3321 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3322 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3323 | pipeline_layout_ci.setLayoutCount = 1; |
| 3324 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3325 | |
| 3326 | VkPipelineLayout pipeline_layout; |
| 3327 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3328 | &pipeline_layout); |
| 3329 | ASSERT_VK_SUCCESS(err); |
| 3330 | |
| 3331 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 3332 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3333 | vp_state_ci.scissorCount = 1; |
| 3334 | vp_state_ci.pScissors = |
| 3335 | NULL; // Null scissor w/ count of 1 should cause error |
| 3336 | vp_state_ci.viewportCount = 1; |
| 3337 | vp_state_ci.pViewports = |
| 3338 | NULL; // vp is dynamic (below) so this won't cause error |
| 3339 | |
| 3340 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 3341 | // Set scissor as dynamic to avoid that error |
| 3342 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 3343 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3344 | dyn_state_ci.dynamicStateCount = 1; |
| 3345 | dyn_state_ci.pDynamicStates = &vp_state; |
| 3346 | |
| 3347 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 3348 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 3349 | |
| 3350 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3351 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3352 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3353 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 3354 | this); // TODO - We shouldn't need a fragment shader |
| 3355 | // but add it to be able to run on more devices |
| 3356 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3357 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 3358 | |
| 3359 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 3360 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 3361 | vi_ci.pNext = nullptr; |
| 3362 | vi_ci.vertexBindingDescriptionCount = 0; |
| 3363 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 3364 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 3365 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 3366 | |
| 3367 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 3368 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 3369 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 3370 | |
| 3371 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 3372 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3373 | rs_ci.pNext = nullptr; |
| 3374 | |
| 3375 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 3376 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 3377 | cb_ci.pNext = nullptr; |
| 3378 | |
| 3379 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 3380 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3381 | gp_ci.stageCount = 2; |
| 3382 | gp_ci.pStages = shaderStages; |
| 3383 | gp_ci.pVertexInputState = &vi_ci; |
| 3384 | gp_ci.pInputAssemblyState = &ia_ci; |
| 3385 | gp_ci.pViewportState = &vp_state_ci; |
| 3386 | gp_ci.pRasterizationState = &rs_ci; |
| 3387 | gp_ci.pColorBlendState = &cb_ci; |
| 3388 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3389 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3390 | gp_ci.layout = pipeline_layout; |
| 3391 | gp_ci.renderPass = renderPass(); |
| 3392 | |
| 3393 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 3394 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3395 | |
| 3396 | VkPipeline pipeline; |
| 3397 | VkPipelineCache pipelineCache; |
| 3398 | |
| 3399 | err = |
| 3400 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 3401 | ASSERT_VK_SUCCESS(err); |
| 3402 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3403 | &gp_ci, NULL, &pipeline); |
| 3404 | |
| 3405 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3406 | FAIL() << "Did not recieve Error 'Gfx Pipeline scissorCount is 1, but " |
| 3407 | "pScissors is NULL...'"; |
| 3408 | m_errorMonitor->DumpFailureMsgs(); |
| 3409 | } |
| 3410 | |
| 3411 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 3412 | // First need to successfully create the PSO from above by setting |
| 3413 | // pViewports |
| 3414 | m_errorMonitor->SetDesiredFailureMsg( |
| 3415 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3416 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 3417 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3418 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3419 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 3420 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3421 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3422 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3423 | ASSERT_VK_SUCCESS(err); |
| 3424 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3425 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3426 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3427 | VkViewport viewports[2] = {}; // don't care about data |
| 3428 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 3429 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3430 | Draw(1, 0, 0, 0); |
| 3431 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3432 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3433 | FAIL() << "Did not receive Error 'Dynamic viewportCount from " |
| 3434 | "vkCmdSetViewport() is 2, but PSO viewportCount is 1...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3435 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3436 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3437 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3438 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3439 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3440 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3441 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3442 | } |
| 3443 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3444 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3445 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3446 | m_errorMonitor->SetDesiredFailureMsg( |
| 3447 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3448 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3449 | |
| 3450 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3451 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3452 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3453 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3454 | // Don't care about RenderPass handle b/c error should be flagged before |
| 3455 | // that |
| 3456 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 3457 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3458 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3459 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3460 | FAIL() << "Did not receive Error 'You cannot use a NULL RenderPass " |
| 3461 | "object in vkCmdBeginRenderPass()'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3462 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3463 | } |
| 3464 | } |
| 3465 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3466 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3467 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3468 | m_errorMonitor->SetDesiredFailureMsg( |
| 3469 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3470 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3471 | |
| 3472 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3473 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3474 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3475 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3476 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 3477 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3478 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3479 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 3480 | rp_begin.pNext = NULL; |
| 3481 | rp_begin.renderPass = renderPass(); |
| 3482 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3483 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3484 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 3485 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3486 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3487 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3488 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3489 | "inside an active render pass...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3490 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3491 | } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3492 | } |
| 3493 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3494 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3495 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3496 | m_errorMonitor->SetDesiredFailureMsg( |
| 3497 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3498 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3499 | |
| 3500 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3501 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3502 | |
| 3503 | // Renderpass is started here |
| 3504 | BeginCommandBuffer(); |
| 3505 | |
| 3506 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3507 | vk_testing::Buffer dstBuffer; |
| 3508 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3509 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3510 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3511 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3512 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3513 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3514 | "inside an active render pass...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3515 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3516 | } |
| 3517 | } |
| 3518 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3519 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3520 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3521 | m_errorMonitor->SetDesiredFailureMsg( |
| 3522 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3523 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3524 | |
| 3525 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3526 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3527 | |
| 3528 | // Renderpass is started here |
| 3529 | BeginCommandBuffer(); |
| 3530 | |
| 3531 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3532 | vk_testing::Buffer dstBuffer; |
| 3533 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3534 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3535 | VkDeviceSize dstOffset = 0; |
| 3536 | VkDeviceSize dataSize = 1024; |
| 3537 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3538 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3539 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 3540 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3541 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3542 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3543 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3544 | "inside an active render pass...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3545 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3546 | } |
| 3547 | } |
| 3548 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3549 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3550 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3551 | m_errorMonitor->SetDesiredFailureMsg( |
| 3552 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3553 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3554 | |
| 3555 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3556 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3557 | |
| 3558 | // Renderpass is started here |
| 3559 | BeginCommandBuffer(); |
| 3560 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 3561 | VkClearColorValue clear_color; |
| 3562 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3563 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 3564 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3565 | const int32_t tex_width = 32; |
| 3566 | const int32_t tex_height = 32; |
| 3567 | VkImageCreateInfo image_create_info = {}; |
| 3568 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3569 | image_create_info.pNext = NULL; |
| 3570 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3571 | image_create_info.format = tex_format; |
| 3572 | image_create_info.extent.width = tex_width; |
| 3573 | image_create_info.extent.height = tex_height; |
| 3574 | image_create_info.extent.depth = 1; |
| 3575 | image_create_info.mipLevels = 1; |
| 3576 | image_create_info.arrayLayers = 1; |
| 3577 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3578 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3579 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3580 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3581 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3582 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 3583 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3584 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3585 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 3586 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3587 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3588 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 3589 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3590 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3591 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3592 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3593 | "inside an active render pass...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3594 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3595 | } |
| 3596 | } |
| 3597 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3598 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3599 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3600 | m_errorMonitor->SetDesiredFailureMsg( |
| 3601 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3602 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3603 | |
| 3604 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3605 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3606 | |
| 3607 | // Renderpass is started here |
| 3608 | BeginCommandBuffer(); |
| 3609 | |
| 3610 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 3611 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3612 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 3613 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3614 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3615 | image_create_info.extent.width = 64; |
| 3616 | image_create_info.extent.height = 64; |
| 3617 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3618 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3619 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3620 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3621 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 3622 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3623 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3624 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 3625 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3626 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3627 | vkCmdClearDepthStencilImage( |
| 3628 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 3629 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 3630 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3631 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3632 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3633 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3634 | "inside an active render pass...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3635 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3636 | } |
| 3637 | } |
| 3638 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3639 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3640 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3641 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3642 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3643 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3644 | "vkCmdClearAttachments: This call " |
| 3645 | "must be issued inside an active " |
| 3646 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3647 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3648 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3649 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3650 | |
| 3651 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3652 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3653 | ASSERT_VK_SUCCESS(err); |
| 3654 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3655 | VkClearAttachment color_attachment; |
| 3656 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3657 | color_attachment.clearValue.color.float32[0] = 0; |
| 3658 | color_attachment.clearValue.color.float32[1] = 0; |
| 3659 | color_attachment.clearValue.color.float32[2] = 0; |
| 3660 | color_attachment.clearValue.color.float32[3] = 0; |
| 3661 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3662 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 3663 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 3664 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3665 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3666 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3667 | FAIL() << "Did not receive Error 'vkCmdClearAttachments: This call " |
| 3668 | "must be issued inside an active render pass.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3669 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3670 | } |
| 3671 | } |
| 3672 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3673 | TEST_F(VkLayerTest, InvalidDynamicStateObject) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3674 | // Create a valid cmd buffer |
| 3675 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3676 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 3677 | // catch this case |
| 3678 | // The DS check for this is after driver has been called to validate DS |
| 3679 | // internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3680 | } |
Tobin Ehlis | 1056d45 | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 3681 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3682 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3683 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3684 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3685 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3686 | m_errorMonitor->SetDesiredFailureMsg( |
| 3687 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3688 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 3689 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3690 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3691 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3692 | uint32_t qfi = 0; |
| 3693 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3694 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3695 | buffCI.size = 1024; |
| 3696 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 3697 | buffCI.queueFamilyIndexCount = 1; |
| 3698 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3699 | |
| 3700 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3701 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3702 | ASSERT_VK_SUCCESS(err); |
| 3703 | |
| 3704 | BeginCommandBuffer(); |
| 3705 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3706 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3707 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3708 | // 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] | 3709 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 3710 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3711 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3712 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3713 | FAIL() << "Did not receive Error 'vkCmdBindIndexBuffer() offset (0x7) " |
| 3714 | "does not fall on ...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3715 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3716 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3717 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3718 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3719 | } |
| 3720 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3721 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 3722 | // Create an out-of-range queueFamilyIndex |
| 3723 | m_errorMonitor->SetDesiredFailureMsg( |
| 3724 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 3725 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3726 | |
| 3727 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3728 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3729 | VkBufferCreateInfo buffCI = {}; |
| 3730 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3731 | buffCI.size = 1024; |
| 3732 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 3733 | buffCI.queueFamilyIndexCount = 1; |
| 3734 | // Introduce failure by specifying invalid queue_family_index |
| 3735 | uint32_t qfi = 777; |
| 3736 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 3737 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3738 | |
| 3739 | VkBuffer ib; |
| 3740 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 3741 | |
| 3742 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 3743 | FAIL() << "Did not receive Error 'queueFamilyIndex %d, must have " |
| 3744 | "been given when the device was created.'"; |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3745 | m_errorMonitor->DumpFailureMsgs(); |
| 3746 | } |
| 3747 | } |
| 3748 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3749 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 3750 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 3751 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3752 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3753 | m_errorMonitor->SetDesiredFailureMsg( |
| 3754 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3755 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3756 | |
| 3757 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3758 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3759 | |
| 3760 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3761 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3762 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 3763 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3764 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3765 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3766 | FAIL() << "Did not receive Error 'vkCmdExecuteCommands() called w/ " |
| 3767 | "Primary Cmd Buffer '"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3768 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3769 | } |
| 3770 | } |
| 3771 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3772 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3773 | // 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] | 3774 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3775 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3776 | m_errorMonitor->SetDesiredFailureMsg( |
| 3777 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Write descriptor update has descriptor " |
| 3778 | "type VK_DESCRIPTOR_TYPE_SAMPLER that " |
| 3779 | "does not match "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3780 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3781 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3782 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3783 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3784 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3785 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3786 | |
| 3787 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3788 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3789 | ds_pool_ci.pNext = NULL; |
| 3790 | ds_pool_ci.maxSets = 1; |
| 3791 | ds_pool_ci.poolSizeCount = 1; |
| 3792 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3793 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3794 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3795 | err = |
| 3796 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3797 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3798 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3799 | dsl_binding.binding = 0; |
| 3800 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3801 | dsl_binding.descriptorCount = 1; |
| 3802 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3803 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3804 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3805 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3806 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3807 | ds_layout_ci.pNext = NULL; |
| 3808 | ds_layout_ci.bindingCount = 1; |
| 3809 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3810 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3811 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3812 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3813 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3814 | ASSERT_VK_SUCCESS(err); |
| 3815 | |
| 3816 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3817 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3818 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3819 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3820 | alloc_info.descriptorPool = ds_pool; |
| 3821 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3822 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3823 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3824 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3825 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3826 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3827 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3828 | sampler_ci.pNext = NULL; |
| 3829 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3830 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3831 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3832 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3833 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3834 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3835 | sampler_ci.mipLodBias = 1.0; |
| 3836 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3837 | sampler_ci.maxAnisotropy = 1; |
| 3838 | sampler_ci.compareEnable = VK_FALSE; |
| 3839 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3840 | sampler_ci.minLod = 1.0; |
| 3841 | sampler_ci.maxLod = 1.0; |
| 3842 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3843 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3844 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3845 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3846 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3847 | ASSERT_VK_SUCCESS(err); |
| 3848 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3849 | VkDescriptorImageInfo info = {}; |
| 3850 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3851 | |
| 3852 | VkWriteDescriptorSet descriptor_write; |
| 3853 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3854 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3855 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3856 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3857 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3858 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3859 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3860 | |
| 3861 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3862 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3863 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3864 | FAIL() << "Did not receive Error 'Write descriptor update has " |
| 3865 | "descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not " |
| 3866 | "match...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3867 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3868 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3869 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3870 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3871 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3872 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3873 | } |
| 3874 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3875 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3876 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3877 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3878 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3879 | m_errorMonitor->SetDesiredFailureMsg( |
| 3880 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Descriptor update type of " |
| 3881 | "VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET " |
| 3882 | "is out of bounds for matching binding"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3883 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3884 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3885 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3886 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3887 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3888 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3889 | |
| 3890 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3891 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3892 | ds_pool_ci.pNext = NULL; |
| 3893 | ds_pool_ci.maxSets = 1; |
| 3894 | ds_pool_ci.poolSizeCount = 1; |
| 3895 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3896 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3897 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3898 | err = |
| 3899 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3900 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3901 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3902 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3903 | dsl_binding.binding = 0; |
| 3904 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3905 | dsl_binding.descriptorCount = 1; |
| 3906 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3907 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3908 | |
| 3909 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3910 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3911 | ds_layout_ci.pNext = NULL; |
| 3912 | ds_layout_ci.bindingCount = 1; |
| 3913 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3914 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3915 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3916 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3917 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3918 | ASSERT_VK_SUCCESS(err); |
| 3919 | |
| 3920 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3921 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3922 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3923 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3924 | alloc_info.descriptorPool = ds_pool; |
| 3925 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3926 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3927 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3928 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3929 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3930 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3931 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3932 | sampler_ci.pNext = NULL; |
| 3933 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3934 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3935 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3936 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3937 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3938 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3939 | sampler_ci.mipLodBias = 1.0; |
| 3940 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3941 | sampler_ci.maxAnisotropy = 1; |
| 3942 | sampler_ci.compareEnable = VK_FALSE; |
| 3943 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3944 | sampler_ci.minLod = 1.0; |
| 3945 | sampler_ci.maxLod = 1.0; |
| 3946 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3947 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3948 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3949 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3950 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3951 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3952 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3953 | VkDescriptorImageInfo info = {}; |
| 3954 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3955 | |
| 3956 | VkWriteDescriptorSet descriptor_write; |
| 3957 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3958 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3959 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3960 | descriptor_write.dstArrayElement = |
| 3961 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3962 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3963 | // 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] | 3964 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3965 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3966 | |
| 3967 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3968 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3969 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3970 | FAIL() << "Did not receive Error 'Descriptor update type of " |
| 3971 | "VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for " |
| 3972 | "matching binding...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3973 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3974 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3975 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3976 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3977 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3978 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3979 | } |
| 3980 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3981 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 3982 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 3983 | // index 2 |
| 3984 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3985 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3986 | m_errorMonitor->SetDesiredFailureMsg( |
| 3987 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3988 | " does not have binding to match update binding "); |
| 3989 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3990 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3991 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3992 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3993 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3994 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3995 | |
| 3996 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3997 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3998 | ds_pool_ci.pNext = NULL; |
| 3999 | ds_pool_ci.maxSets = 1; |
| 4000 | ds_pool_ci.poolSizeCount = 1; |
| 4001 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4002 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4003 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4004 | err = |
| 4005 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4006 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4007 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4008 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4009 | dsl_binding.binding = 0; |
| 4010 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4011 | dsl_binding.descriptorCount = 1; |
| 4012 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4013 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4014 | |
| 4015 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4016 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4017 | ds_layout_ci.pNext = NULL; |
| 4018 | ds_layout_ci.bindingCount = 1; |
| 4019 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4020 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4021 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4022 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4023 | ASSERT_VK_SUCCESS(err); |
| 4024 | |
| 4025 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4026 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4027 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4028 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4029 | alloc_info.descriptorPool = ds_pool; |
| 4030 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4031 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4032 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4033 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4034 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4035 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4036 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4037 | sampler_ci.pNext = NULL; |
| 4038 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4039 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4040 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4041 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4042 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4043 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4044 | sampler_ci.mipLodBias = 1.0; |
| 4045 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4046 | sampler_ci.maxAnisotropy = 1; |
| 4047 | sampler_ci.compareEnable = VK_FALSE; |
| 4048 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4049 | sampler_ci.minLod = 1.0; |
| 4050 | sampler_ci.maxLod = 1.0; |
| 4051 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4052 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4053 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4054 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4055 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4056 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4057 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4058 | VkDescriptorImageInfo info = {}; |
| 4059 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4060 | |
| 4061 | VkWriteDescriptorSet descriptor_write; |
| 4062 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4063 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4064 | descriptor_write.dstSet = descriptorSet; |
| 4065 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4066 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4067 | // 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] | 4068 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4069 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4070 | |
| 4071 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4072 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4073 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4074 | FAIL() << "Did not receive Error 'Descriptor Set <blah> does not have " |
| 4075 | "binding to match update binding '"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4076 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4077 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4078 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4079 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4080 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4081 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4082 | } |
| 4083 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4084 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 4085 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 4086 | // types |
| 4087 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4088 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4089 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4090 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4091 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4092 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4093 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4094 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4095 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4096 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4097 | |
| 4098 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4099 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4100 | ds_pool_ci.pNext = NULL; |
| 4101 | ds_pool_ci.maxSets = 1; |
| 4102 | ds_pool_ci.poolSizeCount = 1; |
| 4103 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4104 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4105 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4106 | err = |
| 4107 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4108 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4109 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4110 | dsl_binding.binding = 0; |
| 4111 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4112 | dsl_binding.descriptorCount = 1; |
| 4113 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4114 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4115 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4116 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4117 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4118 | ds_layout_ci.pNext = NULL; |
| 4119 | ds_layout_ci.bindingCount = 1; |
| 4120 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4121 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4122 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4123 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4124 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4125 | ASSERT_VK_SUCCESS(err); |
| 4126 | |
| 4127 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4128 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4129 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4130 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4131 | alloc_info.descriptorPool = ds_pool; |
| 4132 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4133 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4134 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4135 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4136 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4137 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4138 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4139 | sampler_ci.pNext = NULL; |
| 4140 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4141 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4142 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4143 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4144 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4145 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4146 | sampler_ci.mipLodBias = 1.0; |
| 4147 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4148 | sampler_ci.maxAnisotropy = 1; |
| 4149 | sampler_ci.compareEnable = VK_FALSE; |
| 4150 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4151 | sampler_ci.minLod = 1.0; |
| 4152 | sampler_ci.maxLod = 1.0; |
| 4153 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4154 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4155 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4156 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4157 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4158 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4159 | VkDescriptorImageInfo info = {}; |
| 4160 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4161 | |
| 4162 | VkWriteDescriptorSet descriptor_write; |
| 4163 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4164 | descriptor_write.sType = |
| 4165 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4166 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4167 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4168 | // 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] | 4169 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4170 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4171 | |
| 4172 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4173 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4174 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4175 | FAIL() << "Did not receive Error 'Unexpected UPDATE struct of type '"; |
| 4176 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4177 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4178 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4179 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4180 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4181 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4182 | } |
| 4183 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4184 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4185 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4186 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4187 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4188 | m_errorMonitor->SetDesiredFailureMsg( |
| 4189 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4190 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 4191 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4192 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4193 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 4194 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4195 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4196 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4197 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4198 | |
| 4199 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4200 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4201 | ds_pool_ci.pNext = NULL; |
| 4202 | ds_pool_ci.maxSets = 1; |
| 4203 | ds_pool_ci.poolSizeCount = 1; |
| 4204 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4205 | |
| 4206 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4207 | err = |
| 4208 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4209 | ASSERT_VK_SUCCESS(err); |
| 4210 | |
| 4211 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4212 | dsl_binding.binding = 0; |
| 4213 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4214 | dsl_binding.descriptorCount = 1; |
| 4215 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4216 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4217 | |
| 4218 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4219 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4220 | ds_layout_ci.pNext = NULL; |
| 4221 | ds_layout_ci.bindingCount = 1; |
| 4222 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4223 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4224 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4225 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4226 | ASSERT_VK_SUCCESS(err); |
| 4227 | |
| 4228 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4229 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4230 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4231 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4232 | alloc_info.descriptorPool = ds_pool; |
| 4233 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4234 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4235 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4236 | ASSERT_VK_SUCCESS(err); |
| 4237 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4238 | VkSampler sampler = |
| 4239 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4240 | |
| 4241 | VkDescriptorImageInfo descriptor_info; |
| 4242 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 4243 | descriptor_info.sampler = sampler; |
| 4244 | |
| 4245 | VkWriteDescriptorSet descriptor_write; |
| 4246 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4247 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4248 | descriptor_write.dstSet = descriptorSet; |
| 4249 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4250 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4251 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4252 | descriptor_write.pImageInfo = &descriptor_info; |
| 4253 | |
| 4254 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4255 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4256 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4257 | FAIL() << "Did not receive Error 'Attempt to update descriptor with " |
| 4258 | "invalid sampler...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4259 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4260 | } |
| 4261 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4262 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4263 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4264 | } |
| 4265 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4266 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 4267 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 4268 | // imageView |
| 4269 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4270 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4271 | m_errorMonitor->SetDesiredFailureMsg( |
| 4272 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4273 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 4274 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4275 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4276 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4277 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4278 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4279 | |
| 4280 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4281 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4282 | ds_pool_ci.pNext = NULL; |
| 4283 | ds_pool_ci.maxSets = 1; |
| 4284 | ds_pool_ci.poolSizeCount = 1; |
| 4285 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4286 | |
| 4287 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4288 | err = |
| 4289 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4290 | ASSERT_VK_SUCCESS(err); |
| 4291 | |
| 4292 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4293 | dsl_binding.binding = 0; |
| 4294 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4295 | dsl_binding.descriptorCount = 1; |
| 4296 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4297 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4298 | |
| 4299 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4300 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4301 | ds_layout_ci.pNext = NULL; |
| 4302 | ds_layout_ci.bindingCount = 1; |
| 4303 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4304 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4305 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4306 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4307 | ASSERT_VK_SUCCESS(err); |
| 4308 | |
| 4309 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4310 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4311 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4312 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4313 | alloc_info.descriptorPool = ds_pool; |
| 4314 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4315 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4316 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4317 | ASSERT_VK_SUCCESS(err); |
| 4318 | |
| 4319 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4320 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4321 | sampler_ci.pNext = NULL; |
| 4322 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4323 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4324 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4325 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4326 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4327 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4328 | sampler_ci.mipLodBias = 1.0; |
| 4329 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4330 | sampler_ci.maxAnisotropy = 1; |
| 4331 | sampler_ci.compareEnable = VK_FALSE; |
| 4332 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4333 | sampler_ci.minLod = 1.0; |
| 4334 | sampler_ci.maxLod = 1.0; |
| 4335 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4336 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4337 | |
| 4338 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4339 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4340 | ASSERT_VK_SUCCESS(err); |
| 4341 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4342 | VkImageView view = |
| 4343 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4344 | |
| 4345 | VkDescriptorImageInfo descriptor_info; |
| 4346 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 4347 | descriptor_info.sampler = sampler; |
| 4348 | descriptor_info.imageView = view; |
| 4349 | |
| 4350 | VkWriteDescriptorSet descriptor_write; |
| 4351 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4352 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4353 | descriptor_write.dstSet = descriptorSet; |
| 4354 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4355 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4356 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4357 | descriptor_write.pImageInfo = &descriptor_info; |
| 4358 | |
| 4359 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4360 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4361 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4362 | FAIL() << "Did not receive Error 'Attempt to update descriptor with " |
| 4363 | "invalid imageView...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4364 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4365 | } |
| 4366 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4367 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4368 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4369 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4370 | } |
| 4371 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4372 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 4373 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 4374 | // into the other |
| 4375 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4376 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4377 | m_errorMonitor->SetDesiredFailureMsg( |
| 4378 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Copy descriptor update index 0, update " |
| 4379 | "count #1, has src update descriptor " |
| 4380 | "type VK_DESCRIPTOR_TYPE_SAMPLER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4381 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4382 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4383 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4384 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4385 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4386 | ds_type_count[0].descriptorCount = 1; |
| 4387 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4388 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4389 | |
| 4390 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4391 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4392 | ds_pool_ci.pNext = NULL; |
| 4393 | ds_pool_ci.maxSets = 1; |
| 4394 | ds_pool_ci.poolSizeCount = 2; |
| 4395 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4396 | |
| 4397 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4398 | err = |
| 4399 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4400 | ASSERT_VK_SUCCESS(err); |
| 4401 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4402 | dsl_binding[0].binding = 0; |
| 4403 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4404 | dsl_binding[0].descriptorCount = 1; |
| 4405 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4406 | dsl_binding[0].pImmutableSamplers = NULL; |
| 4407 | dsl_binding[1].binding = 1; |
| 4408 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4409 | dsl_binding[1].descriptorCount = 1; |
| 4410 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 4411 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4412 | |
| 4413 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4414 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4415 | ds_layout_ci.pNext = NULL; |
| 4416 | ds_layout_ci.bindingCount = 2; |
| 4417 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4418 | |
| 4419 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4420 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4421 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4422 | ASSERT_VK_SUCCESS(err); |
| 4423 | |
| 4424 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4425 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4426 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4427 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4428 | alloc_info.descriptorPool = ds_pool; |
| 4429 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4430 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4431 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4432 | ASSERT_VK_SUCCESS(err); |
| 4433 | |
| 4434 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4435 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4436 | sampler_ci.pNext = NULL; |
| 4437 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4438 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4439 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4440 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4441 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4442 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4443 | sampler_ci.mipLodBias = 1.0; |
| 4444 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4445 | sampler_ci.maxAnisotropy = 1; |
| 4446 | sampler_ci.compareEnable = VK_FALSE; |
| 4447 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4448 | sampler_ci.minLod = 1.0; |
| 4449 | sampler_ci.maxLod = 1.0; |
| 4450 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4451 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4452 | |
| 4453 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4454 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4455 | ASSERT_VK_SUCCESS(err); |
| 4456 | |
| 4457 | VkDescriptorImageInfo info = {}; |
| 4458 | info.sampler = sampler; |
| 4459 | |
| 4460 | VkWriteDescriptorSet descriptor_write; |
| 4461 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 4462 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4463 | descriptor_write.dstSet = descriptorSet; |
| 4464 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4465 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4466 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4467 | descriptor_write.pImageInfo = &info; |
| 4468 | // This write update should succeed |
| 4469 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4470 | // Now perform a copy update that fails due to type mismatch |
| 4471 | VkCopyDescriptorSet copy_ds_update; |
| 4472 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4473 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4474 | copy_ds_update.srcSet = descriptorSet; |
| 4475 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4476 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4477 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4478 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4479 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4480 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4481 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4482 | FAIL() << "Did not receive Error 'Copy descriptor update index 0, " |
| 4483 | "update count #1, has src update descriptor " |
| 4484 | "type_DESCRIPTOR_TYPE_SAMPLER'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4485 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4486 | } |
| 4487 | // 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] | 4488 | m_errorMonitor->SetDesiredFailureMsg( |
| 4489 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4490 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4491 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4492 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4493 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4494 | copy_ds_update.srcBinding = |
| 4495 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4496 | copy_ds_update.dstSet = descriptorSet; |
| 4497 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4498 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4499 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4500 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4501 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4502 | FAIL() << "Did not receive Error 'Copy descriptor update 0 has " |
| 4503 | "srcBinding 3 which is out of bounds...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4504 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4505 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4506 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4507 | // 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] | 4508 | m_errorMonitor->SetDesiredFailureMsg( |
| 4509 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4510 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 4511 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4512 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4513 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4514 | copy_ds_update.srcSet = descriptorSet; |
| 4515 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4516 | copy_ds_update.dstSet = descriptorSet; |
| 4517 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4518 | copy_ds_update.descriptorCount = |
| 4519 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4520 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4521 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4522 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4523 | FAIL() << "Did not receive Error 'Copy descriptor src update is out of " |
| 4524 | "bounds for matching binding 1...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4525 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4526 | } |
| 4527 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4528 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4529 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4530 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4531 | } |
| 4532 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4533 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 4534 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 4535 | // sampleCount |
| 4536 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4537 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4538 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4539 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4540 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4541 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4542 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4543 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4544 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4545 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4546 | |
| 4547 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4548 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4549 | ds_pool_ci.pNext = NULL; |
| 4550 | ds_pool_ci.maxSets = 1; |
| 4551 | ds_pool_ci.poolSizeCount = 1; |
| 4552 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4553 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4554 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4555 | err = |
| 4556 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4557 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4558 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4559 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4560 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4561 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4562 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4563 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4564 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4565 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4566 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4567 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4568 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4569 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4570 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4571 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4572 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4573 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4574 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4575 | ASSERT_VK_SUCCESS(err); |
| 4576 | |
| 4577 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4578 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4579 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4580 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4581 | alloc_info.descriptorPool = ds_pool; |
| 4582 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4583 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4584 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4585 | ASSERT_VK_SUCCESS(err); |
| 4586 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4587 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4588 | pipe_ms_state_ci.sType = |
| 4589 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4590 | pipe_ms_state_ci.pNext = NULL; |
| 4591 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 4592 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4593 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4594 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4595 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4596 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4597 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4598 | pipeline_layout_ci.pNext = NULL; |
| 4599 | pipeline_layout_ci.setLayoutCount = 1; |
| 4600 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4601 | |
| 4602 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4603 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4604 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4605 | ASSERT_VK_SUCCESS(err); |
| 4606 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4607 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4608 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4609 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4610 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4611 | this); // TODO - We shouldn't need a fragment shader |
| 4612 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4613 | VkPipelineObj pipe(m_device); |
| 4614 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4615 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4616 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4617 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4618 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4619 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4620 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4621 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4622 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4623 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4624 | FAIL() << "Did not recieve Error 'Num samples mismatch!...'"; |
| 4625 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4626 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4627 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4628 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4629 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4630 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4631 | } |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4632 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4633 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 4634 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 4635 | // to issuing a Draw |
| 4636 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4637 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4638 | // TODO: verify that this matches layer |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4639 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 4640 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4641 | "vkCmdClearAttachments() issued on CB object "); |
| 4642 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4643 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4644 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4645 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4646 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4647 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4648 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4649 | |
| 4650 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4651 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4652 | ds_pool_ci.pNext = NULL; |
| 4653 | ds_pool_ci.maxSets = 1; |
| 4654 | ds_pool_ci.poolSizeCount = 1; |
| 4655 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4656 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4657 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4658 | err = |
| 4659 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4660 | ASSERT_VK_SUCCESS(err); |
| 4661 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4662 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4663 | dsl_binding.binding = 0; |
| 4664 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4665 | dsl_binding.descriptorCount = 1; |
| 4666 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4667 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4668 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4669 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4670 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4671 | ds_layout_ci.pNext = NULL; |
| 4672 | ds_layout_ci.bindingCount = 1; |
| 4673 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4674 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4675 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4676 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4677 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4678 | ASSERT_VK_SUCCESS(err); |
| 4679 | |
| 4680 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4681 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4682 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4683 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4684 | alloc_info.descriptorPool = ds_pool; |
| 4685 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4686 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4687 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4688 | ASSERT_VK_SUCCESS(err); |
| 4689 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4690 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4691 | pipe_ms_state_ci.sType = |
| 4692 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4693 | pipe_ms_state_ci.pNext = NULL; |
| 4694 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 4695 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4696 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4697 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4698 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4699 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4700 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4701 | pipeline_layout_ci.pNext = NULL; |
| 4702 | pipeline_layout_ci.setLayoutCount = 1; |
| 4703 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4704 | |
| 4705 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4706 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4707 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4708 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4709 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4710 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4711 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4712 | // TODO - We shouldn't need a fragment shader but add it to be able to run |
| 4713 | // on more devices |
| 4714 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4715 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4716 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4717 | VkPipelineObj pipe(m_device); |
| 4718 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4719 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4720 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4721 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4722 | |
| 4723 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4724 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4725 | // Main thing we care about for this test is that the VkImage obj we're |
| 4726 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4727 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4728 | VkClearAttachment color_attachment; |
| 4729 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4730 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 4731 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 4732 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 4733 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 4734 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4735 | VkClearRect clear_rect = { |
| 4736 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4737 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4738 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 4739 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4740 | |
| 4741 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4742 | FAIL() << "Did not receive Error 'vkCommandClearAttachments() issued " |
| 4743 | "on CB object...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4744 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4745 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4746 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4747 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4748 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4749 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4750 | } |
| 4751 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4752 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 4753 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4754 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4755 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4756 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 4757 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4758 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4759 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4760 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4761 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4762 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4763 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4764 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4765 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4766 | |
| 4767 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4768 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4769 | ds_pool_ci.pNext = NULL; |
| 4770 | ds_pool_ci.maxSets = 1; |
| 4771 | ds_pool_ci.poolSizeCount = 1; |
| 4772 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4773 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4774 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4775 | err = |
| 4776 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4777 | ASSERT_VK_SUCCESS(err); |
| 4778 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4779 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4780 | dsl_binding.binding = 0; |
| 4781 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4782 | dsl_binding.descriptorCount = 1; |
| 4783 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4784 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4785 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4786 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4787 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4788 | ds_layout_ci.pNext = NULL; |
| 4789 | ds_layout_ci.bindingCount = 1; |
| 4790 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4791 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4792 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4793 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4794 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4795 | ASSERT_VK_SUCCESS(err); |
| 4796 | |
| 4797 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4798 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4799 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4800 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4801 | alloc_info.descriptorPool = ds_pool; |
| 4802 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4803 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4804 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4805 | ASSERT_VK_SUCCESS(err); |
| 4806 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4807 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4808 | pipe_ms_state_ci.sType = |
| 4809 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4810 | pipe_ms_state_ci.pNext = NULL; |
| 4811 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 4812 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4813 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4814 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4815 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4816 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4817 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4818 | pipeline_layout_ci.pNext = NULL; |
| 4819 | pipeline_layout_ci.setLayoutCount = 1; |
| 4820 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4821 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4822 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4823 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4824 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4825 | ASSERT_VK_SUCCESS(err); |
| 4826 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4827 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4828 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4829 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4830 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4831 | this); // TODO - We shouldn't need a fragment shader |
| 4832 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4833 | VkPipelineObj pipe(m_device); |
| 4834 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4835 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4836 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4837 | pipe.SetViewport(m_viewports); |
| 4838 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4839 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4840 | |
| 4841 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4842 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4843 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4844 | // Don't care about actual data, just need to get to draw to flag error |
| 4845 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4846 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 4847 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4848 | 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] | 4849 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4850 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4851 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4852 | FAIL() << "Did not receive Error 'Vtx Buffer Index 0 was bound, but no " |
| 4853 | "vtx buffers are attached to PSO.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4854 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4855 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4856 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4857 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4858 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4859 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4860 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4861 | #endif // DRAW_STATE_TESTS |
| 4862 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 4863 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4864 | #if GTEST_IS_THREADSAFE |
| 4865 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4866 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4867 | VkEvent event; |
| 4868 | bool bailout; |
| 4869 | }; |
| 4870 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4871 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 4872 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4873 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4874 | for (int i = 0; i < 10000; i++) { |
| 4875 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 4876 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4877 | if (data->bailout) { |
| 4878 | break; |
| 4879 | } |
| 4880 | } |
| 4881 | return NULL; |
| 4882 | } |
| 4883 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4884 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4885 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4886 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4887 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4888 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4889 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4890 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4891 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4892 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4893 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4894 | // Calls AllocateCommandBuffers |
| 4895 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4896 | |
| 4897 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4898 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4899 | |
| 4900 | VkEventCreateInfo event_info; |
| 4901 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4902 | VkResult err; |
| 4903 | |
| 4904 | memset(&event_info, 0, sizeof(event_info)); |
| 4905 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 4906 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4907 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4908 | ASSERT_VK_SUCCESS(err); |
| 4909 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4910 | err = vkResetEvent(device(), event); |
| 4911 | ASSERT_VK_SUCCESS(err); |
| 4912 | |
| 4913 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4914 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4915 | data.event = event; |
| 4916 | data.bailout = false; |
| 4917 | m_errorMonitor->SetBailout(&data.bailout); |
| 4918 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4919 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4920 | // Add many entries to command buffer from this thread at the same time. |
| 4921 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4922 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4923 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4924 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4925 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 4926 | m_errorMonitor->SetBailout(NULL); |
| 4927 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4928 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4929 | FAIL() << "Did not receive Error 'THREADING ERROR' from using one " |
| 4930 | "VkCommandBufferObj in two threads"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4931 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4932 | } |
| 4933 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4934 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4935 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4936 | #endif // GTEST_IS_THREADSAFE |
| 4937 | #endif // THREADING_TESTS |
| 4938 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4939 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4940 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4941 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4942 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4943 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4944 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4945 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4946 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4947 | VkShaderModule module; |
| 4948 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4949 | struct icd_spv_header spv; |
| 4950 | |
| 4951 | spv.magic = ICD_SPV_MAGIC; |
| 4952 | spv.version = ICD_SPV_VERSION; |
| 4953 | spv.gen_magic = 0; |
| 4954 | |
| 4955 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4956 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4957 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4958 | moduleCreateInfo.codeSize = 4; |
| 4959 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4960 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4961 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4962 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4963 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4964 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4965 | } |
| 4966 | } |
| 4967 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4968 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4969 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4970 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4971 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4972 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4973 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4974 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4975 | VkShaderModule module; |
| 4976 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4977 | struct icd_spv_header spv; |
| 4978 | |
| 4979 | spv.magic = ~ICD_SPV_MAGIC; |
| 4980 | spv.version = ICD_SPV_VERSION; |
| 4981 | spv.gen_magic = 0; |
| 4982 | |
| 4983 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4984 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4985 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4986 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4987 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4988 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4989 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4990 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4991 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4992 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4993 | } |
| 4994 | } |
| 4995 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4996 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4997 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4998 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4999 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5000 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5001 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5002 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5003 | VkShaderModule module; |
| 5004 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 5005 | struct icd_spv_header spv; |
| 5006 | |
| 5007 | spv.magic = ICD_SPV_MAGIC; |
| 5008 | spv.version = ~ICD_SPV_VERSION; |
| 5009 | spv.gen_magic = 0; |
| 5010 | |
| 5011 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 5012 | moduleCreateInfo.pNext = NULL; |
| 5013 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5014 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5015 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 5016 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5017 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5018 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5019 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5020 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 5021 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5022 | } |
| 5023 | } |
| 5024 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5025 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5026 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5027 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5028 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5029 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5030 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5031 | |
| 5032 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5033 | "#version 400\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5034 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5035 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5036 | "\n" |
| 5037 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5038 | "out gl_PerVertex {\n" |
| 5039 | " vec4 gl_Position;\n" |
| 5040 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5041 | "void main(){\n" |
| 5042 | " gl_Position = vec4(1);\n" |
| 5043 | " x = 0;\n" |
| 5044 | "}\n"; |
| 5045 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5046 | "#version 400\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5047 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5048 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5049 | "\n" |
| 5050 | "layout(location=0) out vec4 color;\n" |
| 5051 | "void main(){\n" |
| 5052 | " color = vec4(1);\n" |
| 5053 | "}\n"; |
| 5054 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5055 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5056 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5057 | |
| 5058 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5059 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5060 | pipe.AddShader(&vs); |
| 5061 | pipe.AddShader(&fs); |
| 5062 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5063 | VkDescriptorSetObj descriptorSet(m_device); |
| 5064 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5065 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5066 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5067 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5068 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5069 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5070 | FAIL() << "Did not receive Warning 'not consumed by fragment shader'"; |
| 5071 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5072 | } |
| 5073 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5074 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5075 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5076 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5077 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5078 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5079 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5080 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5081 | |
| 5082 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5083 | "#version 400\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5084 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5085 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5086 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5087 | "out gl_PerVertex {\n" |
| 5088 | " vec4 gl_Position;\n" |
| 5089 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5090 | "void main(){\n" |
| 5091 | " gl_Position = vec4(1);\n" |
| 5092 | "}\n"; |
| 5093 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5094 | "#version 400\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5095 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5096 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5097 | "\n" |
| 5098 | "layout(location=0) in float x;\n" |
| 5099 | "layout(location=0) out vec4 color;\n" |
| 5100 | "void main(){\n" |
| 5101 | " color = vec4(x);\n" |
| 5102 | "}\n"; |
| 5103 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5104 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5105 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5106 | |
| 5107 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5108 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5109 | pipe.AddShader(&vs); |
| 5110 | pipe.AddShader(&fs); |
| 5111 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5112 | VkDescriptorSetObj descriptorSet(m_device); |
| 5113 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5114 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5115 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5116 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5117 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5118 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5119 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 5120 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5121 | } |
| 5122 | } |
| 5123 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5124 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5125 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5126 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5127 | |
| 5128 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5129 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5130 | |
| 5131 | char const *vsSource = |
| 5132 | "#version 400\n" |
| 5133 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5134 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5135 | "\n" |
| 5136 | "out gl_PerVertex {\n" |
| 5137 | " vec4 gl_Position;\n" |
| 5138 | "};\n" |
| 5139 | "void main(){\n" |
| 5140 | " gl_Position = vec4(1);\n" |
| 5141 | "}\n"; |
| 5142 | char const *fsSource = |
| 5143 | "#version 450\n" |
| 5144 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5145 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5146 | "\n" |
| 5147 | "in block { layout(location=0) float x; } ins;\n" |
| 5148 | "layout(location=0) out vec4 color;\n" |
| 5149 | "void main(){\n" |
| 5150 | " color = vec4(ins.x);\n" |
| 5151 | "}\n"; |
| 5152 | |
| 5153 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5154 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5155 | |
| 5156 | VkPipelineObj pipe(m_device); |
| 5157 | pipe.AddColorAttachment(); |
| 5158 | pipe.AddShader(&vs); |
| 5159 | pipe.AddShader(&fs); |
| 5160 | |
| 5161 | VkDescriptorSetObj descriptorSet(m_device); |
| 5162 | descriptorSet.AppendDummy(); |
| 5163 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5164 | |
| 5165 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5166 | |
| 5167 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5168 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 5169 | m_errorMonitor->DumpFailureMsgs(); |
| 5170 | } |
| 5171 | } |
| 5172 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5173 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5174 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5175 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5176 | "output arr[2] of float32' vs 'ptr to " |
| 5177 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5178 | |
| 5179 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5180 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5181 | |
| 5182 | char const *vsSource = |
| 5183 | "#version 400\n" |
| 5184 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5185 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5186 | "\n" |
| 5187 | "layout(location=0) out float x[2];\n" |
| 5188 | "out gl_PerVertex {\n" |
| 5189 | " vec4 gl_Position;\n" |
| 5190 | "};\n" |
| 5191 | "void main(){\n" |
| 5192 | " x[0] = 0; x[1] = 0;\n" |
| 5193 | " gl_Position = vec4(1);\n" |
| 5194 | "}\n"; |
| 5195 | char const *fsSource = |
| 5196 | "#version 400\n" |
| 5197 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5198 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5199 | "\n" |
| 5200 | "layout(location=0) in float x[3];\n" |
| 5201 | "layout(location=0) out vec4 color;\n" |
| 5202 | "void main(){\n" |
| 5203 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 5204 | "}\n"; |
| 5205 | |
| 5206 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5207 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5208 | |
| 5209 | VkPipelineObj pipe(m_device); |
| 5210 | pipe.AddColorAttachment(); |
| 5211 | pipe.AddShader(&vs); |
| 5212 | pipe.AddShader(&fs); |
| 5213 | |
| 5214 | VkDescriptorSetObj descriptorSet(m_device); |
| 5215 | descriptorSet.AppendDummy(); |
| 5216 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5217 | |
| 5218 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5219 | |
| 5220 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5221 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5222 | FAIL() << "Did not receive Error 'Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5223 | "output arr[2] of float32' vs 'ptr to input arr[3] of " |
| 5224 | "float32''"; |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5225 | } |
| 5226 | } |
| 5227 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5228 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5229 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5230 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5231 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5232 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5233 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5234 | |
| 5235 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5236 | "#version 400\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5237 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5238 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5239 | "\n" |
| 5240 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5241 | "out gl_PerVertex {\n" |
| 5242 | " vec4 gl_Position;\n" |
| 5243 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5244 | "void main(){\n" |
| 5245 | " x = 0;\n" |
| 5246 | " gl_Position = vec4(1);\n" |
| 5247 | "}\n"; |
| 5248 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5249 | "#version 400\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5250 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5251 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5252 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5253 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5254 | "layout(location=0) out vec4 color;\n" |
| 5255 | "void main(){\n" |
| 5256 | " color = vec4(x);\n" |
| 5257 | "}\n"; |
| 5258 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5259 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5260 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5261 | |
| 5262 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5263 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5264 | pipe.AddShader(&vs); |
| 5265 | pipe.AddShader(&fs); |
| 5266 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5267 | VkDescriptorSetObj descriptorSet(m_device); |
| 5268 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5269 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5270 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5271 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5272 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5273 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5274 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 5275 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5276 | } |
| 5277 | } |
| 5278 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5279 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5280 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5281 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5282 | |
| 5283 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5284 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5285 | |
| 5286 | char const *vsSource = |
| 5287 | "#version 450\n" |
| 5288 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5289 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5290 | "\n" |
| 5291 | "out block { layout(location=0) int x; } outs;\n" |
| 5292 | "out gl_PerVertex {\n" |
| 5293 | " vec4 gl_Position;\n" |
| 5294 | "};\n" |
| 5295 | "void main(){\n" |
| 5296 | " outs.x = 0;\n" |
| 5297 | " gl_Position = vec4(1);\n" |
| 5298 | "}\n"; |
| 5299 | char const *fsSource = |
| 5300 | "#version 450\n" |
| 5301 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5302 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5303 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5304 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5305 | "layout(location=0) out vec4 color;\n" |
| 5306 | "void main(){\n" |
| 5307 | " color = vec4(ins.x);\n" |
| 5308 | "}\n"; |
| 5309 | |
| 5310 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5311 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5312 | |
| 5313 | VkPipelineObj pipe(m_device); |
| 5314 | pipe.AddColorAttachment(); |
| 5315 | pipe.AddShader(&vs); |
| 5316 | pipe.AddShader(&fs); |
| 5317 | |
| 5318 | VkDescriptorSetObj descriptorSet(m_device); |
| 5319 | descriptorSet.AppendDummy(); |
| 5320 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5321 | |
| 5322 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5323 | |
| 5324 | if (!m_errorMonitor->DesiredMsgFound()) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5325 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5326 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 5327 | } |
| 5328 | } |
| 5329 | |
| 5330 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 5331 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5332 | "location 0.0 which is not written by vertex shader"); |
| 5333 | |
| 5334 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5335 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5336 | |
| 5337 | char const *vsSource = |
| 5338 | "#version 450\n" |
| 5339 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5340 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5341 | "\n" |
| 5342 | "out block { layout(location=1) float x; } outs;\n" |
| 5343 | "out gl_PerVertex {\n" |
| 5344 | " vec4 gl_Position;\n" |
| 5345 | "};\n" |
| 5346 | "void main(){\n" |
| 5347 | " outs.x = 0;\n" |
| 5348 | " gl_Position = vec4(1);\n" |
| 5349 | "}\n"; |
| 5350 | char const *fsSource = |
| 5351 | "#version 450\n" |
| 5352 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5353 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5354 | "\n" |
| 5355 | "in block { layout(location=0) float x; } ins;\n" |
| 5356 | "layout(location=0) out vec4 color;\n" |
| 5357 | "void main(){\n" |
| 5358 | " color = vec4(ins.x);\n" |
| 5359 | "}\n"; |
| 5360 | |
| 5361 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5362 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5363 | |
| 5364 | VkPipelineObj pipe(m_device); |
| 5365 | pipe.AddColorAttachment(); |
| 5366 | pipe.AddShader(&vs); |
| 5367 | pipe.AddShader(&fs); |
| 5368 | |
| 5369 | VkDescriptorSetObj descriptorSet(m_device); |
| 5370 | descriptorSet.AppendDummy(); |
| 5371 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5372 | |
| 5373 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5374 | |
| 5375 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5376 | m_errorMonitor->DumpFailureMsgs(); |
| 5377 | FAIL() << "Did not receive Error 'location 0.0 which is not written by vertex shader'"; |
| 5378 | } |
| 5379 | } |
| 5380 | |
| 5381 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 5382 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5383 | "location 0.1 which is not written by vertex shader"); |
| 5384 | |
| 5385 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5386 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5387 | |
| 5388 | char const *vsSource = |
| 5389 | "#version 450\n" |
| 5390 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5391 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5392 | "\n" |
| 5393 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 5394 | "out gl_PerVertex {\n" |
| 5395 | " vec4 gl_Position;\n" |
| 5396 | "};\n" |
| 5397 | "void main(){\n" |
| 5398 | " outs.x = 0;\n" |
| 5399 | " gl_Position = vec4(1);\n" |
| 5400 | "}\n"; |
| 5401 | char const *fsSource = |
| 5402 | "#version 450\n" |
| 5403 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5404 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5405 | "\n" |
| 5406 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 5407 | "layout(location=0) out vec4 color;\n" |
| 5408 | "void main(){\n" |
| 5409 | " color = vec4(ins.x);\n" |
| 5410 | "}\n"; |
| 5411 | |
| 5412 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5413 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5414 | |
| 5415 | VkPipelineObj pipe(m_device); |
| 5416 | pipe.AddColorAttachment(); |
| 5417 | pipe.AddShader(&vs); |
| 5418 | pipe.AddShader(&fs); |
| 5419 | |
| 5420 | VkDescriptorSetObj descriptorSet(m_device); |
| 5421 | descriptorSet.AppendDummy(); |
| 5422 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5423 | |
| 5424 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5425 | |
| 5426 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5427 | m_errorMonitor->DumpFailureMsgs(); |
| 5428 | FAIL() << "Did not receive Error 'location 0.1 which is not written by vertex shader'"; |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5429 | } |
| 5430 | } |
| 5431 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5432 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5433 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5434 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5435 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5436 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5437 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5438 | |
| 5439 | VkVertexInputBindingDescription input_binding; |
| 5440 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5441 | |
| 5442 | VkVertexInputAttributeDescription input_attrib; |
| 5443 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5444 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5445 | |
| 5446 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5447 | "#version 400\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5448 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5449 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5450 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5451 | "out gl_PerVertex {\n" |
| 5452 | " vec4 gl_Position;\n" |
| 5453 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5454 | "void main(){\n" |
| 5455 | " gl_Position = vec4(1);\n" |
| 5456 | "}\n"; |
| 5457 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5458 | "#version 400\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5459 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5460 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5461 | "\n" |
| 5462 | "layout(location=0) out vec4 color;\n" |
| 5463 | "void main(){\n" |
| 5464 | " color = vec4(1);\n" |
| 5465 | "}\n"; |
| 5466 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5467 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5468 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5469 | |
| 5470 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5471 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5472 | pipe.AddShader(&vs); |
| 5473 | pipe.AddShader(&fs); |
| 5474 | |
| 5475 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5476 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5477 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5478 | VkDescriptorSetObj descriptorSet(m_device); |
| 5479 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5480 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5481 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5482 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5483 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5484 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5485 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 5486 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5487 | } |
| 5488 | } |
| 5489 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5490 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5491 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5492 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5493 | |
| 5494 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5495 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5496 | |
| 5497 | VkVertexInputBindingDescription input_binding; |
| 5498 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5499 | |
| 5500 | VkVertexInputAttributeDescription input_attrib; |
| 5501 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5502 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5503 | |
| 5504 | char const *vsSource = |
| 5505 | "#version 400\n" |
| 5506 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5507 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5508 | "\n" |
| 5509 | "layout(location=1) in float x;\n" |
| 5510 | "out gl_PerVertex {\n" |
| 5511 | " vec4 gl_Position;\n" |
| 5512 | "};\n" |
| 5513 | "void main(){\n" |
| 5514 | " gl_Position = vec4(x);\n" |
| 5515 | "}\n"; |
| 5516 | char const *fsSource = |
| 5517 | "#version 400\n" |
| 5518 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5519 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5520 | "\n" |
| 5521 | "layout(location=0) out vec4 color;\n" |
| 5522 | "void main(){\n" |
| 5523 | " color = vec4(1);\n" |
| 5524 | "}\n"; |
| 5525 | |
| 5526 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5527 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5528 | |
| 5529 | VkPipelineObj pipe(m_device); |
| 5530 | pipe.AddColorAttachment(); |
| 5531 | pipe.AddShader(&vs); |
| 5532 | pipe.AddShader(&fs); |
| 5533 | |
| 5534 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5535 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5536 | |
| 5537 | VkDescriptorSetObj descriptorSet(m_device); |
| 5538 | descriptorSet.AppendDummy(); |
| 5539 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5540 | |
| 5541 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5542 | |
| 5543 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5544 | m_errorMonitor->DumpFailureMsgs(); |
| 5545 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 5546 | } |
| 5547 | } |
| 5548 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5549 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 5550 | m_errorMonitor->SetDesiredFailureMsg( |
| 5551 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5552 | "VS consumes input at location 0 but not provided"); |
| 5553 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5554 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5555 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5556 | |
| 5557 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5558 | "#version 400\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5559 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5560 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5561 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5562 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5563 | "out gl_PerVertex {\n" |
| 5564 | " vec4 gl_Position;\n" |
| 5565 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5566 | "void main(){\n" |
| 5567 | " gl_Position = x;\n" |
| 5568 | "}\n"; |
| 5569 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5570 | "#version 400\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5571 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5572 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5573 | "\n" |
| 5574 | "layout(location=0) out vec4 color;\n" |
| 5575 | "void main(){\n" |
| 5576 | " color = vec4(1);\n" |
| 5577 | "}\n"; |
| 5578 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5579 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5580 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5581 | |
| 5582 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5583 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5584 | pipe.AddShader(&vs); |
| 5585 | pipe.AddShader(&fs); |
| 5586 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5587 | VkDescriptorSetObj descriptorSet(m_device); |
| 5588 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5589 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5590 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5591 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5592 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5593 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5594 | FAIL() << "Did not receive Error 'VS consumes input at location 0 but " |
| 5595 | "not provided'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5596 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5597 | } |
| 5598 | } |
| 5599 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5600 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 5601 | m_errorMonitor->SetDesiredFailureMsg( |
| 5602 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5603 | "location 0 does not match VS input type"); |
| 5604 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5605 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5606 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5607 | |
| 5608 | VkVertexInputBindingDescription input_binding; |
| 5609 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5610 | |
| 5611 | VkVertexInputAttributeDescription input_attrib; |
| 5612 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5613 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5614 | |
| 5615 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5616 | "#version 400\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5617 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5618 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5619 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5620 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5621 | "out gl_PerVertex {\n" |
| 5622 | " vec4 gl_Position;\n" |
| 5623 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5624 | "void main(){\n" |
| 5625 | " gl_Position = vec4(x);\n" |
| 5626 | "}\n"; |
| 5627 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5628 | "#version 400\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5629 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5630 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5631 | "\n" |
| 5632 | "layout(location=0) out vec4 color;\n" |
| 5633 | "void main(){\n" |
| 5634 | " color = vec4(1);\n" |
| 5635 | "}\n"; |
| 5636 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5637 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5638 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5639 | |
| 5640 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5641 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5642 | pipe.AddShader(&vs); |
| 5643 | pipe.AddShader(&fs); |
| 5644 | |
| 5645 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5646 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5647 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5648 | VkDescriptorSetObj descriptorSet(m_device); |
| 5649 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5650 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5651 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5652 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5653 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5654 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5655 | FAIL() << "Did not receive Error 'location 0 does not match VS input " |
| 5656 | "type'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5657 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5658 | } |
| 5659 | } |
| 5660 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5661 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5662 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 5663 | |
| 5664 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5665 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5666 | |
| 5667 | VkVertexInputBindingDescription input_binding; |
| 5668 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5669 | |
| 5670 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5671 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5672 | |
| 5673 | for (int i = 0; i < 2; i++) { |
| 5674 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5675 | input_attribs[i].location = i; |
| 5676 | } |
| 5677 | |
| 5678 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5679 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5680 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5681 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5682 | "\n" |
| 5683 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5684 | "out gl_PerVertex {\n" |
| 5685 | " vec4 gl_Position;\n" |
| 5686 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5687 | "void main(){\n" |
| 5688 | " gl_Position = x[0] + x[1];\n" |
| 5689 | "}\n"; |
| 5690 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5691 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5692 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5693 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5694 | "\n" |
| 5695 | "layout(location=0) out vec4 color;\n" |
| 5696 | "void main(){\n" |
| 5697 | " color = vec4(1);\n" |
| 5698 | "}\n"; |
| 5699 | |
| 5700 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5701 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5702 | |
| 5703 | VkPipelineObj pipe(m_device); |
| 5704 | pipe.AddColorAttachment(); |
| 5705 | pipe.AddShader(&vs); |
| 5706 | pipe.AddShader(&fs); |
| 5707 | |
| 5708 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5709 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5710 | |
| 5711 | VkDescriptorSetObj descriptorSet(m_device); |
| 5712 | descriptorSet.AppendDummy(); |
| 5713 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5714 | |
| 5715 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5716 | |
| 5717 | /* expect success */ |
| 5718 | if (m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5719 | FAIL() << "Expected to succeed but: " |
| 5720 | << m_errorMonitor->GetFailureMsg(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5721 | m_errorMonitor->DumpFailureMsgs(); |
| 5722 | } |
| 5723 | } |
| 5724 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5725 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 5726 | { |
| 5727 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 5728 | |
| 5729 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5730 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5731 | |
| 5732 | VkVertexInputBindingDescription input_binding; |
| 5733 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5734 | |
| 5735 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5736 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5737 | |
| 5738 | for (int i = 0; i < 2; i++) { |
| 5739 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5740 | input_attribs[i].location = i; |
| 5741 | } |
| 5742 | |
| 5743 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5744 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5745 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5746 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5747 | "\n" |
| 5748 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5749 | "out gl_PerVertex {\n" |
| 5750 | " vec4 gl_Position;\n" |
| 5751 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5752 | "void main(){\n" |
| 5753 | " gl_Position = x[0] + x[1];\n" |
| 5754 | "}\n"; |
| 5755 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5756 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5757 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5758 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5759 | "\n" |
| 5760 | "layout(location=0) out vec4 color;\n" |
| 5761 | "void main(){\n" |
| 5762 | " color = vec4(1);\n" |
| 5763 | "}\n"; |
| 5764 | |
| 5765 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5766 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5767 | |
| 5768 | VkPipelineObj pipe(m_device); |
| 5769 | pipe.AddColorAttachment(); |
| 5770 | pipe.AddShader(&vs); |
| 5771 | pipe.AddShader(&fs); |
| 5772 | |
| 5773 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5774 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5775 | |
| 5776 | VkDescriptorSetObj descriptorSet(m_device); |
| 5777 | descriptorSet.AppendDummy(); |
| 5778 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5779 | |
| 5780 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5781 | |
| 5782 | if (m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5783 | FAIL() << "Expected to succeed but: " << |
| 5784 | m_errorMonitor->GetFailureMsg(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5785 | m_errorMonitor->DumpFailureMsgs(); |
| 5786 | } |
| 5787 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5788 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5789 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 5790 | m_errorMonitor->SetDesiredFailureMsg( |
| 5791 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5792 | "Duplicate vertex input binding descriptions for binding 0"); |
| 5793 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5794 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5795 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5796 | |
| 5797 | /* Two binding descriptions for binding 0 */ |
| 5798 | VkVertexInputBindingDescription input_bindings[2]; |
| 5799 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 5800 | |
| 5801 | VkVertexInputAttributeDescription input_attrib; |
| 5802 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5803 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5804 | |
| 5805 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5806 | "#version 400\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5807 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5808 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5809 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5810 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5811 | "out gl_PerVertex {\n" |
| 5812 | " vec4 gl_Position;\n" |
| 5813 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5814 | "void main(){\n" |
| 5815 | " gl_Position = vec4(x);\n" |
| 5816 | "}\n"; |
| 5817 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5818 | "#version 400\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5819 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5820 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5821 | "\n" |
| 5822 | "layout(location=0) out vec4 color;\n" |
| 5823 | "void main(){\n" |
| 5824 | " color = vec4(1);\n" |
| 5825 | "}\n"; |
| 5826 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5827 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5828 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5829 | |
| 5830 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5831 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5832 | pipe.AddShader(&vs); |
| 5833 | pipe.AddShader(&fs); |
| 5834 | |
| 5835 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 5836 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5837 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5838 | VkDescriptorSetObj descriptorSet(m_device); |
| 5839 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5840 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5841 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5842 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5843 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5844 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5845 | FAIL() << "Did not receive Error 'Duplicate vertex input binding " |
| 5846 | "descriptions for binding 0'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5847 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5848 | } |
| 5849 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 5850 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5851 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5852 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5853 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5854 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5855 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5856 | |
| 5857 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5858 | "#version 400\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5859 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5860 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5861 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5862 | "out gl_PerVertex {\n" |
| 5863 | " vec4 gl_Position;\n" |
| 5864 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5865 | "void main(){\n" |
| 5866 | " gl_Position = vec4(1);\n" |
| 5867 | "}\n"; |
| 5868 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5869 | "#version 400\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5870 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5871 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5872 | "\n" |
| 5873 | "void main(){\n" |
| 5874 | "}\n"; |
| 5875 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5876 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5877 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5878 | |
| 5879 | VkPipelineObj pipe(m_device); |
| 5880 | pipe.AddShader(&vs); |
| 5881 | pipe.AddShader(&fs); |
| 5882 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5883 | /* set up CB 0, not written */ |
| 5884 | pipe.AddColorAttachment(); |
| 5885 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5886 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5887 | VkDescriptorSetObj descriptorSet(m_device); |
| 5888 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5889 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5890 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5891 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5892 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5893 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5894 | FAIL() << "Did not receive Error 'Attachment 0 not written by FS'"; |
| 5895 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5896 | } |
| 5897 | } |
| 5898 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5899 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5900 | // TODO: verify that this matches layer |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5901 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5902 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5903 | "FS writes to output location 1 with no matching attachment"); |
| 5904 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5905 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5906 | |
| 5907 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5908 | "#version 400\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5909 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5910 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5911 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5912 | "out gl_PerVertex {\n" |
| 5913 | " vec4 gl_Position;\n" |
| 5914 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5915 | "void main(){\n" |
| 5916 | " gl_Position = vec4(1);\n" |
| 5917 | "}\n"; |
| 5918 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5919 | "#version 400\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5920 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5921 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5922 | "\n" |
| 5923 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5924 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5925 | "void main(){\n" |
| 5926 | " x = vec4(1);\n" |
| 5927 | " y = vec4(1);\n" |
| 5928 | "}\n"; |
| 5929 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5930 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5931 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5932 | |
| 5933 | VkPipelineObj pipe(m_device); |
| 5934 | pipe.AddShader(&vs); |
| 5935 | pipe.AddShader(&fs); |
| 5936 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5937 | /* set up CB 0, not written */ |
| 5938 | pipe.AddColorAttachment(); |
| 5939 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5940 | /* FS writes CB 1, but we don't configure it */ |
| 5941 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5942 | VkDescriptorSetObj descriptorSet(m_device); |
| 5943 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5944 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5945 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5946 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5947 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5948 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5949 | FAIL() << "Did not receive Error 'FS writes to output location 1 with " |
| 5950 | "no matching attachment'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5951 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5952 | } |
| 5953 | } |
| 5954 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5955 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5956 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5957 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5958 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5959 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5960 | |
| 5961 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5962 | "#version 400\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5963 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5964 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5965 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5966 | "out gl_PerVertex {\n" |
| 5967 | " vec4 gl_Position;\n" |
| 5968 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5969 | "void main(){\n" |
| 5970 | " gl_Position = vec4(1);\n" |
| 5971 | "}\n"; |
| 5972 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5973 | "#version 400\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5974 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5975 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5976 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5977 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5978 | "void main(){\n" |
| 5979 | " x = ivec4(1);\n" |
| 5980 | "}\n"; |
| 5981 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5982 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5983 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5984 | |
| 5985 | VkPipelineObj pipe(m_device); |
| 5986 | pipe.AddShader(&vs); |
| 5987 | pipe.AddShader(&fs); |
| 5988 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5989 | /* set up CB 0; type is UNORM by default */ |
| 5990 | pipe.AddColorAttachment(); |
| 5991 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5992 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5993 | VkDescriptorSetObj descriptorSet(m_device); |
| 5994 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5995 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5996 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5997 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5998 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5999 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6000 | FAIL() << "Did not receive Error 'does not match FS output type'"; |
| 6001 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6002 | } |
| 6003 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 6004 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6005 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6006 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6007 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6008 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6009 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6010 | |
| 6011 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6012 | "#version 400\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6013 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 6014 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 6015 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6016 | "out gl_PerVertex {\n" |
| 6017 | " vec4 gl_Position;\n" |
| 6018 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6019 | "void main(){\n" |
| 6020 | " gl_Position = vec4(1);\n" |
| 6021 | "}\n"; |
| 6022 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6023 | "#version 400\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6024 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 6025 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 6026 | "\n" |
| 6027 | "layout(location=0) out vec4 x;\n" |
| 6028 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 6029 | "void main(){\n" |
| 6030 | " x = vec4(bar.y);\n" |
| 6031 | "}\n"; |
| 6032 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6033 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6034 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6035 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6036 | VkPipelineObj pipe(m_device); |
| 6037 | pipe.AddShader(&vs); |
| 6038 | pipe.AddShader(&fs); |
| 6039 | |
| 6040 | /* set up CB 0; type is UNORM by default */ |
| 6041 | pipe.AddColorAttachment(); |
| 6042 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6043 | |
| 6044 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6045 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6046 | |
| 6047 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6048 | |
| 6049 | /* should have generated an error -- pipeline layout does not |
| 6050 | * provide a uniform buffer in 0.0 |
| 6051 | */ |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6052 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6053 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 6054 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6055 | } |
| 6056 | } |
| 6057 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 6058 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 6059 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6060 | "not declared in layout"); |
| 6061 | |
| 6062 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6063 | |
| 6064 | char const *vsSource = |
| 6065 | "#version 450\n" |
| 6066 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 6067 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 6068 | "\n" |
| 6069 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 6070 | "out gl_PerVertex {\n" |
| 6071 | " vec4 gl_Position;\n" |
| 6072 | "};\n" |
| 6073 | "void main(){\n" |
| 6074 | " gl_Position = vec4(consts.x);\n" |
| 6075 | "}\n"; |
| 6076 | char const *fsSource = |
| 6077 | "#version 450\n" |
| 6078 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 6079 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 6080 | "\n" |
| 6081 | "layout(location=0) out vec4 x;\n" |
| 6082 | "void main(){\n" |
| 6083 | " x = vec4(1);\n" |
| 6084 | "}\n"; |
| 6085 | |
| 6086 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6087 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6088 | |
| 6089 | VkPipelineObj pipe(m_device); |
| 6090 | pipe.AddShader(&vs); |
| 6091 | pipe.AddShader(&fs); |
| 6092 | |
| 6093 | /* set up CB 0; type is UNORM by default */ |
| 6094 | pipe.AddColorAttachment(); |
| 6095 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6096 | |
| 6097 | VkDescriptorSetObj descriptorSet(m_device); |
| 6098 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6099 | |
| 6100 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6101 | |
| 6102 | /* should have generated an error -- no push constant ranges provided! */ |
| 6103 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6104 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 6105 | m_errorMonitor->DumpFailureMsgs(); |
| 6106 | } |
| 6107 | } |
| 6108 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6109 | #endif // SHADER_CHECKER_TESTS |
| 6110 | |
| 6111 | #if DEVICE_LIMITS_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6112 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) { |
| 6113 | m_errorMonitor->SetDesiredFailureMsg( |
| 6114 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6115 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6116 | |
| 6117 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6118 | |
| 6119 | // Create an image |
| 6120 | VkImage image; |
| 6121 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6122 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6123 | const int32_t tex_width = 32; |
| 6124 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6125 | |
| 6126 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6127 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6128 | image_create_info.pNext = NULL; |
| 6129 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6130 | image_create_info.format = tex_format; |
| 6131 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6132 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6133 | image_create_info.extent.depth = 1; |
| 6134 | image_create_info.mipLevels = 1; |
| 6135 | image_create_info.arrayLayers = 1; |
| 6136 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6137 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6138 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6139 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6140 | |
| 6141 | // Introduce error by sending down a bogus width extent |
| 6142 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6143 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6144 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6145 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6146 | FAIL() << "Did not receive Error 'CreateImage extents exceed allowable " |
| 6147 | "limits for format'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6148 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6149 | } |
| 6150 | } |
| 6151 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6152 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 6153 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6154 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6155 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6156 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6157 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6158 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6159 | |
| 6160 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6161 | vk_testing::Buffer buffer; |
| 6162 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 6163 | |
| 6164 | BeginCommandBuffer(); |
| 6165 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6166 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6167 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6168 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, " |
| 6169 | "VkDeviceSize dstOffset, is not a multiple of 4'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6170 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6171 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6172 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6173 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6174 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6175 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6176 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6177 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6178 | |
| 6179 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6180 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, " |
| 6181 | "VkDeviceSize dataSize, is not a multiple of 4'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6182 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6183 | } |
| 6184 | EndCommandBuffer(); |
| 6185 | } |
| 6186 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6187 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6188 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6189 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6190 | |
| 6191 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6192 | |
| 6193 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6194 | vk_testing::Buffer buffer; |
| 6195 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 6196 | |
| 6197 | BeginCommandBuffer(); |
| 6198 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6199 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6200 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6201 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, " |
| 6202 | "VkDeviceSize dstOffset, is not a multiple of 4'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6203 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6204 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6205 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6206 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6207 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6208 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6209 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6210 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6211 | |
| 6212 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6213 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, " |
| 6214 | "VkDeviceSize size, is not a multiple of 4'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6215 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6216 | } |
| 6217 | EndCommandBuffer(); |
| 6218 | } |
| 6219 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6220 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6221 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6222 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6223 | TEST_F(VkLayerTest, InvalidImageView) { |
| 6224 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6225 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6226 | m_errorMonitor->SetDesiredFailureMsg( |
| 6227 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6228 | "vkCreateImageView called with baseMipLevel 10 "); |
| 6229 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6230 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6231 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6232 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6233 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6234 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6235 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6236 | const int32_t tex_width = 32; |
| 6237 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6238 | |
| 6239 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6240 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6241 | image_create_info.pNext = NULL; |
| 6242 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6243 | image_create_info.format = tex_format; |
| 6244 | image_create_info.extent.width = tex_width; |
| 6245 | image_create_info.extent.height = tex_height; |
| 6246 | image_create_info.extent.depth = 1; |
| 6247 | image_create_info.mipLevels = 1; |
| 6248 | image_create_info.arrayLayers = 1; |
| 6249 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6250 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6251 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6252 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6253 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6254 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6255 | ASSERT_VK_SUCCESS(err); |
| 6256 | |
| 6257 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6258 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6259 | image_view_create_info.image = image; |
| 6260 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6261 | image_view_create_info.format = tex_format; |
| 6262 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6263 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 6264 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6265 | image_view_create_info.subresourceRange.aspectMask = |
| 6266 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6267 | |
| 6268 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6269 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6270 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6271 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6272 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6273 | FAIL() << "Did not receive Error 'vkCreateImageView called with " |
| 6274 | "baseMipLevel 10...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6275 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6276 | } |
| 6277 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6278 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6279 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 6280 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6281 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6282 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6283 | "vkCreateImageView: Color image " |
| 6284 | "formats must have ONLY the " |
| 6285 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6286 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6287 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6288 | |
| 6289 | // 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] | 6290 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6291 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6292 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6293 | const int32_t tex_width = 32; |
| 6294 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6295 | |
| 6296 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6297 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6298 | image_create_info.pNext = NULL; |
| 6299 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6300 | image_create_info.format = tex_format; |
| 6301 | image_create_info.extent.width = tex_width; |
| 6302 | image_create_info.extent.height = tex_height; |
| 6303 | image_create_info.extent.depth = 1; |
| 6304 | image_create_info.mipLevels = 1; |
| 6305 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6306 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6307 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6308 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6309 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6310 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6311 | ASSERT_VK_SUCCESS(err); |
| 6312 | |
| 6313 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6314 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6315 | image_view_create_info.image = image; |
| 6316 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6317 | image_view_create_info.format = tex_format; |
| 6318 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 6319 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6320 | // Cause an error by setting an invalid image aspect |
| 6321 | image_view_create_info.subresourceRange.aspectMask = |
| 6322 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6323 | |
| 6324 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6325 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6326 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6327 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6328 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6329 | FAIL() << "Did not receive Error 'VkCreateImageView: Color image " |
| 6330 | "formats must have ...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6331 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6332 | } |
| 6333 | } |
| 6334 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6335 | TEST_F(VkLayerTest, CopyImageTypeMismatch) { |
| 6336 | VkResult err; |
| 6337 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6338 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6339 | m_errorMonitor->SetDesiredFailureMsg( |
| 6340 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6341 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 6342 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6343 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6344 | |
| 6345 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6346 | VkImage srcImage; |
| 6347 | VkImage dstImage; |
| 6348 | VkDeviceMemory srcMem; |
| 6349 | VkDeviceMemory destMem; |
| 6350 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6351 | |
| 6352 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6353 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6354 | image_create_info.pNext = NULL; |
| 6355 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6356 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6357 | image_create_info.extent.width = 32; |
| 6358 | image_create_info.extent.height = 32; |
| 6359 | image_create_info.extent.depth = 1; |
| 6360 | image_create_info.mipLevels = 1; |
| 6361 | image_create_info.arrayLayers = 1; |
| 6362 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6363 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6364 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6365 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6366 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6367 | err = |
| 6368 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6369 | ASSERT_VK_SUCCESS(err); |
| 6370 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6371 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6372 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6373 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6374 | err = |
| 6375 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6376 | ASSERT_VK_SUCCESS(err); |
| 6377 | |
| 6378 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6379 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6380 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6381 | memAlloc.pNext = NULL; |
| 6382 | memAlloc.allocationSize = 0; |
| 6383 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6384 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6385 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6386 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6387 | pass = |
| 6388 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6389 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6390 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6391 | ASSERT_VK_SUCCESS(err); |
| 6392 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6393 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6394 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6395 | pass = |
| 6396 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6397 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6398 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6399 | ASSERT_VK_SUCCESS(err); |
| 6400 | |
| 6401 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6402 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6403 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6404 | ASSERT_VK_SUCCESS(err); |
| 6405 | |
| 6406 | BeginCommandBuffer(); |
| 6407 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6408 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6409 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6410 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6411 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6412 | copyRegion.srcOffset.x = 0; |
| 6413 | copyRegion.srcOffset.y = 0; |
| 6414 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6415 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6416 | copyRegion.dstSubresource.mipLevel = 0; |
| 6417 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6418 | copyRegion.dstSubresource.layerCount = 0; |
| 6419 | copyRegion.dstOffset.x = 0; |
| 6420 | copyRegion.dstOffset.y = 0; |
| 6421 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6422 | copyRegion.extent.width = 1; |
| 6423 | copyRegion.extent.height = 1; |
| 6424 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6425 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6426 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6427 | EndCommandBuffer(); |
| 6428 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6429 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6430 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched " |
| 6431 | "source and dest image types'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6432 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6433 | } |
| 6434 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6435 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6436 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6437 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6438 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6439 | } |
| 6440 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6441 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
| 6442 | // TODO : Create two images with different format sizes and vkCmdCopyImage |
| 6443 | // between them |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6444 | } |
| 6445 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6446 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 6447 | VkResult err; |
| 6448 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6449 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6450 | m_errorMonitor->SetDesiredFailureMsg( |
| 6451 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6452 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 6453 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6454 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6455 | |
| 6456 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6457 | VkImage srcImage; |
| 6458 | VkImage dstImage; |
| 6459 | VkDeviceMemory srcMem; |
| 6460 | VkDeviceMemory destMem; |
| 6461 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6462 | |
| 6463 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6464 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6465 | image_create_info.pNext = NULL; |
| 6466 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6467 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6468 | image_create_info.extent.width = 32; |
| 6469 | image_create_info.extent.height = 32; |
| 6470 | image_create_info.extent.depth = 1; |
| 6471 | image_create_info.mipLevels = 1; |
| 6472 | image_create_info.arrayLayers = 1; |
| 6473 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6474 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6475 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6476 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6477 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6478 | err = |
| 6479 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6480 | ASSERT_VK_SUCCESS(err); |
| 6481 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6482 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6483 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6484 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6485 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6486 | err = |
| 6487 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6488 | ASSERT_VK_SUCCESS(err); |
| 6489 | |
| 6490 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6491 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6492 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6493 | memAlloc.pNext = NULL; |
| 6494 | memAlloc.allocationSize = 0; |
| 6495 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6496 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6497 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6498 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6499 | pass = |
| 6500 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6501 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6502 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6503 | ASSERT_VK_SUCCESS(err); |
| 6504 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6505 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6506 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6507 | pass = |
| 6508 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6509 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6510 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6511 | ASSERT_VK_SUCCESS(err); |
| 6512 | |
| 6513 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6514 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6515 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6516 | ASSERT_VK_SUCCESS(err); |
| 6517 | |
| 6518 | BeginCommandBuffer(); |
| 6519 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6520 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6521 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6522 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6523 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6524 | copyRegion.srcOffset.x = 0; |
| 6525 | copyRegion.srcOffset.y = 0; |
| 6526 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6527 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6528 | copyRegion.dstSubresource.mipLevel = 0; |
| 6529 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6530 | copyRegion.dstSubresource.layerCount = 0; |
| 6531 | copyRegion.dstOffset.x = 0; |
| 6532 | copyRegion.dstOffset.y = 0; |
| 6533 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6534 | copyRegion.extent.width = 1; |
| 6535 | copyRegion.extent.height = 1; |
| 6536 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6537 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6538 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6539 | EndCommandBuffer(); |
| 6540 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6541 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6542 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched " |
| 6543 | "source and dest image types'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6544 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6545 | } |
| 6546 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6547 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6548 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6549 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6550 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6551 | } |
| 6552 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6553 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 6554 | VkResult err; |
| 6555 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6556 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6557 | m_errorMonitor->SetDesiredFailureMsg( |
| 6558 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6559 | "vkCmdResolveImage called with source sample count less than 2."); |
| 6560 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6561 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6562 | |
| 6563 | // 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] | 6564 | VkImage srcImage; |
| 6565 | VkImage dstImage; |
| 6566 | VkDeviceMemory srcMem; |
| 6567 | VkDeviceMemory destMem; |
| 6568 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6569 | |
| 6570 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6571 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6572 | image_create_info.pNext = NULL; |
| 6573 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6574 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6575 | image_create_info.extent.width = 32; |
| 6576 | image_create_info.extent.height = 1; |
| 6577 | image_create_info.extent.depth = 1; |
| 6578 | image_create_info.mipLevels = 1; |
| 6579 | image_create_info.arrayLayers = 1; |
| 6580 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6581 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6582 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6583 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6584 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6585 | err = |
| 6586 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6587 | ASSERT_VK_SUCCESS(err); |
| 6588 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6589 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6590 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6591 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6592 | err = |
| 6593 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6594 | ASSERT_VK_SUCCESS(err); |
| 6595 | |
| 6596 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6597 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6598 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6599 | memAlloc.pNext = NULL; |
| 6600 | memAlloc.allocationSize = 0; |
| 6601 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6602 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6603 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6604 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6605 | pass = |
| 6606 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6607 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6608 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6609 | ASSERT_VK_SUCCESS(err); |
| 6610 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6611 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6612 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6613 | pass = |
| 6614 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6615 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6616 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6617 | ASSERT_VK_SUCCESS(err); |
| 6618 | |
| 6619 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6620 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6621 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6622 | ASSERT_VK_SUCCESS(err); |
| 6623 | |
| 6624 | BeginCommandBuffer(); |
| 6625 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6626 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6627 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6628 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6629 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6630 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6631 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6632 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6633 | resolveRegion.srcOffset.x = 0; |
| 6634 | resolveRegion.srcOffset.y = 0; |
| 6635 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6636 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6637 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6638 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6639 | resolveRegion.dstSubresource.layerCount = 0; |
| 6640 | resolveRegion.dstOffset.x = 0; |
| 6641 | resolveRegion.dstOffset.y = 0; |
| 6642 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6643 | resolveRegion.extent.width = 1; |
| 6644 | resolveRegion.extent.height = 1; |
| 6645 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6646 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6647 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6648 | EndCommandBuffer(); |
| 6649 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6650 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6651 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with source " |
| 6652 | "sample count less than 2.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6653 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6654 | } |
| 6655 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6656 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6657 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6658 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6659 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6660 | } |
| 6661 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6662 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 6663 | VkResult err; |
| 6664 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6665 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6666 | m_errorMonitor->SetDesiredFailureMsg( |
| 6667 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6668 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 6669 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6670 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6671 | |
| 6672 | // Create two images of sample count 2 and try to Resolve between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6673 | VkImage srcImage; |
| 6674 | VkImage dstImage; |
| 6675 | VkDeviceMemory srcMem; |
| 6676 | VkDeviceMemory destMem; |
| 6677 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6678 | |
| 6679 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6680 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6681 | image_create_info.pNext = NULL; |
| 6682 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6683 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6684 | image_create_info.extent.width = 32; |
| 6685 | image_create_info.extent.height = 1; |
| 6686 | image_create_info.extent.depth = 1; |
| 6687 | image_create_info.mipLevels = 1; |
| 6688 | image_create_info.arrayLayers = 1; |
| 6689 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6690 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6691 | // Note: Some implementations expect color attachment usage for any |
| 6692 | // multisample surface |
| 6693 | image_create_info.usage = |
| 6694 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6695 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6696 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6697 | err = |
| 6698 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6699 | ASSERT_VK_SUCCESS(err); |
| 6700 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6701 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6702 | // Note: Some implementations expect color attachment usage for any |
| 6703 | // multisample surface |
| 6704 | image_create_info.usage = |
| 6705 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6706 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6707 | err = |
| 6708 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6709 | ASSERT_VK_SUCCESS(err); |
| 6710 | |
| 6711 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6712 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6713 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6714 | memAlloc.pNext = NULL; |
| 6715 | memAlloc.allocationSize = 0; |
| 6716 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6717 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6718 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6719 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6720 | pass = |
| 6721 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6722 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6723 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6724 | ASSERT_VK_SUCCESS(err); |
| 6725 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6726 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6727 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6728 | pass = |
| 6729 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6730 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6731 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6732 | ASSERT_VK_SUCCESS(err); |
| 6733 | |
| 6734 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6735 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6736 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6737 | ASSERT_VK_SUCCESS(err); |
| 6738 | |
| 6739 | BeginCommandBuffer(); |
| 6740 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6741 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6742 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6743 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6744 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6745 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6746 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6747 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6748 | resolveRegion.srcOffset.x = 0; |
| 6749 | resolveRegion.srcOffset.y = 0; |
| 6750 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6751 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6752 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6753 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6754 | resolveRegion.dstSubresource.layerCount = 0; |
| 6755 | resolveRegion.dstOffset.x = 0; |
| 6756 | resolveRegion.dstOffset.y = 0; |
| 6757 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6758 | resolveRegion.extent.width = 1; |
| 6759 | resolveRegion.extent.height = 1; |
| 6760 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6761 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6762 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6763 | EndCommandBuffer(); |
| 6764 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6765 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6766 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with dest " |
| 6767 | "sample count greater than 1.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6768 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6769 | } |
| 6770 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6771 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6772 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6773 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6774 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6775 | } |
| 6776 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6777 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 6778 | VkResult err; |
| 6779 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6780 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6781 | m_errorMonitor->SetDesiredFailureMsg( |
| 6782 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6783 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 6784 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6785 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6786 | |
| 6787 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6788 | VkImage srcImage; |
| 6789 | VkImage dstImage; |
| 6790 | VkDeviceMemory srcMem; |
| 6791 | VkDeviceMemory destMem; |
| 6792 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6793 | |
| 6794 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6795 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6796 | image_create_info.pNext = NULL; |
| 6797 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6798 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6799 | image_create_info.extent.width = 32; |
| 6800 | image_create_info.extent.height = 1; |
| 6801 | image_create_info.extent.depth = 1; |
| 6802 | image_create_info.mipLevels = 1; |
| 6803 | image_create_info.arrayLayers = 1; |
| 6804 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6805 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6806 | // Note: Some implementations expect color attachment usage for any |
| 6807 | // multisample surface |
| 6808 | image_create_info.usage = |
| 6809 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6810 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6811 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6812 | err = |
| 6813 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6814 | ASSERT_VK_SUCCESS(err); |
| 6815 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6816 | // Set format to something other than source image |
| 6817 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 6818 | // Note: Some implementations expect color attachment usage for any |
| 6819 | // multisample surface |
| 6820 | image_create_info.usage = |
| 6821 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6822 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6823 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6824 | err = |
| 6825 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6826 | ASSERT_VK_SUCCESS(err); |
| 6827 | |
| 6828 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6829 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6830 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6831 | memAlloc.pNext = NULL; |
| 6832 | memAlloc.allocationSize = 0; |
| 6833 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6834 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6835 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6836 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6837 | pass = |
| 6838 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6839 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6840 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6841 | ASSERT_VK_SUCCESS(err); |
| 6842 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6843 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6844 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6845 | pass = |
| 6846 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6847 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6848 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6849 | ASSERT_VK_SUCCESS(err); |
| 6850 | |
| 6851 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6852 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6853 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6854 | ASSERT_VK_SUCCESS(err); |
| 6855 | |
| 6856 | BeginCommandBuffer(); |
| 6857 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6858 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6859 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6860 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6861 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6862 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6863 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6864 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6865 | resolveRegion.srcOffset.x = 0; |
| 6866 | resolveRegion.srcOffset.y = 0; |
| 6867 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6868 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6869 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6870 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6871 | resolveRegion.dstSubresource.layerCount = 0; |
| 6872 | resolveRegion.dstOffset.x = 0; |
| 6873 | resolveRegion.dstOffset.y = 0; |
| 6874 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6875 | resolveRegion.extent.width = 1; |
| 6876 | resolveRegion.extent.height = 1; |
| 6877 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6878 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6879 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6880 | EndCommandBuffer(); |
| 6881 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6882 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6883 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with " |
| 6884 | "unmatched source and dest formats.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6885 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6886 | } |
| 6887 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6888 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6889 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6890 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6891 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6892 | } |
| 6893 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6894 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 6895 | VkResult err; |
| 6896 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6897 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6898 | m_errorMonitor->SetDesiredFailureMsg( |
| 6899 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6900 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 6901 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6902 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6903 | |
| 6904 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6905 | VkImage srcImage; |
| 6906 | VkImage dstImage; |
| 6907 | VkDeviceMemory srcMem; |
| 6908 | VkDeviceMemory destMem; |
| 6909 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6910 | |
| 6911 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6912 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6913 | image_create_info.pNext = NULL; |
| 6914 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6915 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6916 | image_create_info.extent.width = 32; |
| 6917 | image_create_info.extent.height = 1; |
| 6918 | image_create_info.extent.depth = 1; |
| 6919 | image_create_info.mipLevels = 1; |
| 6920 | image_create_info.arrayLayers = 1; |
| 6921 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6922 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6923 | // Note: Some implementations expect color attachment usage for any |
| 6924 | // multisample surface |
| 6925 | image_create_info.usage = |
| 6926 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6927 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6928 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6929 | err = |
| 6930 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6931 | ASSERT_VK_SUCCESS(err); |
| 6932 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6933 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6934 | // Note: Some implementations expect color attachment usage for any |
| 6935 | // multisample surface |
| 6936 | image_create_info.usage = |
| 6937 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6938 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6939 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6940 | err = |
| 6941 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6942 | ASSERT_VK_SUCCESS(err); |
| 6943 | |
| 6944 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6945 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6946 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6947 | memAlloc.pNext = NULL; |
| 6948 | memAlloc.allocationSize = 0; |
| 6949 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6950 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6951 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6952 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6953 | pass = |
| 6954 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6955 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6956 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6957 | ASSERT_VK_SUCCESS(err); |
| 6958 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6959 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6960 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6961 | pass = |
| 6962 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6963 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6964 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6965 | ASSERT_VK_SUCCESS(err); |
| 6966 | |
| 6967 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6968 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6969 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6970 | ASSERT_VK_SUCCESS(err); |
| 6971 | |
| 6972 | BeginCommandBuffer(); |
| 6973 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6974 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6975 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6976 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6977 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6978 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6979 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6980 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6981 | resolveRegion.srcOffset.x = 0; |
| 6982 | resolveRegion.srcOffset.y = 0; |
| 6983 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6984 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6985 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6986 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6987 | resolveRegion.dstSubresource.layerCount = 0; |
| 6988 | resolveRegion.dstOffset.x = 0; |
| 6989 | resolveRegion.dstOffset.y = 0; |
| 6990 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6991 | resolveRegion.extent.width = 1; |
| 6992 | resolveRegion.extent.height = 1; |
| 6993 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6994 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6995 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6996 | EndCommandBuffer(); |
| 6997 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6998 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6999 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with " |
| 7000 | "unmatched source and dest image types.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7001 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7002 | } |
| 7003 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7004 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7005 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7006 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 7007 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7008 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7009 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7010 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7011 | // 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] | 7012 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 7013 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7014 | // The image format check comes 2nd in validation so we trigger it first, |
| 7015 | // 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] | 7016 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7017 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7018 | m_errorMonitor->SetDesiredFailureMsg( |
| 7019 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7020 | "Combination depth/stencil image formats can have only the "); |
| 7021 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7022 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7023 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7024 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7025 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 7026 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7027 | |
| 7028 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7029 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7030 | ds_pool_ci.pNext = NULL; |
| 7031 | ds_pool_ci.maxSets = 1; |
| 7032 | ds_pool_ci.poolSizeCount = 1; |
| 7033 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7034 | |
| 7035 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7036 | err = |
| 7037 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7038 | ASSERT_VK_SUCCESS(err); |
| 7039 | |
| 7040 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7041 | dsl_binding.binding = 0; |
| 7042 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 7043 | dsl_binding.descriptorCount = 1; |
| 7044 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7045 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7046 | |
| 7047 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7048 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7049 | ds_layout_ci.pNext = NULL; |
| 7050 | ds_layout_ci.bindingCount = 1; |
| 7051 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7052 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7053 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7054 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7055 | ASSERT_VK_SUCCESS(err); |
| 7056 | |
| 7057 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7058 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7059 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7060 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7061 | alloc_info.descriptorPool = ds_pool; |
| 7062 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7063 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7064 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7065 | ASSERT_VK_SUCCESS(err); |
| 7066 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7067 | VkImage image_bad; |
| 7068 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7069 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7070 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7071 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7072 | const int32_t tex_width = 32; |
| 7073 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7074 | |
| 7075 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7076 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7077 | image_create_info.pNext = NULL; |
| 7078 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7079 | image_create_info.format = tex_format_bad; |
| 7080 | image_create_info.extent.width = tex_width; |
| 7081 | image_create_info.extent.height = tex_height; |
| 7082 | image_create_info.extent.depth = 1; |
| 7083 | image_create_info.mipLevels = 1; |
| 7084 | image_create_info.arrayLayers = 1; |
| 7085 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7086 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7087 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 7088 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 7089 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7090 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7091 | err = |
| 7092 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7093 | ASSERT_VK_SUCCESS(err); |
| 7094 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7095 | image_create_info.usage = |
| 7096 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 7097 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 7098 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7099 | ASSERT_VK_SUCCESS(err); |
| 7100 | |
| 7101 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7102 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7103 | image_view_create_info.image = image_bad; |
| 7104 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7105 | image_view_create_info.format = tex_format_bad; |
| 7106 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 7107 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 7108 | image_view_create_info.subresourceRange.layerCount = 1; |
| 7109 | image_view_create_info.subresourceRange.levelCount = 1; |
| 7110 | image_view_create_info.subresourceRange.aspectMask = |
| 7111 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7112 | |
| 7113 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7114 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 7115 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7116 | |
| 7117 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7118 | FAIL() << "Did not receive Error 'Combination depth-stencil image " |
| 7119 | "formats can have only the....'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7120 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7121 | } |
| 7122 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7123 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 7124 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7125 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7126 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7127 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7128 | #endif // IMAGE_TESTS |
| 7129 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7130 | int main(int argc, char **argv) { |
| 7131 | int result; |
| 7132 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 7133 | #ifdef ANDROID |
| 7134 | int vulkanSupport = InitVulkan(); |
| 7135 | if (vulkanSupport == 0) |
| 7136 | return 1; |
| 7137 | #endif |
| 7138 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7139 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 7140 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7141 | |
| 7142 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 7143 | |
| 7144 | result = RUN_ALL_TESTS(); |
| 7145 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 7146 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7147 | return result; |
| 7148 | } |