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 | |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 35 | #include <vulkan/vulkan.h> |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 36 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 37 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 38 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 39 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 40 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 41 | #define GLM_FORCE_RADIANS |
| 42 | #include "glm/glm.hpp" |
| 43 | #include <glm/gtc/matrix_transform.hpp> |
| 44 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 45 | #define MEM_TRACKER_TESTS 1 |
| 46 | #define OBJ_TRACKER_TESTS 1 |
| 47 | #define DRAW_STATE_TESTS 1 |
| 48 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 49 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 50 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 51 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 52 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 53 | //-------------------------------------------------------------------------------------- |
| 54 | // Mesh and VertexFormat Data |
| 55 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 56 | struct Vertex { |
| 57 | float posX, posY, posZ, posW; // Position data |
| 58 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 59 | }; |
| 60 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 61 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 62 | |
| 63 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 64 | BsoFailNone = 0x00000000, |
| 65 | BsoFailLineWidth = 0x00000001, |
| 66 | BsoFailDepthBias = 0x00000002, |
| 67 | BsoFailViewport = 0x00000004, |
| 68 | BsoFailScissor = 0x00000008, |
| 69 | BsoFailBlend = 0x00000010, |
| 70 | BsoFailDepthBounds = 0x00000020, |
| 71 | BsoFailStencilReadMask = 0x00000040, |
| 72 | BsoFailStencilWriteMask = 0x00000080, |
| 73 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 74 | } BsoFailSelect; |
| 75 | |
| 76 | struct vktriangle_vs_uniform { |
| 77 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 78 | float mvp[4][4]; |
| 79 | float position[3][4]; |
| 80 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 81 | }; |
| 82 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 83 | static const char bindStateVertShaderText[] = |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 84 | "#version 400\n" |
| 85 | "#extension GL_ARB_separate_shader_objects : require\n" |
| 86 | "#extension GL_ARB_shading_language_420pack : require\n" |
| 87 | "vec2 vertices[3];\n" |
| 88 | "out gl_PerVertex {\n" |
| 89 | " vec4 gl_Position;\n" |
| 90 | "};\n" |
| 91 | "void main() {\n" |
| 92 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 93 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 94 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 95 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 96 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 97 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 98 | static const char bindStateFragShaderText[] = |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 99 | "#version 400\n" |
| 100 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 101 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 102 | "\n" |
| 103 | "layout(location = 0) out vec4 uFragColor;\n" |
| 104 | "void main(){\n" |
| 105 | " uFragColor = vec4(0,1,0,1);\n" |
| 106 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 107 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 108 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 109 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 110 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 111 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 112 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 113 | // ******************************************************** |
| 114 | // ErrorMonitor Usage: |
| 115 | // |
| 116 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 117 | // encountered log messages. Passing NULL will match all log messages. |
| 118 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 119 | // |
| 120 | // Call DesiredMsgFound to determine if the desired failure message |
| 121 | // was encountered. |
| 122 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 123 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 124 | public: |
| 125 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 126 | test_platform_thread_create_mutex(&m_mutex); |
| 127 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 128 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 129 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 130 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 131 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 132 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 133 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 134 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 135 | m_desiredMsg.clear(); |
| 136 | m_failureMsg.clear(); |
| 137 | m_otherMsgs.clear(); |
| 138 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 139 | m_msgFound = VK_FALSE; |
| 140 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 141 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 142 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 143 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 144 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 145 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 146 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 147 | if (m_bailout != NULL) { |
| 148 | *m_bailout = true; |
| 149 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 150 | string errorString(msgString); |
| 151 | if (msgFlags & m_msgFlags) { |
| 152 | if (errorString.find(m_desiredMsg) != string::npos) { |
| 153 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 154 | m_msgFound = VK_TRUE; |
| 155 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 156 | } else { |
| 157 | m_otherMsgs.push_back(errorString); |
| 158 | } |
| 159 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 160 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 161 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 162 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 163 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 164 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 165 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 166 | string GetFailureMsg(void) { return m_failureMsg; } |
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 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
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 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 171 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 172 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 173 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 174 | cout << "Other error messages logged for this test were:" << endl; |
| 175 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 176 | cout << " " << *iter << endl; |
| 177 | } |
| 178 | } |
| 179 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 180 | private: |
| 181 | VkFlags m_msgFlags; |
| 182 | string m_desiredMsg; |
| 183 | string m_failureMsg; |
| 184 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 185 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 186 | bool *m_bailout; |
| 187 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 188 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 189 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 190 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 191 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 192 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 193 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 194 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 195 | (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] | 196 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 197 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 198 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 199 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 200 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 201 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 202 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 203 | class VkLayerTest : public VkRenderFramework { |
| 204 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 205 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 206 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 207 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 208 | BsoFailSelect failMask); |
| 209 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 210 | VkPipelineObj &pipelineobj, |
| 211 | VkDescriptorSetObj &descriptorSet, |
| 212 | BsoFailSelect failMask); |
| 213 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 214 | VkDescriptorSetObj &descriptorSet, |
| 215 | BsoFailSelect failMask) { |
| 216 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 217 | failMask); |
| 218 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 219 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 220 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 221 | VkResult BeginCommandBuffer() { |
| 222 | return BeginCommandBuffer(*m_commandBuffer); |
| 223 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 224 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 225 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 226 | uint32_t firstVertex, uint32_t firstInstance) { |
| 227 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 228 | firstInstance); |
| 229 | } |
| 230 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 231 | uint32_t firstIndex, int32_t vertexOffset, |
| 232 | uint32_t firstInstance) { |
| 233 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 234 | vertexOffset, firstInstance); |
| 235 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 236 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 237 | void QueueCommandBuffer(const VkFence &fence) { |
| 238 | m_commandBuffer->QueueCommandBuffer(fence); |
| 239 | } |
| 240 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 241 | VkDeviceSize offset, uint32_t binding) { |
| 242 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 243 | } |
| 244 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 245 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 246 | } |
| 247 | |
| 248 | protected: |
| 249 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 250 | |
| 251 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 252 | std::vector<const char *> instance_layer_names; |
| 253 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 254 | std::vector<const char *> instance_extension_names; |
| 255 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 256 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 257 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 258 | /* |
| 259 | * Since CreateDbgMsgCallback is an instance level extension call |
| 260 | * any extension / layer that utilizes that feature also needs |
| 261 | * to be enabled at create instance time. |
| 262 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 263 | // Use Threading layer first to protect others from |
| 264 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 265 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 266 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 267 | instance_layer_names.push_back("VK_LAYER_LUNARG_mem_tracker"); |
| 268 | instance_layer_names.push_back("VK_LAYER_LUNARG_draw_state"); |
| 269 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 270 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 271 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 272 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 273 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 274 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 275 | device_layer_names.push_back("VK_LAYER_LUNARG_mem_tracker"); |
| 276 | device_layer_names.push_back("VK_LAYER_LUNARG_draw_state"); |
| 277 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 278 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 279 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 280 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 281 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 282 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 283 | this->app_info.pApplicationName = "layer_tests"; |
| 284 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 285 | this->app_info.pEngineName = "unittest"; |
| 286 | this->app_info.engineVersion = 1; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 287 | this->app_info.apiVersion = VK_API_VERSION; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 288 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 289 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 290 | InitFramework(instance_layer_names, device_layer_names, |
| 291 | instance_extension_names, device_extension_names, |
| 292 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | virtual void TearDown() { |
| 296 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 297 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 298 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 299 | } |
| 300 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 301 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 302 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 303 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 304 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 305 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 306 | |
| 307 | /* |
| 308 | * For render test all drawing happens in a single render pass |
| 309 | * on a single command buffer. |
| 310 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 311 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 312 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | return result; |
| 316 | } |
| 317 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 318 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 319 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 320 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 321 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 322 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 323 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 324 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 325 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 326 | |
| 327 | return result; |
| 328 | } |
| 329 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 330 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 331 | const char *fragShaderText, |
| 332 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 333 | // Create identity matrix |
| 334 | int i; |
| 335 | struct vktriangle_vs_uniform data; |
| 336 | |
| 337 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 338 | glm::mat4 View = glm::mat4(1.0f); |
| 339 | glm::mat4 Model = glm::mat4(1.0f); |
| 340 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 341 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 342 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 343 | |
| 344 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 345 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 346 | static const Vertex tri_data[] = { |
| 347 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 348 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 349 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 350 | }; |
| 351 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 352 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 353 | data.position[i][0] = tri_data[i].posX; |
| 354 | data.position[i][1] = tri_data[i].posY; |
| 355 | data.position[i][2] = tri_data[i].posZ; |
| 356 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 357 | data.color[i][0] = tri_data[i].r; |
| 358 | data.color[i][1] = tri_data[i].g; |
| 359 | data.color[i][2] = tri_data[i].b; |
| 360 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 364 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 365 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 366 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 367 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 368 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 369 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 370 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 371 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 372 | |
| 373 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 374 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 375 | pipelineobj.AddShader(&vs); |
| 376 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 377 | if (failMask & BsoFailLineWidth) { |
| 378 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
| 379 | } |
| 380 | if (failMask & BsoFailDepthBias) { |
| 381 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
| 382 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 383 | // Viewport and scissors must stay in synch or other errors will occur than |
| 384 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 385 | if (failMask & BsoFailViewport) { |
| 386 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 387 | m_viewports.clear(); |
| 388 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 389 | } |
| 390 | if (failMask & BsoFailScissor) { |
| 391 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 392 | m_scissors.clear(); |
| 393 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 394 | } |
| 395 | if (failMask & BsoFailBlend) { |
| 396 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
| 397 | } |
| 398 | if (failMask & BsoFailDepthBounds) { |
| 399 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 400 | } |
| 401 | if (failMask & BsoFailStencilReadMask) { |
| 402 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 403 | } |
| 404 | if (failMask & BsoFailStencilWriteMask) { |
| 405 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 406 | } |
| 407 | if (failMask & BsoFailStencilReference) { |
| 408 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 409 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 410 | |
| 411 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 412 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 413 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 414 | |
| 415 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 416 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 417 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 418 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 419 | |
| 420 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 421 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 422 | |
| 423 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 424 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 425 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 426 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 427 | } |
| 428 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 429 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 430 | VkPipelineObj &pipelineobj, |
| 431 | VkDescriptorSetObj &descriptorSet, |
| 432 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 433 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 434 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 435 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 436 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 437 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 438 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 439 | } |
| 440 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 441 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 442 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 443 | // correctly |
| 444 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 445 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 446 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 447 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 448 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 449 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 450 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 451 | |
| 452 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 453 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 454 | ds_ci.pNext = NULL; |
| 455 | ds_ci.depthTestEnable = VK_FALSE; |
| 456 | ds_ci.depthWriteEnable = VK_TRUE; |
| 457 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 458 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
| 459 | ds_ci.stencilTestEnable = VK_TRUE; |
| 460 | ds_ci.front = stencil; |
| 461 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 462 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 463 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 464 | pipelineobj.SetViewport(m_viewports); |
| 465 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 466 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 467 | VkResult err = pipelineobj.CreateVKPipeline( |
| 468 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 469 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 470 | commandBuffer->BindPipeline(pipelineobj); |
| 471 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | // ******************************************************************************************************************** |
| 475 | // ******************************************************************************************************************** |
| 476 | // ******************************************************************************************************************** |
| 477 | // ******************************************************************************************************************** |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 478 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 479 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 480 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 481 | { |
| 482 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 483 | VkFenceCreateInfo fenceInfo = {}; |
| 484 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 485 | fenceInfo.pNext = NULL; |
| 486 | fenceInfo.flags = 0; |
| 487 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 488 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 489 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 490 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 491 | |
| 492 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 493 | vk_testing::Buffer buffer; |
| 494 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 495 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 496 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 497 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 498 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 499 | |
| 500 | testFence.init(*m_device, fenceInfo); |
| 501 | |
| 502 | // Bypass framework since it does the waits automatically |
| 503 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 504 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 505 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 506 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 507 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 508 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 509 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 510 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 511 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 512 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 513 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 514 | |
| 515 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 516 | ASSERT_VK_SUCCESS( err ); |
| 517 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 518 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 519 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 520 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 521 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 522 | FAIL() << "Did not receive Error 'Resetting CB (0xaddress) before it has completed. You must check CB flag before.'"; |
| 523 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 524 | } |
| 525 | } |
| 526 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 527 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 528 | { |
| 529 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 530 | VkFenceCreateInfo fenceInfo = {}; |
| 531 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 532 | fenceInfo.pNext = NULL; |
| 533 | fenceInfo.flags = 0; |
| 534 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 535 | 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] | 536 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 537 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 538 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 539 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 540 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 541 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 542 | 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] | 543 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 544 | |
| 545 | testFence.init(*m_device, fenceInfo); |
| 546 | |
| 547 | // Bypass framework since it does the waits automatically |
| 548 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 549 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 550 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 551 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 552 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 553 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 554 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 555 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 556 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 557 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 558 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 559 | |
| 560 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 561 | ASSERT_VK_SUCCESS( err ); |
| 562 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 563 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 564 | VkCommandBufferBeginInfo info = {}; |
| 565 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 566 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 567 | info.renderPass = VK_NULL_HANDLE; |
| 568 | info.subpass = 0; |
| 569 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 570 | info.occlusionQueryEnable = VK_FALSE; |
| 571 | info.queryFlags = 0; |
| 572 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 573 | |
| 574 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 575 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 576 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 577 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 578 | FAIL() << "Did not receive Error 'Calling vkBeginCommandBuffer() on an active CB (0xaddress) before it has completed'"; |
| 579 | m_errorMonitor->DumpFailureMsgs(); |
| 580 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 581 | } |
| 582 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 583 | #endif |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 584 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 585 | VkResult err; |
| 586 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 587 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 588 | m_errorMonitor->SetDesiredFailureMsg( |
| 589 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 590 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 591 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 592 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 593 | |
| 594 | // 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] | 595 | VkImage image; |
| 596 | VkDeviceMemory mem; |
| 597 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 598 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 599 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 600 | const int32_t tex_width = 32; |
| 601 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 602 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 603 | VkImageCreateInfo image_create_info = {}; |
| 604 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 605 | image_create_info.pNext = NULL; |
| 606 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 607 | image_create_info.format = tex_format; |
| 608 | image_create_info.extent.width = tex_width; |
| 609 | image_create_info.extent.height = tex_height; |
| 610 | image_create_info.extent.depth = 1; |
| 611 | image_create_info.mipLevels = 1; |
| 612 | image_create_info.arrayLayers = 1; |
| 613 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 614 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 615 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 616 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 617 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 618 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 619 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 620 | mem_alloc.pNext = NULL; |
| 621 | mem_alloc.allocationSize = 0; |
| 622 | // Introduce failure, do NOT set memProps to |
| 623 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 624 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 625 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 626 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 627 | ASSERT_VK_SUCCESS(err); |
| 628 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 629 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 630 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 631 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 632 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 633 | pass = |
| 634 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 635 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 636 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 637 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 638 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 639 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 640 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 641 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 642 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 643 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 644 | ASSERT_VK_SUCCESS(err); |
| 645 | |
| 646 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 647 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 648 | ASSERT_VK_SUCCESS(err); |
| 649 | |
| 650 | // Map memory as if to initialize the image |
| 651 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 652 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 653 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 654 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 655 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 656 | FAIL() << "Did not receive Error 'Error received did not match " |
| 657 | "expected error message from vkMapMemory in MemTracker'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 658 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 659 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 660 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 661 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 662 | } |
| 663 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 664 | // TODO : Is this test still valid. Not sure it is with updates to memory |
| 665 | // binding model |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 666 | // Verify and delete the test of fix the check |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 667 | // TEST_F(VkLayerTest, FreeBoundMemory) |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 668 | //{ |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 669 | // VkResult err; |
| 670 | // |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 671 | // m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 672 | // "Freeing memory object while it still has references"); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 673 | // |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 674 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 675 | |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 676 | // // Create an image, allocate memory, free it, and then try to bind it |
| 677 | // VkImage image; |
| 678 | // VkDeviceMemory mem; |
| 679 | // VkMemoryRequirements mem_reqs; |
| 680 | // |
| 681 | // const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 682 | // const int32_t tex_width = 32; |
| 683 | // const int32_t tex_height = 32; |
| 684 | // |
| 685 | // const VkImageCreateInfo image_create_info = { |
| 686 | // .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 687 | // .pNext = NULL, |
| 688 | // .imageType = VK_IMAGE_TYPE_2D, |
| 689 | // .format = tex_format, |
| 690 | // .extent = { tex_width, tex_height, 1 }, |
| 691 | // .mipLevels = 1, |
| 692 | // .arraySize = 1, |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 693 | // .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 694 | // .tiling = VK_IMAGE_TILING_LINEAR, |
| 695 | // .usage = VK_IMAGE_USAGE_SAMPLED_BIT, |
| 696 | // .flags = 0, |
| 697 | // }; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 698 | // VkMemoryAllocateInfo mem_alloc = { |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 699 | // .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 700 | // .pNext = NULL, |
| 701 | // .allocationSize = 0, |
| 702 | // .memoryTypeIndex = 0, |
| 703 | // }; |
| 704 | // |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 705 | // err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 706 | // ASSERT_VK_SUCCESS(err); |
| 707 | // |
| 708 | // err = vkGetImageMemoryRequirements(m_device->device(), |
| 709 | // image, |
| 710 | // &mem_reqs); |
| 711 | // ASSERT_VK_SUCCESS(err); |
| 712 | // |
| 713 | // mem_alloc.allocationSize = mem_reqs.size; |
| 714 | // |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 715 | // err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 716 | // 0); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 717 | // ASSERT_VK_SUCCESS(err); |
| 718 | // |
| 719 | // // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 720 | // err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 721 | // ASSERT_VK_SUCCESS(err); |
| 722 | // |
| 723 | // // Bind memory to Image object |
| 724 | // err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 725 | // ASSERT_VK_SUCCESS(err); |
| 726 | // |
| 727 | // // Introduce validation failure, free memory while still bound to object |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 728 | // vkFreeMemory(m_device->device(), mem, NULL); |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 729 | // |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 730 | // if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 731 | // FAIL() << "Did not receive Warning 'Freeing memory object while it |
| 732 | // still has references'"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 733 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 734 | // } |
| 735 | //} |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 736 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 737 | TEST_F(VkLayerTest, RebindMemory) { |
| 738 | VkResult err; |
| 739 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 740 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 741 | m_errorMonitor->SetDesiredFailureMsg( |
| 742 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 743 | "which has already been bound to mem object"); |
| 744 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 745 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 746 | |
| 747 | // 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] | 748 | VkImage image; |
| 749 | VkDeviceMemory mem1; |
| 750 | VkDeviceMemory mem2; |
| 751 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 752 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 753 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 754 | const int32_t tex_width = 32; |
| 755 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 756 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 757 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 758 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 759 | image_create_info.pNext = NULL; |
| 760 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 761 | image_create_info.format = tex_format; |
| 762 | image_create_info.extent.width = tex_width; |
| 763 | image_create_info.extent.height = tex_height; |
| 764 | image_create_info.extent.depth = 1; |
| 765 | image_create_info.mipLevels = 1; |
| 766 | image_create_info.arrayLayers = 1; |
| 767 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 768 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 769 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 770 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 771 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 772 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 773 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 774 | mem_alloc.pNext = NULL; |
| 775 | mem_alloc.allocationSize = 0; |
| 776 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 777 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 778 | // Introduce failure, do NOT set memProps to |
| 779 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 780 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 781 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 782 | ASSERT_VK_SUCCESS(err); |
| 783 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 784 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 785 | |
| 786 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 787 | pass = |
| 788 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 789 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 790 | |
| 791 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 792 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 793 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 794 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 795 | ASSERT_VK_SUCCESS(err); |
| 796 | |
| 797 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 798 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 799 | ASSERT_VK_SUCCESS(err); |
| 800 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 801 | // Introduce validation failure, try to bind a different memory object to |
| 802 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 803 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 804 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 805 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 806 | FAIL() << "Did not receive Error when rebinding memory to an object"; |
| 807 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 808 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 809 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 810 | vkDestroyImage(m_device->device(), image, NULL); |
| 811 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 812 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 813 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 814 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 815 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 816 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 817 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 818 | m_errorMonitor->SetDesiredFailureMsg( |
| 819 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 820 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 821 | |
| 822 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 823 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 824 | fenceInfo.pNext = NULL; |
| 825 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 826 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 827 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 828 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 829 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 830 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 831 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 832 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 833 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 834 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 835 | |
| 836 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 837 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 838 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 839 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 840 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 841 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 842 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 843 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 844 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 845 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 846 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 847 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 848 | |
| 849 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 850 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 851 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 852 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 853 | FAIL() << "Did not receive Error 'VkQueueSubmit with fence in " |
| 854 | "SIGNALED_STATE'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 855 | m_errorMonitor->DumpFailureMsgs(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 856 | } |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 857 | } |
| 858 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 859 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 860 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 861 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 862 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 863 | fenceInfo.pNext = NULL; |
| 864 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 865 | // TODO: verify that this matches layer |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 866 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 867 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 868 | "submitted to VkResetFences in UNSIGNALED STATE"); |
| 869 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 870 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 871 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 872 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 873 | vkResetFences(m_device->device(), 1, fences); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 874 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 875 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 876 | FAIL() << "Did not receive Error 'VkResetFences with fence in " |
| 877 | "UNSIGNALED_STATE'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 878 | m_errorMonitor->DumpFailureMsgs(); |
| 879 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 880 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 881 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 882 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 883 | #if 0 |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 884 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 885 | { |
| 886 | // Initiate Draw w/o a PSO bound |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 887 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 888 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 889 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 890 | |
| 891 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 892 | VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 893 | BeginCommandBuffer(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 894 | |
| 895 | const VkExtent3D e3d = { |
| 896 | .width = 128, |
| 897 | .height = 128, |
| 898 | .depth = 1, |
| 899 | }; |
| 900 | const VkImageCreateInfo ici = { |
| 901 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 902 | .pNext = NULL, |
| 903 | .imageType = VK_IMAGE_TYPE_2D, |
| 904 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 905 | .extent = e3d, |
| 906 | .mipLevels = 1, |
| 907 | .arraySize = 1, |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 908 | .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 909 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | 660f0ca | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 910 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 911 | .flags = 0, |
| 912 | }; |
| 913 | |
| 914 | VkImage dsi; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 915 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 916 | VkDepthStencilView dsv; |
| 917 | const VkDepthStencilViewCreateInfo dsvci = { |
| 918 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 919 | .pNext = NULL, |
| 920 | .image = dsi, |
| 921 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 4a26189 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 922 | .baseArrayLayer = 0, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 923 | .arraySize = 1, |
| 924 | .flags = 0, |
| 925 | }; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 926 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 927 | |
| 928 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 929 | FAIL() << "Error received was not 'Invalid usage flag for image...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 930 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 931 | } |
| 932 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 933 | #endif // 0 |
| 934 | #endif // MEM_TRACKER_TESTS |
| 935 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 936 | #if OBJ_TRACKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 937 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 938 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 939 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 940 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 941 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 942 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 943 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 944 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 945 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 946 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 947 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 948 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 949 | |
| 950 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 951 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 952 | ds_pool_ci.pNext = NULL; |
| 953 | ds_pool_ci.maxSets = 1; |
| 954 | ds_pool_ci.poolSizeCount = 1; |
| 955 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 956 | |
| 957 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 958 | err = |
| 959 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 960 | ASSERT_VK_SUCCESS(err); |
| 961 | |
| 962 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 963 | dsl_binding.binding = 0; |
| 964 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 965 | dsl_binding.descriptorCount = 1; |
| 966 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 967 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 968 | |
| 969 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 970 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 971 | ds_layout_ci.pNext = NULL; |
| 972 | ds_layout_ci.bindingCount = 1; |
| 973 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 974 | |
| 975 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 976 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 977 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 978 | ASSERT_VK_SUCCESS(err); |
| 979 | |
| 980 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 981 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 982 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 983 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 984 | alloc_info.descriptorPool = ds_pool; |
| 985 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 986 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 987 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 988 | ASSERT_VK_SUCCESS(err); |
| 989 | |
| 990 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 991 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 992 | pipeline_layout_ci.pNext = NULL; |
| 993 | pipeline_layout_ci.setLayoutCount = 1; |
| 994 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 995 | |
| 996 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 997 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 998 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 999 | ASSERT_VK_SUCCESS(err); |
| 1000 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 1001 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1002 | |
| 1003 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1004 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1005 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1006 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1007 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1008 | FAIL() |
| 1009 | << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be'" |
| 1010 | << endl; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1011 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1012 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1013 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1014 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1015 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1016 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1017 | } |
| 1018 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1019 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 1020 | VkResult err; |
| 1021 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1022 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1023 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1024 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1025 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1026 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1027 | |
| 1028 | // 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] | 1029 | VkImage image; |
| 1030 | VkDeviceMemory mem; |
| 1031 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1032 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1033 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1034 | const int32_t tex_width = 32; |
| 1035 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1036 | |
| 1037 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1038 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1039 | image_create_info.pNext = NULL; |
| 1040 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1041 | image_create_info.format = tex_format; |
| 1042 | image_create_info.extent.width = tex_width; |
| 1043 | image_create_info.extent.height = tex_height; |
| 1044 | image_create_info.extent.depth = 1; |
| 1045 | image_create_info.mipLevels = 1; |
| 1046 | image_create_info.arrayLayers = 1; |
| 1047 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1048 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1049 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1050 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1051 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1052 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1053 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1054 | mem_alloc.pNext = NULL; |
| 1055 | mem_alloc.allocationSize = 0; |
| 1056 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1057 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1058 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1059 | ASSERT_VK_SUCCESS(err); |
| 1060 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1061 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1062 | |
| 1063 | mem_alloc.allocationSize = mem_reqs.size; |
| 1064 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1065 | pass = |
| 1066 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1067 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1068 | |
| 1069 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1070 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1071 | ASSERT_VK_SUCCESS(err); |
| 1072 | |
| 1073 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1074 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1075 | |
| 1076 | // Try to bind free memory that has been freed |
| 1077 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1078 | // This may very well return an error. |
| 1079 | (void)err; |
| 1080 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1081 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1082 | FAIL() << "Did not receive Error 'Invalid VkDeviceMemory Object " |
| 1083 | "0x<handle>'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1084 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1085 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1086 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1087 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1088 | } |
| 1089 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1090 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1091 | VkResult err; |
| 1092 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1093 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1094 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1095 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1096 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1097 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1098 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1099 | // Create an image object, allocate memory, destroy the object and then try |
| 1100 | // to bind it |
| 1101 | VkImage image; |
| 1102 | VkDeviceMemory mem; |
| 1103 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1104 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1105 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1106 | const int32_t tex_width = 32; |
| 1107 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1108 | |
| 1109 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1110 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1111 | image_create_info.pNext = NULL; |
| 1112 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1113 | image_create_info.format = tex_format; |
| 1114 | image_create_info.extent.width = tex_width; |
| 1115 | image_create_info.extent.height = tex_height; |
| 1116 | image_create_info.extent.depth = 1; |
| 1117 | image_create_info.mipLevels = 1; |
| 1118 | image_create_info.arrayLayers = 1; |
| 1119 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1120 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1121 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1122 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1123 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1124 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1125 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1126 | mem_alloc.pNext = NULL; |
| 1127 | mem_alloc.allocationSize = 0; |
| 1128 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1129 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1130 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1131 | ASSERT_VK_SUCCESS(err); |
| 1132 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1133 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1134 | |
| 1135 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1136 | pass = |
| 1137 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1138 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1139 | |
| 1140 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1141 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1142 | ASSERT_VK_SUCCESS(err); |
| 1143 | |
| 1144 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1145 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1146 | ASSERT_VK_SUCCESS(err); |
| 1147 | |
| 1148 | // Now Try to bind memory to this destroyed object |
| 1149 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1150 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1151 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1152 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1153 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1154 | FAIL() << "Did not receive Error 'Invalid VkImage Object 0x<handle>'"; |
| 1155 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1156 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1157 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1158 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1159 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1160 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1161 | #endif // OBJ_TRACKER_TESTS |
| 1162 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1163 | #if DRAW_STATE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1164 | TEST_F(VkLayerTest, LineWidthStateNotBound) { |
| 1165 | m_errorMonitor->SetDesiredFailureMsg( |
| 1166 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1167 | "Dynamic line width state not set for this command buffer"); |
| 1168 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1169 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line " |
| 1170 | "width state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1171 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1172 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1173 | BsoFailLineWidth); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1174 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1175 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1176 | FAIL() << "Did not receive Error 'Dynamic line width state not set for " |
| 1177 | "this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1178 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1179 | } |
| 1180 | } |
| 1181 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1182 | TEST_F(VkLayerTest, DepthBiasStateNotBound) { |
| 1183 | m_errorMonitor->SetDesiredFailureMsg( |
| 1184 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1185 | "Dynamic depth bias state not set for this command buffer"); |
| 1186 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1187 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth " |
| 1188 | "bias state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1189 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1190 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1191 | BsoFailDepthBias); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1192 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1193 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1194 | FAIL() << "Did not receive Error 'Dynamic depth bias state not set for " |
| 1195 | "this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1196 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1197 | } |
| 1198 | } |
| 1199 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1200 | // Disable these two tests until we can sort out how to track multiple layer |
| 1201 | // errors |
| 1202 | TEST_F(VkLayerTest, ViewportStateNotBound) { |
| 1203 | m_errorMonitor->SetDesiredFailureMsg( |
| 1204 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1205 | "Dynamic viewport state not set for this command buffer"); |
| 1206 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1207 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport " |
| 1208 | "state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1209 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1210 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1211 | BsoFailViewport); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1212 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1213 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1214 | FAIL() << "Did not recieve Error 'Dynamic scissor state not set for " |
| 1215 | "this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1216 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1217 | } |
| 1218 | } |
| 1219 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1220 | TEST_F(VkLayerTest, ScissorStateNotBound) { |
| 1221 | m_errorMonitor->SetDesiredFailureMsg( |
| 1222 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1223 | "Dynamic scissor state not set for this command buffer"); |
| 1224 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1225 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport " |
| 1226 | "state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1227 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1228 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1229 | BsoFailScissor); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1230 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1231 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1232 | FAIL() << "Did not recieve Error ' Expected: 'Dynamic scissor state " |
| 1233 | "not set for this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1234 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1235 | } |
| 1236 | } |
| 1237 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1238 | TEST_F(VkLayerTest, BlendStateNotBound) { |
| 1239 | m_errorMonitor->SetDesiredFailureMsg( |
| 1240 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1241 | "Dynamic blend object state not set for this command buffer"); |
| 1242 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1243 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend " |
| 1244 | "state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1245 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1246 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1247 | BsoFailBlend); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1248 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1249 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1250 | FAIL() << "Did not recieve Error 'Dynamic blend object state not set " |
| 1251 | "for this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1252 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1253 | } |
| 1254 | } |
| 1255 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1256 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) { |
| 1257 | m_errorMonitor->SetDesiredFailureMsg( |
| 1258 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1259 | "Dynamic depth bounds state not set for this command buffer"); |
| 1260 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1261 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth " |
| 1262 | "bounds state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1263 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1264 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1265 | BsoFailDepthBounds); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1266 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1267 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1268 | FAIL() << "Did not receive Error 'Dynamic depth bounds state not set " |
| 1269 | "for this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1270 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1271 | } |
| 1272 | } |
| 1273 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1274 | TEST_F(VkLayerTest, StencilReadMaskNotSet) { |
| 1275 | m_errorMonitor->SetDesiredFailureMsg( |
| 1276 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1277 | "Dynamic stencil read mask state not set for this command buffer"); |
| 1278 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1279 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1280 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1281 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1282 | "read mask is not set beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1283 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1284 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1285 | BsoFailStencilReadMask); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1286 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1287 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1288 | FAIL() << "Did not receive Error 'Dynamic stencil read mask state not " |
| 1289 | "set for this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1290 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1291 | } |
| 1292 | } |
| 1293 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1294 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) { |
| 1295 | m_errorMonitor->SetDesiredFailureMsg( |
| 1296 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1297 | "Dynamic stencil write mask state not set for this command buffer"); |
| 1298 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1299 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1300 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1301 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1302 | "write mask is not set beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1303 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1304 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1305 | BsoFailStencilWriteMask); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1306 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1307 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1308 | FAIL() << "Did not receive Error 'Dynamic stencil write mask state not " |
| 1309 | "set for this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1310 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1311 | } |
| 1312 | } |
| 1313 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1314 | TEST_F(VkLayerTest, StencilReferenceNotSet) { |
| 1315 | m_errorMonitor->SetDesiredFailureMsg( |
| 1316 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1317 | "Dynamic stencil reference state not set for this command buffer"); |
| 1318 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1319 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1320 | "reference is not set beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1321 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1322 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1323 | BsoFailStencilReference); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1324 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1325 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1326 | FAIL() << "Did not receive Error 'Dynamic stencil reference state not " |
| 1327 | "set for this command buffer'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1328 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1329 | } |
| 1330 | } |
| 1331 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1332 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1333 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1334 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1335 | m_errorMonitor->SetDesiredFailureMsg( |
| 1336 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1337 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 1338 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1339 | |
| 1340 | VkFenceCreateInfo fenceInfo = {}; |
| 1341 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1342 | fenceInfo.pNext = NULL; |
| 1343 | fenceInfo.flags = 0; |
| 1344 | |
| 1345 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1346 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1347 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1348 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1349 | // We luck out b/c by default the framework creates CB w/ the |
| 1350 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1351 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1352 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 1353 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1354 | EndCommandBuffer(); |
| 1355 | |
| 1356 | testFence.init(*m_device, fenceInfo); |
| 1357 | |
| 1358 | // Bypass framework since it does the waits automatically |
| 1359 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1360 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1361 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1362 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1363 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1364 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1365 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1366 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1367 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1368 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1369 | submit_info.pSignalSemaphores = NULL; |
| 1370 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1371 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 1372 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1373 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1374 | // Cause validation error by re-submitting cmd buffer that should only be |
| 1375 | // submitted once |
| 1376 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1377 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1378 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1379 | FAIL() << "Did not receive Error 'CB (0xaddress) was created w/ " |
| 1380 | "VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1381 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1382 | } |
| 1383 | } |
| 1384 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1385 | TEST_F(VkLayerTest, BindPipelineNoRenderPass) { |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1386 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1387 | VkResult err; |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1388 | |
| 1389 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1390 | "vkCmdBindPipeline: This call must be " |
| 1391 | "issued inside an active render pass"); |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1392 | |
| 1393 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1394 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1395 | |
| 1396 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1397 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1398 | ds_type_count.descriptorCount = 1; |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1399 | |
| 1400 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1401 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1402 | ds_pool_ci.pNext = NULL; |
| 1403 | ds_pool_ci.maxSets = 1; |
| 1404 | ds_pool_ci.poolSizeCount = 1; |
| 1405 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1406 | |
| 1407 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1408 | err = |
| 1409 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1410 | ASSERT_VK_SUCCESS(err); |
| 1411 | |
| 1412 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1413 | dsl_binding.binding = 0; |
| 1414 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1415 | dsl_binding.descriptorCount = 1; |
| 1416 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1417 | dsl_binding.pImmutableSamplers = NULL; |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1418 | |
| 1419 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1420 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1421 | ds_layout_ci.pNext = NULL; |
| 1422 | ds_layout_ci.bindingCount = 1; |
| 1423 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1424 | |
| 1425 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1426 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1427 | &ds_layout); |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1428 | ASSERT_VK_SUCCESS(err); |
| 1429 | |
| 1430 | VkDescriptorSet descriptorSet; |
| 1431 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 1432 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1433 | alloc_info.descriptorSetCount = 1; |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1434 | alloc_info.descriptorPool = ds_pool; |
| 1435 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1436 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1437 | &descriptorSet); |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1438 | ASSERT_VK_SUCCESS(err); |
| 1439 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1440 | pipe_ms_state_ci.sType = |
| 1441 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 1442 | pipe_ms_state_ci.pNext = NULL; |
| 1443 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 1444 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 1445 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 1446 | pipe_ms_state_ci.pSampleMask = NULL; |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1447 | |
| 1448 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1449 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1450 | pipeline_layout_ci.pNext = NULL; |
| 1451 | pipeline_layout_ci.setLayoutCount = 1; |
| 1452 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1453 | VkPipelineLayout pipeline_layout; |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1454 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1455 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1456 | &pipeline_layout); |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1457 | ASSERT_VK_SUCCESS(err); |
| 1458 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1459 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 1460 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1461 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 1462 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 1463 | this); // TODO - We shouldn't need a fragment shader |
| 1464 | // but add it to be able to run on more devices |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1465 | VkPipelineObj pipe(m_device); |
| 1466 | pipe.AddShader(&vs); |
| 1467 | pipe.AddShader(&fs); |
| 1468 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 1469 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 1470 | |
| 1471 | // Calls AllocateCommandBuffers |
| 1472 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 1473 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1474 | memset(&cmd_buf_info, 0, sizeof(VkCommandBufferBeginInfo)); |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1475 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
| 1476 | memset(&cmd_buf_hinfo, 0, sizeof(VkCommandBufferInheritanceInfo)); |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1477 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1478 | cmd_buf_info.pNext = NULL; |
| 1479 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1480 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1481 | |
| 1482 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1483 | vkCmdBindPipeline(commandBuffer.GetBufferHandle(), |
| 1484 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1485 | |
| 1486 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1487 | FAIL() << "Did not receive Error 'vkCmdBindPipeline: This call must be " |
| 1488 | "issued inside an active render pass'"; |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1489 | m_errorMonitor->DumpFailureMsgs(); |
| 1490 | } |
| 1491 | |
| 1492 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1493 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1494 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1495 | } |
| 1496 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1497 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1498 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1499 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1500 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1501 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1502 | "Unable to allocate 1 descriptors of " |
| 1503 | "type " |
| 1504 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1505 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1506 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1507 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1508 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1509 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 1510 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1511 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1512 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1513 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1514 | |
| 1515 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1516 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1517 | ds_pool_ci.pNext = NULL; |
| 1518 | ds_pool_ci.flags = 0; |
| 1519 | ds_pool_ci.maxSets = 1; |
| 1520 | ds_pool_ci.poolSizeCount = 1; |
| 1521 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1522 | |
| 1523 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1524 | err = |
| 1525 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1526 | ASSERT_VK_SUCCESS(err); |
| 1527 | |
| 1528 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1529 | dsl_binding.binding = 0; |
| 1530 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1531 | dsl_binding.descriptorCount = 1; |
| 1532 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1533 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1534 | |
| 1535 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1536 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1537 | ds_layout_ci.pNext = NULL; |
| 1538 | ds_layout_ci.bindingCount = 1; |
| 1539 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1540 | |
| 1541 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1542 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1543 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1544 | ASSERT_VK_SUCCESS(err); |
| 1545 | |
| 1546 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1547 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1548 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1549 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1550 | alloc_info.descriptorPool = ds_pool; |
| 1551 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1552 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1553 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1554 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1555 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1556 | FAIL() << "Did not receive Error 'Unable to allocate 1 descriptors of " |
| 1557 | "type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1558 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1559 | } |
| 1560 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1561 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1562 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1563 | } |
| 1564 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1565 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 1566 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1567 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1568 | m_errorMonitor->SetDesiredFailureMsg( |
| 1569 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1570 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 1571 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1572 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1573 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1574 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1575 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1576 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1577 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1578 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1579 | |
| 1580 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1581 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1582 | ds_pool_ci.pNext = NULL; |
| 1583 | ds_pool_ci.maxSets = 1; |
| 1584 | ds_pool_ci.poolSizeCount = 1; |
| 1585 | ds_pool_ci.flags = 0; |
| 1586 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1587 | // app can only call vkResetDescriptorPool on this pool.; |
| 1588 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1589 | |
| 1590 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1591 | err = |
| 1592 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1593 | ASSERT_VK_SUCCESS(err); |
| 1594 | |
| 1595 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1596 | dsl_binding.binding = 0; |
| 1597 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1598 | dsl_binding.descriptorCount = 1; |
| 1599 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1600 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1601 | |
| 1602 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1603 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1604 | ds_layout_ci.pNext = NULL; |
| 1605 | ds_layout_ci.bindingCount = 1; |
| 1606 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1607 | |
| 1608 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1609 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1610 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1611 | ASSERT_VK_SUCCESS(err); |
| 1612 | |
| 1613 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1614 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1615 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1616 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1617 | alloc_info.descriptorPool = ds_pool; |
| 1618 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1619 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1620 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1621 | ASSERT_VK_SUCCESS(err); |
| 1622 | |
| 1623 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1624 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1625 | FAIL() << "Did not receive Error 'It is invalid to call " |
| 1626 | "vkFreeDescriptorSets() with a pool created with...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1627 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1628 | } |
| 1629 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1630 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1631 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1632 | } |
| 1633 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1634 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
| 1635 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 1636 | // catch this case |
| 1637 | // The DS check for this is after driver has been called to validate DS |
| 1638 | // internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1639 | // Attempt to clear DS Pool with bad object |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1640 | /* |
| 1641 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1642 | "Unable to find pool node for pool 0xbaad6001 specified in |
| 1643 | vkResetDescriptorPool() call"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1644 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1645 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1646 | vkResetDescriptorPool(device(), badPool); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1647 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1648 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1649 | FAIL() << "Did not receive Error 'Unable to find pool node for pool |
| 1650 | 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1651 | m_errorMonitor->DumpFailureMsgs(); |
| 1652 | }*/ |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1653 | } |
| 1654 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1655 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
| 1656 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 1657 | // catch this case |
| 1658 | // The DS check for this is after driver has been called to validate DS |
| 1659 | // internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1660 | // Create a valid cmd buffer |
| 1661 | // call vkCmdBindDescriptorSets w/ false DS |
| 1662 | } |
| 1663 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1664 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
| 1665 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 1666 | // catch this case |
| 1667 | // The DS check for this is after driver has been called to validate DS |
| 1668 | // internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1669 | } |
| 1670 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1671 | TEST_F(VkLayerTest, InvalidPipeline) { |
| 1672 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 1673 | // catch this case |
| 1674 | // The DS check for this is after driver has been called to validate DS |
| 1675 | // internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1676 | // Create a valid cmd buffer |
| 1677 | // call vkCmdBindPipeline w/ false Pipeline |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1678 | // |
| 1679 | // m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1680 | // "Attempt to bind Pipeline "); |
| 1681 | // |
| 1682 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1683 | // VkCommandBufferObj commandBuffer(m_device); |
| 1684 | // BeginCommandBuffer(); |
| 1685 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 1686 | // vkCmdBindPipeline(commandBuffer.GetBufferHandle(), |
| 1687 | // VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
| 1688 | // |
| 1689 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 1690 | // FAIL() << "Did not receive Error 'Attempt to bind Pipeline |
| 1691 | // 0xbaadb1be that doesn't exist!'"; |
| 1692 | // m_errorMonitor->DumpFailureMsgs(); |
| 1693 | // } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1694 | } |
| 1695 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1696 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 1697 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 1698 | // CommandBuffer |
| 1699 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1700 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1701 | // TODO: verify that this matches layer |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 1702 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1703 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1704 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1705 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1706 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1707 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1708 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1709 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1710 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1711 | |
| 1712 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1713 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1714 | ds_pool_ci.pNext = NULL; |
| 1715 | ds_pool_ci.maxSets = 1; |
| 1716 | ds_pool_ci.poolSizeCount = 1; |
| 1717 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1718 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1719 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1720 | err = |
| 1721 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1722 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1723 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1724 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1725 | dsl_binding.binding = 0; |
| 1726 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1727 | dsl_binding.descriptorCount = 1; |
| 1728 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1729 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1730 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1731 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1732 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1733 | ds_layout_ci.pNext = NULL; |
| 1734 | ds_layout_ci.bindingCount = 1; |
| 1735 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1736 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1737 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1738 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1739 | ASSERT_VK_SUCCESS(err); |
| 1740 | |
| 1741 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1742 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1743 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1744 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1745 | alloc_info.descriptorPool = ds_pool; |
| 1746 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1747 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1748 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1749 | ASSERT_VK_SUCCESS(err); |
| 1750 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1751 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1752 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1753 | pipeline_layout_ci.pNext = NULL; |
| 1754 | pipeline_layout_ci.setLayoutCount = 1; |
| 1755 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1756 | |
| 1757 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1758 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1759 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1760 | ASSERT_VK_SUCCESS(err); |
| 1761 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1762 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 1763 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1764 | // TODO - We shouldn't need a fragment shader but add it to be able to run |
| 1765 | // on more devices |
| 1766 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 1767 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1768 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1769 | VkPipelineObj pipe(m_device); |
| 1770 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1771 | pipe.AddShader(&fs); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1772 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1773 | |
| 1774 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1775 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1776 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1777 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1778 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1779 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1780 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1781 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1782 | FAIL() << "Did not recieve Warning 'DS <blah> bound but it was never " |
| 1783 | "updated. You may want to either update it or not bind it.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1784 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1785 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1786 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1787 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1788 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1789 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1790 | } |
| 1791 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1792 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1793 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1794 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1795 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1796 | m_errorMonitor->SetDesiredFailureMsg( |
| 1797 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1798 | "Attempt to update descriptor with invalid bufferView "); |
| 1799 | |
| 1800 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1801 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1802 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1803 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1804 | |
| 1805 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1806 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1807 | ds_pool_ci.pNext = NULL; |
| 1808 | ds_pool_ci.maxSets = 1; |
| 1809 | ds_pool_ci.poolSizeCount = 1; |
| 1810 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1811 | |
| 1812 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1813 | err = |
| 1814 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1815 | ASSERT_VK_SUCCESS(err); |
| 1816 | |
| 1817 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1818 | dsl_binding.binding = 0; |
| 1819 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1820 | dsl_binding.descriptorCount = 1; |
| 1821 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1822 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1823 | |
| 1824 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1825 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1826 | ds_layout_ci.pNext = NULL; |
| 1827 | ds_layout_ci.bindingCount = 1; |
| 1828 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1829 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1830 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1831 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1832 | ASSERT_VK_SUCCESS(err); |
| 1833 | |
| 1834 | VkDescriptorSet descriptorSet; |
| 1835 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1836 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1837 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1838 | alloc_info.descriptorPool = ds_pool; |
| 1839 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1840 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1841 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1842 | ASSERT_VK_SUCCESS(err); |
| 1843 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1844 | VkBufferView view = |
| 1845 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1846 | VkWriteDescriptorSet descriptor_write; |
| 1847 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1848 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1849 | descriptor_write.dstSet = descriptorSet; |
| 1850 | descriptor_write.dstBinding = 0; |
| 1851 | descriptor_write.descriptorCount = 1; |
| 1852 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1853 | descriptor_write.pTexelBufferView = &view; |
| 1854 | |
| 1855 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1856 | |
| 1857 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1858 | FAIL() << "Did not receive Error 'Attempt to update descriptor with " |
| 1859 | "invalid bufferView'"; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1860 | m_errorMonitor->DumpFailureMsgs(); |
| 1861 | } |
| 1862 | |
| 1863 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1864 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1865 | } |
| 1866 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1867 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 1868 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 1869 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1870 | // 1. No dynamicOffset supplied |
| 1871 | // 2. Too many dynamicOffsets supplied |
| 1872 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1873 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1874 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1875 | " requires 1 dynamicOffsets, but only " |
| 1876 | "0 dynamicOffsets are left in " |
| 1877 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1878 | |
| 1879 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1880 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1881 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1882 | |
| 1883 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1884 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1885 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1886 | |
| 1887 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1888 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1889 | ds_pool_ci.pNext = NULL; |
| 1890 | ds_pool_ci.maxSets = 1; |
| 1891 | ds_pool_ci.poolSizeCount = 1; |
| 1892 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1893 | |
| 1894 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1895 | err = |
| 1896 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1897 | ASSERT_VK_SUCCESS(err); |
| 1898 | |
| 1899 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1900 | dsl_binding.binding = 0; |
| 1901 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1902 | dsl_binding.descriptorCount = 1; |
| 1903 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1904 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1905 | |
| 1906 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1907 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1908 | ds_layout_ci.pNext = NULL; |
| 1909 | ds_layout_ci.bindingCount = 1; |
| 1910 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1911 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1912 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1913 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1914 | ASSERT_VK_SUCCESS(err); |
| 1915 | |
| 1916 | VkDescriptorSet descriptorSet; |
| 1917 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1918 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1919 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1920 | alloc_info.descriptorPool = ds_pool; |
| 1921 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1922 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1923 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1924 | ASSERT_VK_SUCCESS(err); |
| 1925 | |
| 1926 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1927 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1928 | pipeline_layout_ci.pNext = NULL; |
| 1929 | pipeline_layout_ci.setLayoutCount = 1; |
| 1930 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1931 | |
| 1932 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1933 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1934 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1935 | ASSERT_VK_SUCCESS(err); |
| 1936 | |
| 1937 | // Create a buffer to update the descriptor with |
| 1938 | uint32_t qfi = 0; |
| 1939 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1940 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1941 | buffCI.size = 1024; |
| 1942 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1943 | buffCI.queueFamilyIndexCount = 1; |
| 1944 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1945 | |
| 1946 | VkBuffer dyub; |
| 1947 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 1948 | ASSERT_VK_SUCCESS(err); |
| 1949 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 1950 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1951 | buffInfo.buffer = dyub; |
| 1952 | buffInfo.offset = 0; |
| 1953 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1954 | |
| 1955 | VkWriteDescriptorSet descriptor_write; |
| 1956 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1957 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1958 | descriptor_write.dstSet = descriptorSet; |
| 1959 | descriptor_write.dstBinding = 0; |
| 1960 | descriptor_write.descriptorCount = 1; |
| 1961 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1962 | descriptor_write.pBufferInfo = &buffInfo; |
| 1963 | |
| 1964 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1965 | |
| 1966 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1967 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1968 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1969 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1970 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1971 | FAIL() << "Error received was not 'descriptorSet #0 (0x<ADDR>) " |
| 1972 | "requires 1 dynamicOffsets, but only 0 dynamicOffsets are " |
| 1973 | "left in pDynamicOffsets array...'"; |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1974 | m_errorMonitor->DumpFailureMsgs(); |
| 1975 | } |
| 1976 | uint32_t pDynOff[2] = {512, 756}; |
| 1977 | // 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] | 1978 | m_errorMonitor->SetDesiredFailureMsg( |
| 1979 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1980 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1981 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1982 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1983 | 1, &descriptorSet, 2, pDynOff); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1984 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1985 | FAIL() << "Error received was not 'Attempting to bind 1 descriptorSets " |
| 1986 | "with 1 dynamic descriptors, but dynamicOffsetCount is 0...'"; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1987 | m_errorMonitor->DumpFailureMsgs(); |
| 1988 | } |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1989 | // Finally cause error due to dynamicOffset being too big |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1990 | m_errorMonitor->SetDesiredFailureMsg( |
| 1991 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1992 | " from its update, this oversteps its buffer ("); |
| 1993 | // Create PSO to be used for draw-time errors below |
| 1994 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1995 | "#version 400\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1996 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 1997 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 1998 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1999 | "out gl_PerVertex { \n" |
| 2000 | " vec4 gl_Position;\n" |
| 2001 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2002 | "void main(){\n" |
| 2003 | " gl_Position = vec4(1);\n" |
| 2004 | "}\n"; |
| 2005 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2006 | "#version 400\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2007 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 2008 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 2009 | "\n" |
| 2010 | "layout(location=0) out vec4 x;\n" |
| 2011 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 2012 | "void main(){\n" |
| 2013 | " x = vec4(bar.y);\n" |
| 2014 | "}\n"; |
| 2015 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2016 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 2017 | VkPipelineObj pipe(m_device); |
| 2018 | pipe.AddShader(&vs); |
| 2019 | pipe.AddShader(&fs); |
| 2020 | pipe.AddColorAttachment(); |
| 2021 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 2022 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2023 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2024 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2025 | // This update should succeed, but offset size of 512 will overstep buffer |
| 2026 | // /w range 1024 & size 1024 |
| 2027 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2028 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2029 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2030 | Draw(1, 0, 0, 0); |
| 2031 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2032 | FAIL() << "Error received was not 'VkDescriptorSet (0x<ADDR>) bound as " |
| 2033 | "set #0 has dynamic offset 512. Combined with offet 0 and " |
| 2034 | "range 1024 from its update, this oversteps...'"; |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2035 | m_errorMonitor->DumpFailureMsgs(); |
| 2036 | } |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2037 | |
| 2038 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2039 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2040 | } |
| 2041 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2042 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2043 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2044 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2045 | |
| 2046 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2047 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2048 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2049 | |
| 2050 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 2051 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2052 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2053 | ds_type_count[0].descriptorCount = 10; |
| 2054 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 2055 | ds_type_count[1].descriptorCount = 2; |
| 2056 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 2057 | ds_type_count[2].descriptorCount = 2; |
| 2058 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2059 | ds_type_count[3].descriptorCount = 5; |
| 2060 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 2061 | // type |
| 2062 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 2063 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 2064 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2065 | |
| 2066 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2067 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2068 | ds_pool_ci.pNext = NULL; |
| 2069 | ds_pool_ci.maxSets = 5; |
| 2070 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 2071 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2072 | |
| 2073 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2074 | err = |
| 2075 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2076 | ASSERT_VK_SUCCESS(err); |
| 2077 | |
| 2078 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 2079 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2080 | dsl_binding[0].binding = 0; |
| 2081 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2082 | dsl_binding[0].descriptorCount = 5; |
| 2083 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 2084 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2085 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2086 | // Create layout identical to set0 layout but w/ different stageFlags |
| 2087 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2088 | dsl_fs_stage_only.binding = 0; |
| 2089 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2090 | dsl_fs_stage_only.descriptorCount = 5; |
| 2091 | dsl_fs_stage_only.stageFlags = |
| 2092 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 2093 | // bind time |
| 2094 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2095 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2096 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2097 | ds_layout_ci.pNext = NULL; |
| 2098 | ds_layout_ci.bindingCount = 1; |
| 2099 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2100 | static const uint32_t NUM_LAYOUTS = 4; |
| 2101 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2102 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2103 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 2104 | // layout for error case |
| 2105 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2106 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2107 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2108 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2109 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2110 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2111 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2112 | dsl_binding[0].binding = 0; |
| 2113 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2114 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2115 | dsl_binding[1].binding = 1; |
| 2116 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 2117 | dsl_binding[1].descriptorCount = 2; |
| 2118 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 2119 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2120 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2121 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2122 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2123 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2124 | ASSERT_VK_SUCCESS(err); |
| 2125 | dsl_binding[0].binding = 0; |
| 2126 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2127 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2128 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2129 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2130 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2131 | ASSERT_VK_SUCCESS(err); |
| 2132 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2133 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2134 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2135 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2136 | ASSERT_VK_SUCCESS(err); |
| 2137 | |
| 2138 | static const uint32_t NUM_SETS = 4; |
| 2139 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 2140 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2141 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2142 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2143 | alloc_info.descriptorPool = ds_pool; |
| 2144 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2145 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2146 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2147 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2148 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2149 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2150 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2151 | err = |
| 2152 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2153 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2154 | |
| 2155 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2156 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2157 | pipeline_layout_ci.pNext = NULL; |
| 2158 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 2159 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2160 | |
| 2161 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2162 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2163 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2164 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2165 | // Create pipelineLayout with only one setLayout |
| 2166 | pipeline_layout_ci.setLayoutCount = 1; |
| 2167 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2168 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2169 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2170 | ASSERT_VK_SUCCESS(err); |
| 2171 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 2172 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 2173 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2174 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2175 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2176 | ASSERT_VK_SUCCESS(err); |
| 2177 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 2178 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 2179 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2180 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2181 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2182 | ASSERT_VK_SUCCESS(err); |
| 2183 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 2184 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 2185 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2186 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2187 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2188 | ASSERT_VK_SUCCESS(err); |
| 2189 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 2190 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 2191 | pl_bad_s0[0] = ds_layout_fs_only; |
| 2192 | pl_bad_s0[1] = ds_layout[1]; |
| 2193 | pipeline_layout_ci.setLayoutCount = 2; |
| 2194 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 2195 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2196 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2197 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2198 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2199 | |
| 2200 | // Create a buffer to update the descriptor with |
| 2201 | uint32_t qfi = 0; |
| 2202 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2203 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2204 | buffCI.size = 1024; |
| 2205 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 2206 | buffCI.queueFamilyIndexCount = 1; |
| 2207 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2208 | |
| 2209 | VkBuffer dyub; |
| 2210 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 2211 | ASSERT_VK_SUCCESS(err); |
| 2212 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 2213 | static const uint32_t NUM_BUFFS = 5; |
| 2214 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2215 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2216 | buffInfo[i].buffer = dyub; |
| 2217 | buffInfo[i].offset = 0; |
| 2218 | buffInfo[i].range = 1024; |
| 2219 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2220 | VkImage image; |
| 2221 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2222 | const int32_t tex_width = 32; |
| 2223 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2224 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2225 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2226 | image_create_info.pNext = NULL; |
| 2227 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2228 | image_create_info.format = tex_format; |
| 2229 | image_create_info.extent.width = tex_width; |
| 2230 | image_create_info.extent.height = tex_height; |
| 2231 | image_create_info.extent.depth = 1; |
| 2232 | image_create_info.mipLevels = 1; |
| 2233 | image_create_info.arrayLayers = 1; |
| 2234 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2235 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2236 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2237 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2238 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 2239 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2240 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2241 | VkMemoryRequirements memReqs; |
| 2242 | VkDeviceMemory imageMem; |
| 2243 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2244 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2245 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2246 | memAlloc.pNext = NULL; |
| 2247 | memAlloc.allocationSize = 0; |
| 2248 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2249 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 2250 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2251 | pass = |
| 2252 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2253 | ASSERT_TRUE(pass); |
| 2254 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 2255 | ASSERT_VK_SUCCESS(err); |
| 2256 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 2257 | ASSERT_VK_SUCCESS(err); |
| 2258 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2259 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2260 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2261 | image_view_create_info.image = image; |
| 2262 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2263 | image_view_create_info.format = tex_format; |
| 2264 | image_view_create_info.subresourceRange.layerCount = 1; |
| 2265 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 2266 | image_view_create_info.subresourceRange.levelCount = 1; |
| 2267 | image_view_create_info.subresourceRange.aspectMask = |
| 2268 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2269 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2270 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2271 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 2272 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2273 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2274 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2275 | imageInfo[0].imageView = view; |
| 2276 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2277 | imageInfo[1].imageView = view; |
| 2278 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2279 | imageInfo[2].imageView = view; |
| 2280 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2281 | imageInfo[3].imageView = view; |
| 2282 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2283 | |
| 2284 | static const uint32_t NUM_SET_UPDATES = 3; |
| 2285 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 2286 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2287 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 2288 | descriptor_write[0].dstBinding = 0; |
| 2289 | descriptor_write[0].descriptorCount = 5; |
| 2290 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2291 | descriptor_write[0].pBufferInfo = buffInfo; |
| 2292 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2293 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 2294 | descriptor_write[1].dstBinding = 0; |
| 2295 | descriptor_write[1].descriptorCount = 2; |
| 2296 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 2297 | descriptor_write[1].pImageInfo = imageInfo; |
| 2298 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2299 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 2300 | descriptor_write[2].dstBinding = 1; |
| 2301 | descriptor_write[2].descriptorCount = 2; |
| 2302 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2303 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2304 | |
| 2305 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2306 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2307 | // Create PSO to be used for draw-time errors below |
| 2308 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2309 | "#version 400\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2310 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 2311 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 2312 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2313 | "out gl_PerVertex {\n" |
| 2314 | " vec4 gl_Position;\n" |
| 2315 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2316 | "void main(){\n" |
| 2317 | " gl_Position = vec4(1);\n" |
| 2318 | "}\n"; |
| 2319 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2320 | "#version 400\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2321 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 2322 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 2323 | "\n" |
| 2324 | "layout(location=0) out vec4 x;\n" |
| 2325 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 2326 | "void main(){\n" |
| 2327 | " x = vec4(bar.y);\n" |
| 2328 | "}\n"; |
| 2329 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2330 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2331 | VkPipelineObj pipe(m_device); |
| 2332 | pipe.AddShader(&vs); |
| 2333 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2334 | pipe.AddColorAttachment(); |
| 2335 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2336 | |
| 2337 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2338 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2339 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2340 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2341 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 2342 | // of PSO |
| 2343 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 2344 | // cmd_pipeline.c |
| 2345 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 2346 | // cmd_bind_graphics_pipeline() |
| 2347 | // TODO : Want to cause various binding incompatibility issues here to test |
| 2348 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2349 | // First cause various verify_layout_compatibility() fails |
| 2350 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2351 | // verify_set_layout_compatibility fail cases: |
| 2352 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2353 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2354 | " due to: invalid VkPipelineLayout "); |
| 2355 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2356 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2357 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 2358 | &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2359 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2360 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2361 | "descriptorSets with invalid VkPipelineLayout."; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2362 | m_errorMonitor->DumpFailureMsgs(); |
| 2363 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2364 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2365 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2366 | " attempting to bind set to index 1"); |
| 2367 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2368 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 2369 | 0, 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2370 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2371 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2372 | "descriptorSet to index 1 when pipelineLayout only has index " |
| 2373 | "0."; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2374 | m_errorMonitor->DumpFailureMsgs(); |
| 2375 | } |
| 2376 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2377 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 2378 | // descriptors |
| 2379 | m_errorMonitor->SetDesiredFailureMsg( |
| 2380 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2381 | ", but corresponding set being bound has 5 descriptors."); |
| 2382 | vkCmdBindDescriptorSets( |
| 2383 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2384 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2385 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2386 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2387 | "descriptorSet w/ 5 descriptors to pipelineLayout with only " |
| 2388 | "2 descriptors."; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2389 | m_errorMonitor->DumpFailureMsgs(); |
| 2390 | } |
| 2391 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 2392 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2393 | m_errorMonitor->SetDesiredFailureMsg( |
| 2394 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2395 | " descriptor from pipelineLayout is type 'VK_DESCRIPTOR_TYPE_SAMPLER'"); |
| 2396 | vkCmdBindDescriptorSets( |
| 2397 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2398 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2399 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2400 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2401 | "UNIFORM_BUFFER descriptorSet to pipelineLayout with " |
| 2402 | "overlapping SAMPLER type."; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2403 | m_errorMonitor->DumpFailureMsgs(); |
| 2404 | } |
| 2405 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 2406 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2407 | m_errorMonitor->SetDesiredFailureMsg( |
| 2408 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2409 | " descriptor from pipelineLayout has stageFlags "); |
| 2410 | vkCmdBindDescriptorSets( |
| 2411 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2412 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 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 error msg when attempting to bind " |
| 2415 | "UNIFORM_BUFFER descriptorSet with ALL stageFlags to " |
| 2416 | "pipelineLayout with FS-only stageFlags."; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2417 | m_errorMonitor->DumpFailureMsgs(); |
| 2418 | } |
| 2419 | // Cause INFO messages due to disturbing previously bound Sets |
| 2420 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2421 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2422 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2423 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2424 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2425 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2426 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2427 | " previously bound as set #0 was disturbed "); |
| 2428 | vkCmdBindDescriptorSets( |
| 2429 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2430 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2431 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2432 | FAIL() << "Did not receive correct info msg when binding Set1 w/ " |
| 2433 | "pipelineLayout that should disturb Set0."; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2434 | m_errorMonitor->DumpFailureMsgs(); |
| 2435 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2436 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2437 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2438 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2439 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2440 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2441 | " newly bound as set #0 so set #1 and " |
| 2442 | "any subsequent sets were disturbed "); |
| 2443 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2444 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2445 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2446 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2447 | FAIL() << "Did not receive correct info msg when re-binding Set0 w/ " |
| 2448 | "pipelineLayout that should disturb Set1."; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2449 | m_errorMonitor->DumpFailureMsgs(); |
| 2450 | } |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2451 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2452 | // 1. Error due to not binding required set (we actually use same code as |
| 2453 | // above to disturb set0) |
| 2454 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2455 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2456 | 2, &descriptorSet[0], 0, NULL); |
| 2457 | vkCmdBindDescriptorSets( |
| 2458 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2459 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 2460 | m_errorMonitor->SetDesiredFailureMsg( |
| 2461 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2462 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2463 | Draw(1, 0, 0, 0); |
| 2464 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2465 | FAIL() << "Did not receive correct error msg when attempting draw " |
| 2466 | "requiring Set0 but Set0 is not bound."; |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2467 | m_errorMonitor->DumpFailureMsgs(); |
| 2468 | } |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2469 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2470 | // 2. Error due to bound set not being compatible with PSO's |
| 2471 | // VkPipelineLayout (diff stageFlags in this case) |
| 2472 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2473 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2474 | 2, &descriptorSet[0], 0, NULL); |
| 2475 | m_errorMonitor->SetDesiredFailureMsg( |
| 2476 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2477 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2478 | Draw(1, 0, 0, 0); |
| 2479 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2480 | FAIL() << "Did not receive correct error msg when attempted draw where " |
| 2481 | "bound Set0 layout is not compatible PSO Set0 layout."; |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2482 | m_errorMonitor->DumpFailureMsgs(); |
| 2483 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2484 | // Remaining clean-up |
| 2485 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2486 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2487 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 2488 | } |
| 2489 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
| 2490 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, descriptorSet); |
| 2491 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2492 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2493 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2494 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2495 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2496 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2497 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2498 | m_errorMonitor->SetDesiredFailureMsg( |
| 2499 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2500 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2501 | |
| 2502 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2503 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2504 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2505 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2506 | |
| 2507 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2508 | FAIL() << "Did not recieve Error 'You must call vkBeginCommandBuffer() " |
| 2509 | "before this call to vkEndCommandBuffer()'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2510 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2511 | } |
| 2512 | } |
| 2513 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2514 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 2515 | VkResult err; |
| 2516 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2517 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2518 | m_errorMonitor->SetDesiredFailureMsg( |
| 2519 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 2520 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2521 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2522 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2523 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2524 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2525 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2526 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2527 | cmd.commandPool = m_commandPool; |
| 2528 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2529 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2530 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2531 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2532 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2533 | |
| 2534 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2535 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2536 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2537 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2538 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2539 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 2540 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2541 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2542 | |
| 2543 | // The error should be caught by validation of the BeginCommandBuffer call |
| 2544 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 2545 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2546 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2547 | FAIL() << "Did not receive Error 'vkBeginCommandBuffer(): Secondary " |
| 2548 | "Command Buffers (0x<ADDR>) must specify a valid renderpass " |
| 2549 | "parameter.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2550 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2551 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2552 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2553 | } |
| 2554 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2555 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2556 | // Cause error due to Begin while recording CB |
| 2557 | // Then cause 2 errors for attempting to reset CB w/o having |
| 2558 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 2559 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2560 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2561 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2562 | |
| 2563 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2564 | |
| 2565 | // Calls AllocateCommandBuffers |
| 2566 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 2567 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2568 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 2569 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2570 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2571 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2572 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2573 | cmd_buf_info.pNext = NULL; |
| 2574 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2575 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2576 | |
| 2577 | // Begin CB to transition to recording state |
| 2578 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2579 | // Can't re-begin. This should trigger error |
| 2580 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2581 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2582 | FAIL() << "Did not receive Error 'Cannot call Begin on CB (0x<ADDR>) " |
| 2583 | "in the RECORDING state...'"; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2584 | m_errorMonitor->DumpFailureMsgs(); |
| 2585 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2586 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2587 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2588 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 2589 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 2590 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
| 2591 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2592 | FAIL() << "Did not receive Error 'Attempt to reset command buffer " |
| 2593 | "(0x<ADDR>) created from command pool...'"; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2594 | m_errorMonitor->DumpFailureMsgs(); |
| 2595 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2596 | m_errorMonitor->SetDesiredFailureMsg( |
| 2597 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2598 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2599 | // Transition CB to RECORDED state |
| 2600 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 2601 | // Now attempting to Begin will implicitly reset, which triggers error |
| 2602 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2603 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2604 | FAIL() << "Did not receive Error 'Call to vkBeginCommandBuffer() on " |
| 2605 | "command buffer (0x<ADDR>) attempts to implicitly reset...'"; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2606 | m_errorMonitor->DumpFailureMsgs(); |
| 2607 | } |
| 2608 | } |
| 2609 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2610 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2611 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2612 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2613 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2614 | m_errorMonitor->SetDesiredFailureMsg( |
| 2615 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2616 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 2617 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2618 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2619 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2620 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2621 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2622 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2623 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2624 | |
| 2625 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2626 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2627 | ds_pool_ci.pNext = NULL; |
| 2628 | ds_pool_ci.maxSets = 1; |
| 2629 | ds_pool_ci.poolSizeCount = 1; |
| 2630 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2631 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2632 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2633 | err = |
| 2634 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2635 | ASSERT_VK_SUCCESS(err); |
| 2636 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2637 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2638 | dsl_binding.binding = 0; |
| 2639 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2640 | dsl_binding.descriptorCount = 1; |
| 2641 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2642 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2643 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2644 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2645 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2646 | ds_layout_ci.pNext = NULL; |
| 2647 | ds_layout_ci.bindingCount = 1; |
| 2648 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2649 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2650 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2651 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2652 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2653 | ASSERT_VK_SUCCESS(err); |
| 2654 | |
| 2655 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2656 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2657 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2658 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2659 | alloc_info.descriptorPool = ds_pool; |
| 2660 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2661 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2662 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2663 | ASSERT_VK_SUCCESS(err); |
| 2664 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2665 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2666 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2667 | pipeline_layout_ci.setLayoutCount = 1; |
| 2668 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2669 | |
| 2670 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2671 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2672 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2673 | ASSERT_VK_SUCCESS(err); |
| 2674 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2675 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2676 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2677 | |
| 2678 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2679 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2680 | vp_state_ci.scissorCount = 1; |
| 2681 | vp_state_ci.pScissors = ≻ |
| 2682 | vp_state_ci.viewportCount = 1; |
| 2683 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2684 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2685 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2686 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2687 | gp_ci.pViewportState = &vp_state_ci; |
| 2688 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2689 | gp_ci.layout = pipeline_layout; |
| 2690 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2691 | |
| 2692 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2693 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2694 | pc_ci.initialDataSize = 0; |
| 2695 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2696 | |
| 2697 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2698 | VkPipelineCache pipelineCache; |
| 2699 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2700 | err = |
| 2701 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2702 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2703 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2704 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2705 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2706 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2707 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: " |
| 2708 | "Vtx Shader required'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2709 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2710 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2711 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2712 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2713 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2714 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2715 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2716 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2717 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 2718 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 2719 | { |
| 2720 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2721 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2722 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2723 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2724 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 2725 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2726 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2727 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2728 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2729 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2730 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2731 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2732 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2733 | |
| 2734 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2735 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2736 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2737 | ds_pool_ci.poolSizeCount = 1; |
| 2738 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2739 | |
| 2740 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2741 | err = vkCreateDescriptorPool(m_device->device(), |
| 2742 | 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] | 2743 | ASSERT_VK_SUCCESS(err); |
| 2744 | |
| 2745 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2746 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2747 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2748 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2749 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2750 | dsl_binding.pImmutableSamplers = NULL; |
| 2751 | |
| 2752 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2753 | ds_layout_ci.sType = |
| 2754 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2755 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2756 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2757 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2758 | |
| 2759 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2760 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2761 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2762 | ASSERT_VK_SUCCESS(err); |
| 2763 | |
| 2764 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2765 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 2766 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2767 | ASSERT_VK_SUCCESS(err); |
| 2768 | |
| 2769 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2770 | pipeline_layout_ci.sType = |
| 2771 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2772 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2773 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2774 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2775 | |
| 2776 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2777 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2778 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2779 | ASSERT_VK_SUCCESS(err); |
| 2780 | |
| 2781 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 2782 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 2783 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2784 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 2785 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2786 | // 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] | 2787 | VkShaderObj |
| 2788 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 2789 | this); |
| 2790 | VkShaderObj |
| 2791 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 2792 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2793 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2794 | shaderStages[0].sType = |
| 2795 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2796 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2797 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2798 | shaderStages[1].sType = |
| 2799 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2800 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2801 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2802 | shaderStages[2].sType = |
| 2803 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2804 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2805 | shaderStages[2].shader = te.handle(); |
| 2806 | |
| 2807 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2808 | iaCI.sType = |
| 2809 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2810 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2811 | |
| 2812 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 2813 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 2814 | tsCI.patchControlPoints = 0; // This will cause an error |
| 2815 | |
| 2816 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2817 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2818 | gp_ci.pNext = NULL; |
| 2819 | gp_ci.stageCount = 3; |
| 2820 | gp_ci.pStages = shaderStages; |
| 2821 | gp_ci.pVertexInputState = NULL; |
| 2822 | gp_ci.pInputAssemblyState = &iaCI; |
| 2823 | gp_ci.pTessellationState = &tsCI; |
| 2824 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2825 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2826 | gp_ci.pMultisampleState = NULL; |
| 2827 | gp_ci.pDepthStencilState = NULL; |
| 2828 | gp_ci.pColorBlendState = NULL; |
| 2829 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2830 | gp_ci.layout = pipeline_layout; |
| 2831 | gp_ci.renderPass = renderPass(); |
| 2832 | |
| 2833 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2834 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2835 | pc_ci.pNext = NULL; |
| 2836 | pc_ci.initialSize = 0; |
| 2837 | pc_ci.initialData = 0; |
| 2838 | pc_ci.maxSize = 0; |
| 2839 | |
| 2840 | VkPipeline pipeline; |
| 2841 | VkPipelineCache pipelineCache; |
| 2842 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2843 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 2844 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2845 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2846 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2847 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2848 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2849 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2850 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: |
| 2851 | VK_PRIMITIVE_TOPOLOGY_PATCH primitive...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2852 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2853 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2854 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2855 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2856 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2857 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2858 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2859 | } |
| 2860 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2861 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2862 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2863 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2864 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2865 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2866 | m_errorMonitor->SetDesiredFailureMsg( |
| 2867 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2868 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2869 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2870 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2871 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2872 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2873 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2874 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2875 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2876 | |
| 2877 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2878 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2879 | ds_pool_ci.maxSets = 1; |
| 2880 | ds_pool_ci.poolSizeCount = 1; |
| 2881 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2882 | |
| 2883 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2884 | err = |
| 2885 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2886 | ASSERT_VK_SUCCESS(err); |
| 2887 | |
| 2888 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2889 | dsl_binding.binding = 0; |
| 2890 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2891 | dsl_binding.descriptorCount = 1; |
| 2892 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2893 | |
| 2894 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2895 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2896 | ds_layout_ci.bindingCount = 1; |
| 2897 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2898 | |
| 2899 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2900 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2901 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2902 | ASSERT_VK_SUCCESS(err); |
| 2903 | |
| 2904 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2905 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2906 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2907 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2908 | alloc_info.descriptorPool = ds_pool; |
| 2909 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2910 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2911 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2912 | ASSERT_VK_SUCCESS(err); |
| 2913 | |
| 2914 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2915 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2916 | pipeline_layout_ci.setLayoutCount = 1; |
| 2917 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2918 | |
| 2919 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2920 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2921 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2922 | ASSERT_VK_SUCCESS(err); |
| 2923 | |
| 2924 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2925 | |
| 2926 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2927 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2928 | vp_state_ci.scissorCount = 0; |
| 2929 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2930 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2931 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2932 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2933 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2934 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2935 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 2936 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2937 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 2938 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 2939 | this); // TODO - We shouldn't need a fragment shader |
| 2940 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2941 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2942 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2943 | |
| 2944 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2945 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2946 | gp_ci.stageCount = 2; |
| 2947 | gp_ci.pStages = shaderStages; |
| 2948 | gp_ci.pViewportState = &vp_state_ci; |
| 2949 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2950 | gp_ci.layout = pipeline_layout; |
| 2951 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2952 | |
| 2953 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2954 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2955 | |
| 2956 | VkPipeline pipeline; |
| 2957 | VkPipelineCache pipelineCache; |
| 2958 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2959 | err = |
| 2960 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2961 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2962 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2963 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2964 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2965 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2966 | FAIL() << "Did not receive Error 'Gfx Pipeline viewport count (1) must " |
| 2967 | "match scissor count (0).'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2968 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2969 | } |
| 2970 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2971 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2972 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2973 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2974 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2975 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2976 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 2977 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2978 | // 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] | 2979 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2980 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2981 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2982 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2983 | m_errorMonitor->SetDesiredFailureMsg( |
| 2984 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2985 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2986 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2987 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2988 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2989 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2990 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2991 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2992 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2993 | |
| 2994 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2995 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2996 | ds_pool_ci.maxSets = 1; |
| 2997 | ds_pool_ci.poolSizeCount = 1; |
| 2998 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2999 | |
| 3000 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3001 | err = |
| 3002 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3003 | ASSERT_VK_SUCCESS(err); |
| 3004 | |
| 3005 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3006 | dsl_binding.binding = 0; |
| 3007 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3008 | dsl_binding.descriptorCount = 1; |
| 3009 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3010 | |
| 3011 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3012 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3013 | ds_layout_ci.bindingCount = 1; |
| 3014 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3015 | |
| 3016 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3017 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3018 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3019 | ASSERT_VK_SUCCESS(err); |
| 3020 | |
| 3021 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3022 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3023 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3024 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3025 | alloc_info.descriptorPool = ds_pool; |
| 3026 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3027 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3028 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3029 | ASSERT_VK_SUCCESS(err); |
| 3030 | |
| 3031 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3032 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3033 | pipeline_layout_ci.setLayoutCount = 1; |
| 3034 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3035 | |
| 3036 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3037 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3038 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3039 | ASSERT_VK_SUCCESS(err); |
| 3040 | |
| 3041 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 3042 | // Set scissor as dynamic to avoid second error |
| 3043 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3044 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3045 | dyn_state_ci.dynamicStateCount = 1; |
| 3046 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3047 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3048 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3049 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3050 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3051 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3052 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3053 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3054 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 3055 | this); // TODO - We shouldn't need a fragment shader |
| 3056 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3057 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3058 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3059 | |
| 3060 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3061 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3062 | gp_ci.stageCount = 2; |
| 3063 | gp_ci.pStages = shaderStages; |
| 3064 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 3065 | // should cause validation error |
| 3066 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3067 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3068 | gp_ci.layout = pipeline_layout; |
| 3069 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3070 | |
| 3071 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3072 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3073 | |
| 3074 | VkPipeline pipeline; |
| 3075 | VkPipelineCache pipelineCache; |
| 3076 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3077 | err = |
| 3078 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3079 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3080 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3081 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3082 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3083 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3084 | FAIL() << "Did not receive Error 'Gfx Pipeline pViewportState is null. " |
| 3085 | "Even if...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3086 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3087 | } |
| 3088 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3089 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3090 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3091 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3092 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3093 | } |
| 3094 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3095 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 3096 | // count |
| 3097 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 3098 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3099 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3100 | m_errorMonitor->SetDesiredFailureMsg( |
| 3101 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3102 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 3103 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3104 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3105 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3106 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3107 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3108 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3109 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3110 | |
| 3111 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3112 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3113 | ds_pool_ci.maxSets = 1; |
| 3114 | ds_pool_ci.poolSizeCount = 1; |
| 3115 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3116 | |
| 3117 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3118 | err = |
| 3119 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3120 | ASSERT_VK_SUCCESS(err); |
| 3121 | |
| 3122 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3123 | dsl_binding.binding = 0; |
| 3124 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3125 | dsl_binding.descriptorCount = 1; |
| 3126 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3127 | |
| 3128 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3129 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3130 | ds_layout_ci.bindingCount = 1; |
| 3131 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3132 | |
| 3133 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3134 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3135 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3136 | ASSERT_VK_SUCCESS(err); |
| 3137 | |
| 3138 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3139 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3140 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3141 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3142 | alloc_info.descriptorPool = ds_pool; |
| 3143 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3144 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3145 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3146 | ASSERT_VK_SUCCESS(err); |
| 3147 | |
| 3148 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3149 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3150 | pipeline_layout_ci.setLayoutCount = 1; |
| 3151 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3152 | |
| 3153 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3154 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3155 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3156 | ASSERT_VK_SUCCESS(err); |
| 3157 | |
| 3158 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3159 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3160 | vp_state_ci.viewportCount = 1; |
| 3161 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 3162 | vp_state_ci.scissorCount = 1; |
| 3163 | vp_state_ci.pScissors = |
| 3164 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3165 | |
| 3166 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 3167 | // Set scissor as dynamic to avoid that error |
| 3168 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3169 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3170 | dyn_state_ci.dynamicStateCount = 1; |
| 3171 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3172 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3173 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3174 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3175 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3176 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3177 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3178 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3179 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 3180 | this); // TODO - We shouldn't need a fragment shader |
| 3181 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3182 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3183 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3184 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3185 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 3186 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 3187 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3188 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3189 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3190 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3191 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 3192 | |
| 3193 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 3194 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 3195 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 3196 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3197 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3198 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3199 | rs_ci.pNext = nullptr; |
| 3200 | |
| 3201 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 3202 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 3203 | cb_ci.pNext = nullptr; |
| 3204 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3205 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3206 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3207 | gp_ci.stageCount = 2; |
| 3208 | gp_ci.pStages = shaderStages; |
| 3209 | gp_ci.pVertexInputState = &vi_ci; |
| 3210 | gp_ci.pInputAssemblyState = &ia_ci; |
| 3211 | gp_ci.pViewportState = &vp_state_ci; |
| 3212 | gp_ci.pRasterizationState = &rs_ci; |
| 3213 | gp_ci.pColorBlendState = &cb_ci; |
| 3214 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3215 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3216 | gp_ci.layout = pipeline_layout; |
| 3217 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3218 | |
| 3219 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3220 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3221 | |
| 3222 | VkPipeline pipeline; |
| 3223 | VkPipelineCache pipelineCache; |
| 3224 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3225 | err = |
| 3226 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3227 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3228 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3229 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3230 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3231 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3232 | FAIL() << "Did not recieve Error 'Gfx Pipeline viewportCount is 1, but " |
| 3233 | "pViewports is NULL...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3234 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3235 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3236 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3237 | // 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] | 3238 | // First need to successfully create the PSO from above by setting |
| 3239 | // pViewports |
| 3240 | m_errorMonitor->SetDesiredFailureMsg( |
| 3241 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3242 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 3243 | "scissorCount is 1. These counts must match."); |
| 3244 | |
| 3245 | VkViewport vp = {}; // Just need dummy vp to point to |
| 3246 | vp_state_ci.pViewports = &vp; |
| 3247 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3248 | &gp_ci, NULL, &pipeline); |
| 3249 | ASSERT_VK_SUCCESS(err); |
| 3250 | BeginCommandBuffer(); |
| 3251 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3252 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 3253 | VkRect2D scissors[2] = {}; // don't care about data |
| 3254 | // Count of 2 doesn't match PSO count of 1 |
| 3255 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 3256 | Draw(1, 0, 0, 0); |
| 3257 | |
| 3258 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3259 | FAIL() << "Did not receive Error 'Dynamic scissorCount from " |
| 3260 | "vkCmdSetScissor() is 2, but PSO scissorCount is 1...'"; |
| 3261 | m_errorMonitor->DumpFailureMsgs(); |
| 3262 | } |
| 3263 | |
| 3264 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3265 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3266 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3267 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3268 | } |
| 3269 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 3270 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 3271 | // viewportCount |
| 3272 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 3273 | VkResult err; |
| 3274 | |
| 3275 | m_errorMonitor->SetDesiredFailureMsg( |
| 3276 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3277 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 3278 | |
| 3279 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3280 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3281 | |
| 3282 | VkDescriptorPoolSize ds_type_count = {}; |
| 3283 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3284 | ds_type_count.descriptorCount = 1; |
| 3285 | |
| 3286 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3287 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3288 | ds_pool_ci.maxSets = 1; |
| 3289 | ds_pool_ci.poolSizeCount = 1; |
| 3290 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 3291 | |
| 3292 | VkDescriptorPool ds_pool; |
| 3293 | err = |
| 3294 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 3295 | ASSERT_VK_SUCCESS(err); |
| 3296 | |
| 3297 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3298 | dsl_binding.binding = 0; |
| 3299 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3300 | dsl_binding.descriptorCount = 1; |
| 3301 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3302 | |
| 3303 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3304 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3305 | ds_layout_ci.bindingCount = 1; |
| 3306 | ds_layout_ci.pBindings = &dsl_binding; |
| 3307 | |
| 3308 | VkDescriptorSetLayout ds_layout; |
| 3309 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3310 | &ds_layout); |
| 3311 | ASSERT_VK_SUCCESS(err); |
| 3312 | |
| 3313 | VkDescriptorSet descriptorSet; |
| 3314 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 3315 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 3316 | alloc_info.descriptorSetCount = 1; |
| 3317 | alloc_info.descriptorPool = ds_pool; |
| 3318 | alloc_info.pSetLayouts = &ds_layout; |
| 3319 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3320 | &descriptorSet); |
| 3321 | ASSERT_VK_SUCCESS(err); |
| 3322 | |
| 3323 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3324 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3325 | pipeline_layout_ci.setLayoutCount = 1; |
| 3326 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3327 | |
| 3328 | VkPipelineLayout pipeline_layout; |
| 3329 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3330 | &pipeline_layout); |
| 3331 | ASSERT_VK_SUCCESS(err); |
| 3332 | |
| 3333 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 3334 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3335 | vp_state_ci.scissorCount = 1; |
| 3336 | vp_state_ci.pScissors = |
| 3337 | NULL; // Null scissor w/ count of 1 should cause error |
| 3338 | vp_state_ci.viewportCount = 1; |
| 3339 | vp_state_ci.pViewports = |
| 3340 | NULL; // vp is dynamic (below) so this won't cause error |
| 3341 | |
| 3342 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 3343 | // Set scissor as dynamic to avoid that error |
| 3344 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 3345 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3346 | dyn_state_ci.dynamicStateCount = 1; |
| 3347 | dyn_state_ci.pDynamicStates = &vp_state; |
| 3348 | |
| 3349 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 3350 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 3351 | |
| 3352 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3353 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3354 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3355 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 3356 | this); // TODO - We shouldn't need a fragment shader |
| 3357 | // but add it to be able to run on more devices |
| 3358 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3359 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 3360 | |
| 3361 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 3362 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 3363 | vi_ci.pNext = nullptr; |
| 3364 | vi_ci.vertexBindingDescriptionCount = 0; |
| 3365 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 3366 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 3367 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 3368 | |
| 3369 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 3370 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 3371 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 3372 | |
| 3373 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 3374 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3375 | rs_ci.pNext = nullptr; |
| 3376 | |
| 3377 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 3378 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 3379 | cb_ci.pNext = nullptr; |
| 3380 | |
| 3381 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 3382 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3383 | gp_ci.stageCount = 2; |
| 3384 | gp_ci.pStages = shaderStages; |
| 3385 | gp_ci.pVertexInputState = &vi_ci; |
| 3386 | gp_ci.pInputAssemblyState = &ia_ci; |
| 3387 | gp_ci.pViewportState = &vp_state_ci; |
| 3388 | gp_ci.pRasterizationState = &rs_ci; |
| 3389 | gp_ci.pColorBlendState = &cb_ci; |
| 3390 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3391 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3392 | gp_ci.layout = pipeline_layout; |
| 3393 | gp_ci.renderPass = renderPass(); |
| 3394 | |
| 3395 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 3396 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3397 | |
| 3398 | VkPipeline pipeline; |
| 3399 | VkPipelineCache pipelineCache; |
| 3400 | |
| 3401 | err = |
| 3402 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 3403 | ASSERT_VK_SUCCESS(err); |
| 3404 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3405 | &gp_ci, NULL, &pipeline); |
| 3406 | |
| 3407 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3408 | FAIL() << "Did not recieve Error 'Gfx Pipeline scissorCount is 1, but " |
| 3409 | "pScissors is NULL...'"; |
| 3410 | m_errorMonitor->DumpFailureMsgs(); |
| 3411 | } |
| 3412 | |
| 3413 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 3414 | // First need to successfully create the PSO from above by setting |
| 3415 | // pViewports |
| 3416 | m_errorMonitor->SetDesiredFailureMsg( |
| 3417 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3418 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 3419 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3420 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3421 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 3422 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3423 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3424 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3425 | ASSERT_VK_SUCCESS(err); |
| 3426 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3427 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3428 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3429 | VkViewport viewports[2] = {}; // don't care about data |
| 3430 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 3431 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3432 | Draw(1, 0, 0, 0); |
| 3433 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3434 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3435 | FAIL() << "Did not receive Error 'Dynamic viewportCount from " |
| 3436 | "vkCmdSetViewport() is 2, but PSO viewportCount is 1...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3437 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3438 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3439 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3440 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3441 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3442 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3443 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3444 | } |
| 3445 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3446 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3447 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3448 | m_errorMonitor->SetDesiredFailureMsg( |
| 3449 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3450 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3451 | |
| 3452 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3453 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3454 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3455 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3456 | // Don't care about RenderPass handle b/c error should be flagged before |
| 3457 | // that |
| 3458 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 3459 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3460 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3461 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3462 | FAIL() << "Did not receive Error 'You cannot use a NULL RenderPass " |
| 3463 | "object in vkCmdBeginRenderPass()'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3464 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3465 | } |
| 3466 | } |
| 3467 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3468 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3469 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3470 | m_errorMonitor->SetDesiredFailureMsg( |
| 3471 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3472 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3473 | |
| 3474 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3475 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3476 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3477 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3478 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 3479 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3480 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3481 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 3482 | rp_begin.pNext = NULL; |
| 3483 | rp_begin.renderPass = renderPass(); |
| 3484 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3485 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3486 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 3487 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3488 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3489 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3490 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3491 | "inside an active render pass...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3492 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3493 | } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3494 | } |
| 3495 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3496 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3497 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3498 | m_errorMonitor->SetDesiredFailureMsg( |
| 3499 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3500 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3501 | |
| 3502 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3503 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3504 | |
| 3505 | // Renderpass is started here |
| 3506 | BeginCommandBuffer(); |
| 3507 | |
| 3508 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3509 | vk_testing::Buffer dstBuffer; |
| 3510 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3511 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3512 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3513 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3514 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3515 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3516 | "inside an active render pass...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3517 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3518 | } |
| 3519 | } |
| 3520 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3521 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3522 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3523 | m_errorMonitor->SetDesiredFailureMsg( |
| 3524 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3525 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3526 | |
| 3527 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3528 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3529 | |
| 3530 | // Renderpass is started here |
| 3531 | BeginCommandBuffer(); |
| 3532 | |
| 3533 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3534 | vk_testing::Buffer dstBuffer; |
| 3535 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3536 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3537 | VkDeviceSize dstOffset = 0; |
| 3538 | VkDeviceSize dataSize = 1024; |
| 3539 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3540 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3541 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 3542 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3543 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3544 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3545 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3546 | "inside an active render pass...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3547 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3548 | } |
| 3549 | } |
| 3550 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3551 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3552 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3553 | m_errorMonitor->SetDesiredFailureMsg( |
| 3554 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3555 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3556 | |
| 3557 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3558 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3559 | |
| 3560 | // Renderpass is started here |
| 3561 | BeginCommandBuffer(); |
| 3562 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 3563 | VkClearColorValue clear_color; |
| 3564 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3565 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 3566 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3567 | const int32_t tex_width = 32; |
| 3568 | const int32_t tex_height = 32; |
| 3569 | VkImageCreateInfo image_create_info = {}; |
| 3570 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3571 | image_create_info.pNext = NULL; |
| 3572 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3573 | image_create_info.format = tex_format; |
| 3574 | image_create_info.extent.width = tex_width; |
| 3575 | image_create_info.extent.height = tex_height; |
| 3576 | image_create_info.extent.depth = 1; |
| 3577 | image_create_info.mipLevels = 1; |
| 3578 | image_create_info.arrayLayers = 1; |
| 3579 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3580 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3581 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3582 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3583 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3584 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 3585 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3586 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3587 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 3588 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3589 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3590 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 3591 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3592 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3593 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3594 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3595 | "inside an active render pass...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3596 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3597 | } |
| 3598 | } |
| 3599 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3600 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3601 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3602 | m_errorMonitor->SetDesiredFailureMsg( |
| 3603 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3604 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3605 | |
| 3606 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3607 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3608 | |
| 3609 | // Renderpass is started here |
| 3610 | BeginCommandBuffer(); |
| 3611 | |
| 3612 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame^] | 3613 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3614 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 3615 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3616 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3617 | image_create_info.extent.width = 64; |
| 3618 | image_create_info.extent.height = 64; |
| 3619 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3620 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3621 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3622 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3623 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 3624 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3625 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3626 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 3627 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3628 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3629 | vkCmdClearDepthStencilImage( |
| 3630 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 3631 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 3632 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3633 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3634 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3635 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3636 | "inside an active render pass...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3637 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3638 | } |
| 3639 | } |
| 3640 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3641 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3642 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3643 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3644 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3645 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3646 | "vkCmdClearAttachments: This call " |
| 3647 | "must be issued inside an active " |
| 3648 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3649 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3650 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3651 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3652 | |
| 3653 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3654 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3655 | ASSERT_VK_SUCCESS(err); |
| 3656 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3657 | VkClearAttachment color_attachment; |
| 3658 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3659 | color_attachment.clearValue.color.float32[0] = 0; |
| 3660 | color_attachment.clearValue.color.float32[1] = 0; |
| 3661 | color_attachment.clearValue.color.float32[2] = 0; |
| 3662 | color_attachment.clearValue.color.float32[3] = 0; |
| 3663 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3664 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 3665 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 3666 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3667 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3668 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3669 | FAIL() << "Did not receive Error 'vkCmdClearAttachments: This call " |
| 3670 | "must be issued inside an active render pass.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3671 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3672 | } |
| 3673 | } |
| 3674 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3675 | TEST_F(VkLayerTest, InvalidDynamicStateObject) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3676 | // Create a valid cmd buffer |
| 3677 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3678 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 3679 | // catch this case |
| 3680 | // The DS check for this is after driver has been called to validate DS |
| 3681 | // internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3682 | } |
Tobin Ehlis | 1056d45 | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 3683 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3684 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3685 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3686 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3687 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3688 | m_errorMonitor->SetDesiredFailureMsg( |
| 3689 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3690 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 3691 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3692 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3693 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3694 | uint32_t qfi = 0; |
| 3695 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3696 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3697 | buffCI.size = 1024; |
| 3698 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 3699 | buffCI.queueFamilyIndexCount = 1; |
| 3700 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3701 | |
| 3702 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3703 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3704 | ASSERT_VK_SUCCESS(err); |
| 3705 | |
| 3706 | BeginCommandBuffer(); |
| 3707 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3708 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3709 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3710 | // 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] | 3711 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 3712 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3713 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3714 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3715 | FAIL() << "Did not receive Error 'vkCmdBindIndexBuffer() offset (0x7) " |
| 3716 | "does not fall on ...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3717 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3718 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3719 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3720 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3721 | } |
| 3722 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3723 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 3724 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 3725 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3726 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3727 | m_errorMonitor->SetDesiredFailureMsg( |
| 3728 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3729 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3730 | |
| 3731 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3732 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3733 | |
| 3734 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3735 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3736 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 3737 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3738 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3739 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3740 | FAIL() << "Did not receive Error 'vkCmdExecuteCommands() called w/ " |
| 3741 | "Primary Cmd Buffer '"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3742 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3743 | } |
| 3744 | } |
| 3745 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3746 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3747 | // 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] | 3748 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3749 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3750 | m_errorMonitor->SetDesiredFailureMsg( |
| 3751 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Write descriptor update has descriptor " |
| 3752 | "type VK_DESCRIPTOR_TYPE_SAMPLER that " |
| 3753 | "does not match "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3754 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3755 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3756 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3757 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3758 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3759 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3760 | |
| 3761 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3762 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3763 | ds_pool_ci.pNext = NULL; |
| 3764 | ds_pool_ci.maxSets = 1; |
| 3765 | ds_pool_ci.poolSizeCount = 1; |
| 3766 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3767 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3768 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3769 | err = |
| 3770 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3771 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3772 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3773 | dsl_binding.binding = 0; |
| 3774 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3775 | dsl_binding.descriptorCount = 1; |
| 3776 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3777 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3778 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3779 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3780 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3781 | ds_layout_ci.pNext = NULL; |
| 3782 | ds_layout_ci.bindingCount = 1; |
| 3783 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3784 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3785 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3786 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3787 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3788 | ASSERT_VK_SUCCESS(err); |
| 3789 | |
| 3790 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3791 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3792 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3793 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3794 | alloc_info.descriptorPool = ds_pool; |
| 3795 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3796 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3797 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3798 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3799 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3800 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3801 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3802 | sampler_ci.pNext = NULL; |
| 3803 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3804 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3805 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3806 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3807 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3808 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3809 | sampler_ci.mipLodBias = 1.0; |
| 3810 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3811 | sampler_ci.maxAnisotropy = 1; |
| 3812 | sampler_ci.compareEnable = VK_FALSE; |
| 3813 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3814 | sampler_ci.minLod = 1.0; |
| 3815 | sampler_ci.maxLod = 1.0; |
| 3816 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3817 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3818 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3819 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3820 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3821 | ASSERT_VK_SUCCESS(err); |
| 3822 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3823 | VkDescriptorImageInfo info = {}; |
| 3824 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3825 | |
| 3826 | VkWriteDescriptorSet descriptor_write; |
| 3827 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3828 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3829 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3830 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3831 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3832 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3833 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3834 | |
| 3835 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3836 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3837 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3838 | FAIL() << "Did not receive Error 'Write descriptor update has " |
| 3839 | "descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not " |
| 3840 | "match...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3841 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3842 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3843 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3844 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3845 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3846 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3847 | } |
| 3848 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3849 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3850 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3851 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3852 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3853 | m_errorMonitor->SetDesiredFailureMsg( |
| 3854 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Descriptor update type of " |
| 3855 | "VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET " |
| 3856 | "is out of bounds for matching binding"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3857 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3858 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3859 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3860 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3861 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3862 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3863 | |
| 3864 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3865 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3866 | ds_pool_ci.pNext = NULL; |
| 3867 | ds_pool_ci.maxSets = 1; |
| 3868 | ds_pool_ci.poolSizeCount = 1; |
| 3869 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3870 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3871 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3872 | err = |
| 3873 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3874 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3875 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3876 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3877 | dsl_binding.binding = 0; |
| 3878 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3879 | dsl_binding.descriptorCount = 1; |
| 3880 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3881 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3882 | |
| 3883 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3884 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3885 | ds_layout_ci.pNext = NULL; |
| 3886 | ds_layout_ci.bindingCount = 1; |
| 3887 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3888 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3889 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3890 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3891 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3892 | ASSERT_VK_SUCCESS(err); |
| 3893 | |
| 3894 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3895 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3896 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3897 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3898 | alloc_info.descriptorPool = ds_pool; |
| 3899 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3900 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3901 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3902 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3903 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3904 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3905 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3906 | sampler_ci.pNext = NULL; |
| 3907 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3908 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3909 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3910 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3911 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3912 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3913 | sampler_ci.mipLodBias = 1.0; |
| 3914 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3915 | sampler_ci.maxAnisotropy = 1; |
| 3916 | sampler_ci.compareEnable = VK_FALSE; |
| 3917 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3918 | sampler_ci.minLod = 1.0; |
| 3919 | sampler_ci.maxLod = 1.0; |
| 3920 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3921 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3922 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3923 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3924 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3925 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3926 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3927 | VkDescriptorImageInfo info = {}; |
| 3928 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3929 | |
| 3930 | VkWriteDescriptorSet descriptor_write; |
| 3931 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3932 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3933 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3934 | descriptor_write.dstArrayElement = |
| 3935 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3936 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3937 | // 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] | 3938 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3939 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3940 | |
| 3941 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3942 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3943 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3944 | FAIL() << "Did not receive Error 'Descriptor update type of " |
| 3945 | "VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for " |
| 3946 | "matching binding...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3947 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3948 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3949 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3950 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3951 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3952 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3953 | } |
| 3954 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3955 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 3956 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 3957 | // index 2 |
| 3958 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3959 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3960 | m_errorMonitor->SetDesiredFailureMsg( |
| 3961 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3962 | " does not have binding to match update binding "); |
| 3963 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3964 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3965 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3966 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3967 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3968 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3969 | |
| 3970 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3971 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3972 | ds_pool_ci.pNext = NULL; |
| 3973 | ds_pool_ci.maxSets = 1; |
| 3974 | ds_pool_ci.poolSizeCount = 1; |
| 3975 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3976 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3977 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3978 | err = |
| 3979 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3980 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3981 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3982 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3983 | dsl_binding.binding = 0; |
| 3984 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3985 | dsl_binding.descriptorCount = 1; |
| 3986 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3987 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3988 | |
| 3989 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3990 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3991 | ds_layout_ci.pNext = NULL; |
| 3992 | ds_layout_ci.bindingCount = 1; |
| 3993 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3994 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3995 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3996 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3997 | ASSERT_VK_SUCCESS(err); |
| 3998 | |
| 3999 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4000 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4001 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4002 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4003 | alloc_info.descriptorPool = ds_pool; |
| 4004 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4005 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4006 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4007 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4008 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4009 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4010 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4011 | sampler_ci.pNext = NULL; |
| 4012 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4013 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4014 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4015 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4016 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4017 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4018 | sampler_ci.mipLodBias = 1.0; |
| 4019 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4020 | sampler_ci.maxAnisotropy = 1; |
| 4021 | sampler_ci.compareEnable = VK_FALSE; |
| 4022 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4023 | sampler_ci.minLod = 1.0; |
| 4024 | sampler_ci.maxLod = 1.0; |
| 4025 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4026 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4027 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4028 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4029 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4030 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4031 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4032 | VkDescriptorImageInfo info = {}; |
| 4033 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4034 | |
| 4035 | VkWriteDescriptorSet descriptor_write; |
| 4036 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4037 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4038 | descriptor_write.dstSet = descriptorSet; |
| 4039 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4040 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4041 | // 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] | 4042 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4043 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4044 | |
| 4045 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4046 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4047 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4048 | FAIL() << "Did not receive Error 'Descriptor Set <blah> does not have " |
| 4049 | "binding to match update binding '"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4050 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4051 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4052 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4053 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4054 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4055 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4056 | } |
| 4057 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4058 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 4059 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 4060 | // types |
| 4061 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4062 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4063 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4064 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4065 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4066 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4067 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4068 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4069 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4070 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4071 | |
| 4072 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4073 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4074 | ds_pool_ci.pNext = NULL; |
| 4075 | ds_pool_ci.maxSets = 1; |
| 4076 | ds_pool_ci.poolSizeCount = 1; |
| 4077 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4078 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4079 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4080 | err = |
| 4081 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4082 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4083 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4084 | dsl_binding.binding = 0; |
| 4085 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4086 | dsl_binding.descriptorCount = 1; |
| 4087 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4088 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4089 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4090 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4091 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4092 | ds_layout_ci.pNext = NULL; |
| 4093 | ds_layout_ci.bindingCount = 1; |
| 4094 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4095 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4096 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4097 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4098 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4099 | ASSERT_VK_SUCCESS(err); |
| 4100 | |
| 4101 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4102 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4103 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4104 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4105 | alloc_info.descriptorPool = ds_pool; |
| 4106 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4107 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4108 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4109 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4110 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4111 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4112 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4113 | sampler_ci.pNext = NULL; |
| 4114 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4115 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4116 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4117 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4118 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4119 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4120 | sampler_ci.mipLodBias = 1.0; |
| 4121 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4122 | sampler_ci.maxAnisotropy = 1; |
| 4123 | sampler_ci.compareEnable = VK_FALSE; |
| 4124 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4125 | sampler_ci.minLod = 1.0; |
| 4126 | sampler_ci.maxLod = 1.0; |
| 4127 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4128 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4129 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4130 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4131 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4132 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4133 | VkDescriptorImageInfo info = {}; |
| 4134 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4135 | |
| 4136 | VkWriteDescriptorSet descriptor_write; |
| 4137 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4138 | descriptor_write.sType = |
| 4139 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4140 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4141 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4142 | // 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] | 4143 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4144 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4145 | |
| 4146 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4147 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4148 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4149 | FAIL() << "Did not receive Error 'Unexpected UPDATE struct of type '"; |
| 4150 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4151 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4152 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4153 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4154 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4155 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4156 | } |
| 4157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4158 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4159 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4160 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4161 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4162 | m_errorMonitor->SetDesiredFailureMsg( |
| 4163 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4164 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 4165 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4166 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4167 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 4168 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4169 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4170 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4171 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4172 | |
| 4173 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4174 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4175 | ds_pool_ci.pNext = NULL; |
| 4176 | ds_pool_ci.maxSets = 1; |
| 4177 | ds_pool_ci.poolSizeCount = 1; |
| 4178 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4179 | |
| 4180 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4181 | err = |
| 4182 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4183 | ASSERT_VK_SUCCESS(err); |
| 4184 | |
| 4185 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4186 | dsl_binding.binding = 0; |
| 4187 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4188 | dsl_binding.descriptorCount = 1; |
| 4189 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4190 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4191 | |
| 4192 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4193 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4194 | ds_layout_ci.pNext = NULL; |
| 4195 | ds_layout_ci.bindingCount = 1; |
| 4196 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4197 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4198 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4199 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4200 | ASSERT_VK_SUCCESS(err); |
| 4201 | |
| 4202 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4203 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4204 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4205 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4206 | alloc_info.descriptorPool = ds_pool; |
| 4207 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4208 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4209 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4210 | ASSERT_VK_SUCCESS(err); |
| 4211 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4212 | VkSampler sampler = |
| 4213 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4214 | |
| 4215 | VkDescriptorImageInfo descriptor_info; |
| 4216 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 4217 | descriptor_info.sampler = sampler; |
| 4218 | |
| 4219 | VkWriteDescriptorSet descriptor_write; |
| 4220 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4221 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4222 | descriptor_write.dstSet = descriptorSet; |
| 4223 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4224 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4225 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4226 | descriptor_write.pImageInfo = &descriptor_info; |
| 4227 | |
| 4228 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4229 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4230 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4231 | FAIL() << "Did not receive Error 'Attempt to update descriptor with " |
| 4232 | "invalid sampler...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4233 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4234 | } |
| 4235 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4236 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4237 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4238 | } |
| 4239 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4240 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 4241 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 4242 | // imageView |
| 4243 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4244 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4245 | m_errorMonitor->SetDesiredFailureMsg( |
| 4246 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4247 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 4248 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4249 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4250 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4251 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4252 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4253 | |
| 4254 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4255 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4256 | ds_pool_ci.pNext = NULL; |
| 4257 | ds_pool_ci.maxSets = 1; |
| 4258 | ds_pool_ci.poolSizeCount = 1; |
| 4259 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4260 | |
| 4261 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4262 | err = |
| 4263 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4264 | ASSERT_VK_SUCCESS(err); |
| 4265 | |
| 4266 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4267 | dsl_binding.binding = 0; |
| 4268 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4269 | dsl_binding.descriptorCount = 1; |
| 4270 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4271 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4272 | |
| 4273 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4274 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4275 | ds_layout_ci.pNext = NULL; |
| 4276 | ds_layout_ci.bindingCount = 1; |
| 4277 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4278 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4279 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4280 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4281 | ASSERT_VK_SUCCESS(err); |
| 4282 | |
| 4283 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4284 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4285 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4286 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4287 | alloc_info.descriptorPool = ds_pool; |
| 4288 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4289 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4290 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4291 | ASSERT_VK_SUCCESS(err); |
| 4292 | |
| 4293 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4294 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4295 | sampler_ci.pNext = NULL; |
| 4296 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4297 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4298 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4299 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4300 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4301 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4302 | sampler_ci.mipLodBias = 1.0; |
| 4303 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4304 | sampler_ci.maxAnisotropy = 1; |
| 4305 | sampler_ci.compareEnable = VK_FALSE; |
| 4306 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4307 | sampler_ci.minLod = 1.0; |
| 4308 | sampler_ci.maxLod = 1.0; |
| 4309 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4310 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4311 | |
| 4312 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4313 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4314 | ASSERT_VK_SUCCESS(err); |
| 4315 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4316 | VkImageView view = |
| 4317 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4318 | |
| 4319 | VkDescriptorImageInfo descriptor_info; |
| 4320 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 4321 | descriptor_info.sampler = sampler; |
| 4322 | descriptor_info.imageView = view; |
| 4323 | |
| 4324 | VkWriteDescriptorSet descriptor_write; |
| 4325 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4326 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4327 | descriptor_write.dstSet = descriptorSet; |
| 4328 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4329 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4330 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4331 | descriptor_write.pImageInfo = &descriptor_info; |
| 4332 | |
| 4333 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4334 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4335 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4336 | FAIL() << "Did not receive Error 'Attempt to update descriptor with " |
| 4337 | "invalid imageView...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4338 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4339 | } |
| 4340 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4341 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4342 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4343 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4344 | } |
| 4345 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4346 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 4347 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 4348 | // into the other |
| 4349 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4350 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4351 | m_errorMonitor->SetDesiredFailureMsg( |
| 4352 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Copy descriptor update index 0, update " |
| 4353 | "count #1, has src update descriptor " |
| 4354 | "type VK_DESCRIPTOR_TYPE_SAMPLER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4355 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4356 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4357 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4358 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4359 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4360 | ds_type_count[0].descriptorCount = 1; |
| 4361 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4362 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4363 | |
| 4364 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4365 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4366 | ds_pool_ci.pNext = NULL; |
| 4367 | ds_pool_ci.maxSets = 1; |
| 4368 | ds_pool_ci.poolSizeCount = 2; |
| 4369 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4370 | |
| 4371 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4372 | err = |
| 4373 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4374 | ASSERT_VK_SUCCESS(err); |
| 4375 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4376 | dsl_binding[0].binding = 0; |
| 4377 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4378 | dsl_binding[0].descriptorCount = 1; |
| 4379 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4380 | dsl_binding[0].pImmutableSamplers = NULL; |
| 4381 | dsl_binding[1].binding = 1; |
| 4382 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4383 | dsl_binding[1].descriptorCount = 1; |
| 4384 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 4385 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4386 | |
| 4387 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4388 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4389 | ds_layout_ci.pNext = NULL; |
| 4390 | ds_layout_ci.bindingCount = 2; |
| 4391 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4392 | |
| 4393 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4394 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4395 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4396 | ASSERT_VK_SUCCESS(err); |
| 4397 | |
| 4398 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4399 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4400 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4401 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4402 | alloc_info.descriptorPool = ds_pool; |
| 4403 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4404 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4405 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4406 | ASSERT_VK_SUCCESS(err); |
| 4407 | |
| 4408 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4409 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4410 | sampler_ci.pNext = NULL; |
| 4411 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4412 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4413 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4414 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4415 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4416 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4417 | sampler_ci.mipLodBias = 1.0; |
| 4418 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4419 | sampler_ci.maxAnisotropy = 1; |
| 4420 | sampler_ci.compareEnable = VK_FALSE; |
| 4421 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4422 | sampler_ci.minLod = 1.0; |
| 4423 | sampler_ci.maxLod = 1.0; |
| 4424 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4425 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4426 | |
| 4427 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4428 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4429 | ASSERT_VK_SUCCESS(err); |
| 4430 | |
| 4431 | VkDescriptorImageInfo info = {}; |
| 4432 | info.sampler = sampler; |
| 4433 | |
| 4434 | VkWriteDescriptorSet descriptor_write; |
| 4435 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 4436 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4437 | descriptor_write.dstSet = descriptorSet; |
| 4438 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4439 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4440 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4441 | descriptor_write.pImageInfo = &info; |
| 4442 | // This write update should succeed |
| 4443 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4444 | // Now perform a copy update that fails due to type mismatch |
| 4445 | VkCopyDescriptorSet copy_ds_update; |
| 4446 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4447 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4448 | copy_ds_update.srcSet = descriptorSet; |
| 4449 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4450 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4451 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4452 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4453 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4454 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4455 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4456 | FAIL() << "Did not receive Error 'Copy descriptor update index 0, " |
| 4457 | "update count #1, has src update descriptor " |
| 4458 | "type_DESCRIPTOR_TYPE_SAMPLER'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4459 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4460 | } |
| 4461 | // 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] | 4462 | m_errorMonitor->SetDesiredFailureMsg( |
| 4463 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4464 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4465 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4466 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4467 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4468 | copy_ds_update.srcBinding = |
| 4469 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4470 | copy_ds_update.dstSet = descriptorSet; |
| 4471 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4472 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4473 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4474 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4475 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4476 | FAIL() << "Did not receive Error 'Copy descriptor update 0 has " |
| 4477 | "srcBinding 3 which is out of bounds...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4478 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4479 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4480 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4481 | // 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] | 4482 | m_errorMonitor->SetDesiredFailureMsg( |
| 4483 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4484 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 4485 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4486 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4487 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4488 | copy_ds_update.srcSet = descriptorSet; |
| 4489 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4490 | copy_ds_update.dstSet = descriptorSet; |
| 4491 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4492 | copy_ds_update.descriptorCount = |
| 4493 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4494 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4495 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4496 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4497 | FAIL() << "Did not receive Error 'Copy descriptor src update is out of " |
| 4498 | "bounds for matching binding 1...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4499 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4500 | } |
| 4501 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4502 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4503 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4504 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4505 | } |
| 4506 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4507 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 4508 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 4509 | // sampleCount |
| 4510 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4511 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4512 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4513 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4514 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4515 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4516 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4517 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4518 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4519 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4520 | |
| 4521 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4522 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4523 | ds_pool_ci.pNext = NULL; |
| 4524 | ds_pool_ci.maxSets = 1; |
| 4525 | ds_pool_ci.poolSizeCount = 1; |
| 4526 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4527 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4528 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4529 | err = |
| 4530 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4531 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4532 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4533 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4534 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4535 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4536 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4537 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4538 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4539 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4540 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4541 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4542 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4543 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4544 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4545 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4546 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4547 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4548 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4549 | ASSERT_VK_SUCCESS(err); |
| 4550 | |
| 4551 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4552 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4553 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4554 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4555 | alloc_info.descriptorPool = ds_pool; |
| 4556 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4557 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4558 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4559 | ASSERT_VK_SUCCESS(err); |
| 4560 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4561 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4562 | pipe_ms_state_ci.sType = |
| 4563 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4564 | pipe_ms_state_ci.pNext = NULL; |
| 4565 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 4566 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4567 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4568 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4569 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4570 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4571 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4572 | pipeline_layout_ci.pNext = NULL; |
| 4573 | pipeline_layout_ci.setLayoutCount = 1; |
| 4574 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4575 | |
| 4576 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4577 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4578 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4579 | ASSERT_VK_SUCCESS(err); |
| 4580 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4581 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4582 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4583 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4584 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4585 | this); // TODO - We shouldn't need a fragment shader |
| 4586 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4587 | VkPipelineObj pipe(m_device); |
| 4588 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4589 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4590 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4591 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4592 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4593 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4594 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4595 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4596 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4597 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4598 | FAIL() << "Did not recieve Error 'Num samples mismatch!...'"; |
| 4599 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4600 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4601 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4602 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4603 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4604 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4605 | } |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4606 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4607 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 4608 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 4609 | // to issuing a Draw |
| 4610 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4611 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4612 | // TODO: verify that this matches layer |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4613 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4614 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4615 | "vkCmdClearAttachments() issued on CB object "); |
| 4616 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4617 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4618 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4619 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4620 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4621 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4622 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4623 | |
| 4624 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4625 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4626 | ds_pool_ci.pNext = NULL; |
| 4627 | ds_pool_ci.maxSets = 1; |
| 4628 | ds_pool_ci.poolSizeCount = 1; |
| 4629 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4630 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4631 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4632 | err = |
| 4633 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4634 | ASSERT_VK_SUCCESS(err); |
| 4635 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4636 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4637 | dsl_binding.binding = 0; |
| 4638 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4639 | dsl_binding.descriptorCount = 1; |
| 4640 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4641 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4642 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4643 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4644 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4645 | ds_layout_ci.pNext = NULL; |
| 4646 | ds_layout_ci.bindingCount = 1; |
| 4647 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4648 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4649 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4650 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4651 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4652 | ASSERT_VK_SUCCESS(err); |
| 4653 | |
| 4654 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4655 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4656 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4657 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4658 | alloc_info.descriptorPool = ds_pool; |
| 4659 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4660 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4661 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4662 | ASSERT_VK_SUCCESS(err); |
| 4663 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4664 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4665 | pipe_ms_state_ci.sType = |
| 4666 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4667 | pipe_ms_state_ci.pNext = NULL; |
| 4668 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 4669 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4670 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4671 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4672 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4673 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4674 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4675 | pipeline_layout_ci.pNext = NULL; |
| 4676 | pipeline_layout_ci.setLayoutCount = 1; |
| 4677 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4678 | |
| 4679 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4680 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4681 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4682 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4683 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4684 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4685 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4686 | // TODO - We shouldn't need a fragment shader but add it to be able to run |
| 4687 | // on more devices |
| 4688 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4689 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4690 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4691 | VkPipelineObj pipe(m_device); |
| 4692 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4693 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4694 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4695 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4696 | |
| 4697 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4698 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4699 | // Main thing we care about for this test is that the VkImage obj we're |
| 4700 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4701 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4702 | VkClearAttachment color_attachment; |
| 4703 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4704 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 4705 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 4706 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 4707 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 4708 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4709 | VkClearRect clear_rect = { |
| 4710 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4711 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4712 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 4713 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4714 | |
| 4715 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4716 | FAIL() << "Did not receive Error 'vkCommandClearAttachments() issued " |
| 4717 | "on CB object...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4718 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4719 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4720 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4721 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4722 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4723 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4724 | } |
| 4725 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4726 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 4727 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4728 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4729 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4730 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 4731 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4732 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4733 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4734 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4735 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4736 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4737 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4738 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4739 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4740 | |
| 4741 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4742 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4743 | ds_pool_ci.pNext = NULL; |
| 4744 | ds_pool_ci.maxSets = 1; |
| 4745 | ds_pool_ci.poolSizeCount = 1; |
| 4746 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4747 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4748 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4749 | err = |
| 4750 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4751 | ASSERT_VK_SUCCESS(err); |
| 4752 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4753 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4754 | dsl_binding.binding = 0; |
| 4755 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4756 | dsl_binding.descriptorCount = 1; |
| 4757 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4758 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4759 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4760 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4761 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4762 | ds_layout_ci.pNext = NULL; |
| 4763 | ds_layout_ci.bindingCount = 1; |
| 4764 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4765 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4766 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4767 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4768 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4769 | ASSERT_VK_SUCCESS(err); |
| 4770 | |
| 4771 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4772 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4773 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4774 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4775 | alloc_info.descriptorPool = ds_pool; |
| 4776 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4777 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4778 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4779 | ASSERT_VK_SUCCESS(err); |
| 4780 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4781 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4782 | pipe_ms_state_ci.sType = |
| 4783 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4784 | pipe_ms_state_ci.pNext = NULL; |
| 4785 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 4786 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4787 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4788 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4789 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4790 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4791 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4792 | pipeline_layout_ci.pNext = NULL; |
| 4793 | pipeline_layout_ci.setLayoutCount = 1; |
| 4794 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4795 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4796 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4797 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4798 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4799 | ASSERT_VK_SUCCESS(err); |
| 4800 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4801 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4802 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4803 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4804 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4805 | this); // TODO - We shouldn't need a fragment shader |
| 4806 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4807 | VkPipelineObj pipe(m_device); |
| 4808 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4809 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4810 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4811 | pipe.SetViewport(m_viewports); |
| 4812 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4813 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4814 | |
| 4815 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4816 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4817 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4818 | // Don't care about actual data, just need to get to draw to flag error |
| 4819 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4820 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 4821 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4822 | 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] | 4823 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4824 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4825 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4826 | FAIL() << "Did not receive Error 'Vtx Buffer Index 0 was bound, but no " |
| 4827 | "vtx buffers are attached to PSO.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4828 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4829 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4830 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4831 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4832 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4833 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4834 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4835 | #endif // DRAW_STATE_TESTS |
| 4836 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 4837 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4838 | #if GTEST_IS_THREADSAFE |
| 4839 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4840 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4841 | VkEvent event; |
| 4842 | bool bailout; |
| 4843 | }; |
| 4844 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4845 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 4846 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4847 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4848 | for (int i = 0; i < 10000; i++) { |
| 4849 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 4850 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4851 | if (data->bailout) { |
| 4852 | break; |
| 4853 | } |
| 4854 | } |
| 4855 | return NULL; |
| 4856 | } |
| 4857 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4858 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4859 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4860 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4861 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4862 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4863 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4864 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4865 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4866 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4867 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4868 | // Calls AllocateCommandBuffers |
| 4869 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4870 | |
| 4871 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4872 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4873 | |
| 4874 | VkEventCreateInfo event_info; |
| 4875 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4876 | VkResult err; |
| 4877 | |
| 4878 | memset(&event_info, 0, sizeof(event_info)); |
| 4879 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 4880 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4881 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4882 | ASSERT_VK_SUCCESS(err); |
| 4883 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4884 | err = vkResetEvent(device(), event); |
| 4885 | ASSERT_VK_SUCCESS(err); |
| 4886 | |
| 4887 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4888 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4889 | data.event = event; |
| 4890 | data.bailout = false; |
| 4891 | m_errorMonitor->SetBailout(&data.bailout); |
| 4892 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4893 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4894 | // Add many entries to command buffer from this thread at the same time. |
| 4895 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4896 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4897 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4898 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4899 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 4900 | m_errorMonitor->SetBailout(NULL); |
| 4901 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4902 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4903 | FAIL() << "Did not receive Error 'THREADING ERROR' from using one " |
| 4904 | "VkCommandBufferObj in two threads"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4905 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4906 | } |
| 4907 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4908 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4909 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4910 | #endif // GTEST_IS_THREADSAFE |
| 4911 | #endif // THREADING_TESTS |
| 4912 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4913 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4914 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4915 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4916 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4917 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4918 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4919 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4920 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4921 | VkShaderModule module; |
| 4922 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4923 | struct icd_spv_header spv; |
| 4924 | |
| 4925 | spv.magic = ICD_SPV_MAGIC; |
| 4926 | spv.version = ICD_SPV_VERSION; |
| 4927 | spv.gen_magic = 0; |
| 4928 | |
| 4929 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4930 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4931 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4932 | moduleCreateInfo.codeSize = 4; |
| 4933 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4934 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4935 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4936 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4937 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4938 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4939 | } |
| 4940 | } |
| 4941 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4942 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4943 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4944 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4945 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4946 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4947 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4948 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4949 | VkShaderModule module; |
| 4950 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4951 | struct icd_spv_header spv; |
| 4952 | |
| 4953 | spv.magic = ~ICD_SPV_MAGIC; |
| 4954 | spv.version = ICD_SPV_VERSION; |
| 4955 | spv.gen_magic = 0; |
| 4956 | |
| 4957 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4958 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4959 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4960 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4961 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4962 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4963 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4964 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4965 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4966 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4967 | } |
| 4968 | } |
| 4969 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4970 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4971 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4972 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4973 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4974 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4975 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4976 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4977 | VkShaderModule module; |
| 4978 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4979 | struct icd_spv_header spv; |
| 4980 | |
| 4981 | spv.magic = ICD_SPV_MAGIC; |
| 4982 | spv.version = ~ICD_SPV_VERSION; |
| 4983 | spv.gen_magic = 0; |
| 4984 | |
| 4985 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4986 | moduleCreateInfo.pNext = NULL; |
| 4987 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4988 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4989 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4990 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4991 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4992 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4993 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4994 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4995 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4996 | } |
| 4997 | } |
| 4998 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4999 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5000 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5001 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5002 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5003 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5004 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5005 | |
| 5006 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5007 | "#version 400\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5008 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5009 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5010 | "\n" |
| 5011 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5012 | "out gl_PerVertex {\n" |
| 5013 | " vec4 gl_Position;\n" |
| 5014 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5015 | "void main(){\n" |
| 5016 | " gl_Position = vec4(1);\n" |
| 5017 | " x = 0;\n" |
| 5018 | "}\n"; |
| 5019 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5020 | "#version 400\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5021 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5022 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5023 | "\n" |
| 5024 | "layout(location=0) out vec4 color;\n" |
| 5025 | "void main(){\n" |
| 5026 | " color = vec4(1);\n" |
| 5027 | "}\n"; |
| 5028 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5029 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5030 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5031 | |
| 5032 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5033 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5034 | pipe.AddShader(&vs); |
| 5035 | pipe.AddShader(&fs); |
| 5036 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5037 | VkDescriptorSetObj descriptorSet(m_device); |
| 5038 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5039 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5040 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5041 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5042 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5043 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5044 | FAIL() << "Did not receive Warning 'not consumed by fragment shader'"; |
| 5045 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5046 | } |
| 5047 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5048 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5049 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5050 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5051 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5052 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5053 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5054 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5055 | |
| 5056 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5057 | "#version 400\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5058 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5059 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5060 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5061 | "out gl_PerVertex {\n" |
| 5062 | " vec4 gl_Position;\n" |
| 5063 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5064 | "void main(){\n" |
| 5065 | " gl_Position = vec4(1);\n" |
| 5066 | "}\n"; |
| 5067 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5068 | "#version 400\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5069 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5070 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5071 | "\n" |
| 5072 | "layout(location=0) in float x;\n" |
| 5073 | "layout(location=0) out vec4 color;\n" |
| 5074 | "void main(){\n" |
| 5075 | " color = vec4(x);\n" |
| 5076 | "}\n"; |
| 5077 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5078 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5079 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5080 | |
| 5081 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5082 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5083 | pipe.AddShader(&vs); |
| 5084 | pipe.AddShader(&fs); |
| 5085 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5086 | VkDescriptorSetObj descriptorSet(m_device); |
| 5087 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5088 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5089 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5090 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5091 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5092 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5093 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 5094 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5095 | } |
| 5096 | } |
| 5097 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5098 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5099 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5100 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5101 | |
| 5102 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5103 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5104 | |
| 5105 | char const *vsSource = |
| 5106 | "#version 400\n" |
| 5107 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5108 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5109 | "\n" |
| 5110 | "out gl_PerVertex {\n" |
| 5111 | " vec4 gl_Position;\n" |
| 5112 | "};\n" |
| 5113 | "void main(){\n" |
| 5114 | " gl_Position = vec4(1);\n" |
| 5115 | "}\n"; |
| 5116 | char const *fsSource = |
| 5117 | "#version 450\n" |
| 5118 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5119 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5120 | "\n" |
| 5121 | "in block { layout(location=0) float x; } ins;\n" |
| 5122 | "layout(location=0) out vec4 color;\n" |
| 5123 | "void main(){\n" |
| 5124 | " color = vec4(ins.x);\n" |
| 5125 | "}\n"; |
| 5126 | |
| 5127 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5128 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5129 | |
| 5130 | VkPipelineObj pipe(m_device); |
| 5131 | pipe.AddColorAttachment(); |
| 5132 | pipe.AddShader(&vs); |
| 5133 | pipe.AddShader(&fs); |
| 5134 | |
| 5135 | VkDescriptorSetObj descriptorSet(m_device); |
| 5136 | descriptorSet.AppendDummy(); |
| 5137 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5138 | |
| 5139 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5140 | |
| 5141 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5142 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 5143 | m_errorMonitor->DumpFailureMsgs(); |
| 5144 | } |
| 5145 | } |
| 5146 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5147 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5148 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5149 | "Type mismatch on location 0: 'ptr to " |
| 5150 | "output arr[2] of float32' vs 'ptr to " |
| 5151 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5152 | |
| 5153 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5154 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5155 | |
| 5156 | char const *vsSource = |
| 5157 | "#version 400\n" |
| 5158 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5159 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5160 | "\n" |
| 5161 | "layout(location=0) out float x[2];\n" |
| 5162 | "out gl_PerVertex {\n" |
| 5163 | " vec4 gl_Position;\n" |
| 5164 | "};\n" |
| 5165 | "void main(){\n" |
| 5166 | " x[0] = 0; x[1] = 0;\n" |
| 5167 | " gl_Position = vec4(1);\n" |
| 5168 | "}\n"; |
| 5169 | char const *fsSource = |
| 5170 | "#version 400\n" |
| 5171 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5172 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5173 | "\n" |
| 5174 | "layout(location=0) in float x[3];\n" |
| 5175 | "layout(location=0) out vec4 color;\n" |
| 5176 | "void main(){\n" |
| 5177 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 5178 | "}\n"; |
| 5179 | |
| 5180 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5181 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5182 | |
| 5183 | VkPipelineObj pipe(m_device); |
| 5184 | pipe.AddColorAttachment(); |
| 5185 | pipe.AddShader(&vs); |
| 5186 | pipe.AddShader(&fs); |
| 5187 | |
| 5188 | VkDescriptorSetObj descriptorSet(m_device); |
| 5189 | descriptorSet.AppendDummy(); |
| 5190 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5191 | |
| 5192 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5193 | |
| 5194 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5195 | m_errorMonitor->DumpFailureMsgs(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5196 | FAIL() << "Did not receive Error 'Type mismatch on location 0: 'ptr to " |
| 5197 | "output arr[2] of float32' vs 'ptr to input arr[3] of " |
| 5198 | "float32''"; |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5199 | } |
| 5200 | } |
| 5201 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5202 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5203 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5204 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5205 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5206 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5207 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5208 | |
| 5209 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5210 | "#version 400\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5211 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5212 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5213 | "\n" |
| 5214 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5215 | "out gl_PerVertex {\n" |
| 5216 | " vec4 gl_Position;\n" |
| 5217 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5218 | "void main(){\n" |
| 5219 | " x = 0;\n" |
| 5220 | " gl_Position = vec4(1);\n" |
| 5221 | "}\n"; |
| 5222 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5223 | "#version 400\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5224 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5225 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5226 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5227 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5228 | "layout(location=0) out vec4 color;\n" |
| 5229 | "void main(){\n" |
| 5230 | " color = vec4(x);\n" |
| 5231 | "}\n"; |
| 5232 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5233 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5234 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5235 | |
| 5236 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5237 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5238 | pipe.AddShader(&vs); |
| 5239 | pipe.AddShader(&fs); |
| 5240 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5241 | VkDescriptorSetObj descriptorSet(m_device); |
| 5242 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5243 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5244 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5245 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5246 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5247 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5248 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 5249 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5250 | } |
| 5251 | } |
| 5252 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5253 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5254 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5255 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5256 | |
| 5257 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5258 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5259 | |
| 5260 | char const *vsSource = |
| 5261 | "#version 450\n" |
| 5262 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5263 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5264 | "\n" |
| 5265 | "out block { layout(location=0) int x; } outs;\n" |
| 5266 | "out gl_PerVertex {\n" |
| 5267 | " vec4 gl_Position;\n" |
| 5268 | "};\n" |
| 5269 | "void main(){\n" |
| 5270 | " outs.x = 0;\n" |
| 5271 | " gl_Position = vec4(1);\n" |
| 5272 | "}\n"; |
| 5273 | char const *fsSource = |
| 5274 | "#version 450\n" |
| 5275 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5276 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5277 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5278 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5279 | "layout(location=0) out vec4 color;\n" |
| 5280 | "void main(){\n" |
| 5281 | " color = vec4(ins.x);\n" |
| 5282 | "}\n"; |
| 5283 | |
| 5284 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5285 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5286 | |
| 5287 | VkPipelineObj pipe(m_device); |
| 5288 | pipe.AddColorAttachment(); |
| 5289 | pipe.AddShader(&vs); |
| 5290 | pipe.AddShader(&fs); |
| 5291 | |
| 5292 | VkDescriptorSetObj descriptorSet(m_device); |
| 5293 | descriptorSet.AppendDummy(); |
| 5294 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5295 | |
| 5296 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5297 | |
| 5298 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5299 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 5300 | m_errorMonitor->DumpFailureMsgs(); |
| 5301 | } |
| 5302 | } |
| 5303 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5304 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5305 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5306 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5307 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5308 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5309 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5310 | |
| 5311 | VkVertexInputBindingDescription input_binding; |
| 5312 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5313 | |
| 5314 | VkVertexInputAttributeDescription input_attrib; |
| 5315 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5316 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5317 | |
| 5318 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5319 | "#version 400\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5320 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5321 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5322 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5323 | "out gl_PerVertex {\n" |
| 5324 | " vec4 gl_Position;\n" |
| 5325 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5326 | "void main(){\n" |
| 5327 | " gl_Position = vec4(1);\n" |
| 5328 | "}\n"; |
| 5329 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5330 | "#version 400\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5331 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5332 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5333 | "\n" |
| 5334 | "layout(location=0) out vec4 color;\n" |
| 5335 | "void main(){\n" |
| 5336 | " color = vec4(1);\n" |
| 5337 | "}\n"; |
| 5338 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5339 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5340 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5341 | |
| 5342 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5343 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5344 | pipe.AddShader(&vs); |
| 5345 | pipe.AddShader(&fs); |
| 5346 | |
| 5347 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5348 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5349 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5350 | VkDescriptorSetObj descriptorSet(m_device); |
| 5351 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5352 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5353 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5354 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5355 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5356 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5357 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 5358 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5359 | } |
| 5360 | } |
| 5361 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5362 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5363 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5364 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5365 | |
| 5366 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5367 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5368 | |
| 5369 | VkVertexInputBindingDescription input_binding; |
| 5370 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5371 | |
| 5372 | VkVertexInputAttributeDescription input_attrib; |
| 5373 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5374 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5375 | |
| 5376 | char const *vsSource = |
| 5377 | "#version 400\n" |
| 5378 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5379 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5380 | "\n" |
| 5381 | "layout(location=1) in float x;\n" |
| 5382 | "out gl_PerVertex {\n" |
| 5383 | " vec4 gl_Position;\n" |
| 5384 | "};\n" |
| 5385 | "void main(){\n" |
| 5386 | " gl_Position = vec4(x);\n" |
| 5387 | "}\n"; |
| 5388 | char const *fsSource = |
| 5389 | "#version 400\n" |
| 5390 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5391 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5392 | "\n" |
| 5393 | "layout(location=0) out vec4 color;\n" |
| 5394 | "void main(){\n" |
| 5395 | " color = vec4(1);\n" |
| 5396 | "}\n"; |
| 5397 | |
| 5398 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5399 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5400 | |
| 5401 | VkPipelineObj pipe(m_device); |
| 5402 | pipe.AddColorAttachment(); |
| 5403 | pipe.AddShader(&vs); |
| 5404 | pipe.AddShader(&fs); |
| 5405 | |
| 5406 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5407 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5408 | |
| 5409 | VkDescriptorSetObj descriptorSet(m_device); |
| 5410 | descriptorSet.AppendDummy(); |
| 5411 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5412 | |
| 5413 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5414 | |
| 5415 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5416 | m_errorMonitor->DumpFailureMsgs(); |
| 5417 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 5418 | } |
| 5419 | } |
| 5420 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5421 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 5422 | m_errorMonitor->SetDesiredFailureMsg( |
| 5423 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5424 | "VS consumes input at location 0 but not provided"); |
| 5425 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5426 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5427 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5428 | |
| 5429 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5430 | "#version 400\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5431 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5432 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5433 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5434 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5435 | "out gl_PerVertex {\n" |
| 5436 | " vec4 gl_Position;\n" |
| 5437 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5438 | "void main(){\n" |
| 5439 | " gl_Position = x;\n" |
| 5440 | "}\n"; |
| 5441 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5442 | "#version 400\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5443 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5444 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5445 | "\n" |
| 5446 | "layout(location=0) out vec4 color;\n" |
| 5447 | "void main(){\n" |
| 5448 | " color = vec4(1);\n" |
| 5449 | "}\n"; |
| 5450 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5451 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5452 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5453 | |
| 5454 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5455 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5456 | pipe.AddShader(&vs); |
| 5457 | pipe.AddShader(&fs); |
| 5458 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5459 | VkDescriptorSetObj descriptorSet(m_device); |
| 5460 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5461 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5462 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5463 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5464 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5465 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5466 | FAIL() << "Did not receive Error 'VS consumes input at location 0 but " |
| 5467 | "not provided'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5468 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5469 | } |
| 5470 | } |
| 5471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5472 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 5473 | m_errorMonitor->SetDesiredFailureMsg( |
| 5474 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5475 | "location 0 does not match VS input type"); |
| 5476 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5477 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5478 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5479 | |
| 5480 | VkVertexInputBindingDescription input_binding; |
| 5481 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5482 | |
| 5483 | VkVertexInputAttributeDescription input_attrib; |
| 5484 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5485 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5486 | |
| 5487 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5488 | "#version 400\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5489 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5490 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5491 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5492 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5493 | "out gl_PerVertex {\n" |
| 5494 | " vec4 gl_Position;\n" |
| 5495 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5496 | "void main(){\n" |
| 5497 | " gl_Position = vec4(x);\n" |
| 5498 | "}\n"; |
| 5499 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5500 | "#version 400\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5501 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5502 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5503 | "\n" |
| 5504 | "layout(location=0) out vec4 color;\n" |
| 5505 | "void main(){\n" |
| 5506 | " color = vec4(1);\n" |
| 5507 | "}\n"; |
| 5508 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5509 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5510 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5511 | |
| 5512 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5513 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5514 | pipe.AddShader(&vs); |
| 5515 | pipe.AddShader(&fs); |
| 5516 | |
| 5517 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5518 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5519 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5520 | VkDescriptorSetObj descriptorSet(m_device); |
| 5521 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5522 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5523 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5524 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5525 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5526 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5527 | FAIL() << "Did not receive Error 'location 0 does not match VS input " |
| 5528 | "type'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5529 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5530 | } |
| 5531 | } |
| 5532 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5533 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5534 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 5535 | |
| 5536 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5537 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5538 | |
| 5539 | VkVertexInputBindingDescription input_binding; |
| 5540 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5541 | |
| 5542 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5543 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5544 | |
| 5545 | for (int i = 0; i < 2; i++) { |
| 5546 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5547 | input_attribs[i].location = i; |
| 5548 | } |
| 5549 | |
| 5550 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5551 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5552 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5553 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5554 | "\n" |
| 5555 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5556 | "out gl_PerVertex {\n" |
| 5557 | " vec4 gl_Position;\n" |
| 5558 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5559 | "void main(){\n" |
| 5560 | " gl_Position = x[0] + x[1];\n" |
| 5561 | "}\n"; |
| 5562 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5563 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5564 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5565 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5566 | "\n" |
| 5567 | "layout(location=0) out vec4 color;\n" |
| 5568 | "void main(){\n" |
| 5569 | " color = vec4(1);\n" |
| 5570 | "}\n"; |
| 5571 | |
| 5572 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5573 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5574 | |
| 5575 | VkPipelineObj pipe(m_device); |
| 5576 | pipe.AddColorAttachment(); |
| 5577 | pipe.AddShader(&vs); |
| 5578 | pipe.AddShader(&fs); |
| 5579 | |
| 5580 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5581 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5582 | |
| 5583 | VkDescriptorSetObj descriptorSet(m_device); |
| 5584 | descriptorSet.AppendDummy(); |
| 5585 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5586 | |
| 5587 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5588 | |
| 5589 | /* expect success */ |
| 5590 | if (m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5591 | FAIL() << "Expected to succeed but: " |
| 5592 | << m_errorMonitor->GetFailureMsg(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5593 | m_errorMonitor->DumpFailureMsgs(); |
| 5594 | } |
| 5595 | } |
| 5596 | |
| 5597 | /* |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5598 | * Would work, but not supported by glslang! This is similar to the matrix case |
| 5599 | above. |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5600 | * |
| 5601 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 5602 | { |
| 5603 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 5604 | |
| 5605 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5606 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5607 | |
| 5608 | VkVertexInputBindingDescription input_binding; |
| 5609 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5610 | |
| 5611 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5612 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5613 | |
| 5614 | for (int i = 0; i < 2; i++) { |
| 5615 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5616 | input_attribs[i].location = i; |
| 5617 | } |
| 5618 | |
| 5619 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5620 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5621 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5622 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5623 | "\n" |
| 5624 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5625 | "out gl_PerVertex {\n" |
| 5626 | " vec4 gl_Position;\n" |
| 5627 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5628 | "void main(){\n" |
| 5629 | " gl_Position = x[0] + x[1];\n" |
| 5630 | "}\n"; |
| 5631 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5632 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5633 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5634 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5635 | "\n" |
| 5636 | "layout(location=0) out vec4 color;\n" |
| 5637 | "void main(){\n" |
| 5638 | " color = vec4(1);\n" |
| 5639 | "}\n"; |
| 5640 | |
| 5641 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5642 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5643 | |
| 5644 | VkPipelineObj pipe(m_device); |
| 5645 | pipe.AddColorAttachment(); |
| 5646 | pipe.AddShader(&vs); |
| 5647 | pipe.AddShader(&fs); |
| 5648 | |
| 5649 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5650 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5651 | |
| 5652 | VkDescriptorSetObj descriptorSet(m_device); |
| 5653 | descriptorSet.AppendDummy(); |
| 5654 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5655 | |
| 5656 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5657 | |
| 5658 | if (m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5659 | FAIL() << "Expected to succeed but: " << |
| 5660 | m_errorMonitor->GetFailureMsg(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5661 | m_errorMonitor->DumpFailureMsgs(); |
| 5662 | } |
| 5663 | } |
| 5664 | */ |
| 5665 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5666 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 5667 | m_errorMonitor->SetDesiredFailureMsg( |
| 5668 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5669 | "Duplicate vertex input binding descriptions for binding 0"); |
| 5670 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5671 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5672 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5673 | |
| 5674 | /* Two binding descriptions for binding 0 */ |
| 5675 | VkVertexInputBindingDescription input_bindings[2]; |
| 5676 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 5677 | |
| 5678 | VkVertexInputAttributeDescription input_attrib; |
| 5679 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5680 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5681 | |
| 5682 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5683 | "#version 400\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5684 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5685 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5686 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5687 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5688 | "out gl_PerVertex {\n" |
| 5689 | " vec4 gl_Position;\n" |
| 5690 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5691 | "void main(){\n" |
| 5692 | " gl_Position = vec4(x);\n" |
| 5693 | "}\n"; |
| 5694 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5695 | "#version 400\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5696 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5697 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5698 | "\n" |
| 5699 | "layout(location=0) out vec4 color;\n" |
| 5700 | "void main(){\n" |
| 5701 | " color = vec4(1);\n" |
| 5702 | "}\n"; |
| 5703 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5704 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5705 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5706 | |
| 5707 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5708 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5709 | pipe.AddShader(&vs); |
| 5710 | pipe.AddShader(&fs); |
| 5711 | |
| 5712 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 5713 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5714 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5715 | VkDescriptorSetObj descriptorSet(m_device); |
| 5716 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5717 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5718 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5719 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5720 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5721 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5722 | FAIL() << "Did not receive Error 'Duplicate vertex input binding " |
| 5723 | "descriptions for binding 0'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5724 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5725 | } |
| 5726 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 5727 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5728 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5729 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5730 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5731 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5732 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5733 | |
| 5734 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5735 | "#version 400\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5736 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5737 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5738 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5739 | "out gl_PerVertex {\n" |
| 5740 | " vec4 gl_Position;\n" |
| 5741 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5742 | "void main(){\n" |
| 5743 | " gl_Position = vec4(1);\n" |
| 5744 | "}\n"; |
| 5745 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5746 | "#version 400\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5747 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5748 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5749 | "\n" |
| 5750 | "void main(){\n" |
| 5751 | "}\n"; |
| 5752 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5753 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5754 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5755 | |
| 5756 | VkPipelineObj pipe(m_device); |
| 5757 | pipe.AddShader(&vs); |
| 5758 | pipe.AddShader(&fs); |
| 5759 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5760 | /* set up CB 0, not written */ |
| 5761 | pipe.AddColorAttachment(); |
| 5762 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5763 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5764 | VkDescriptorSetObj descriptorSet(m_device); |
| 5765 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5766 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5767 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5768 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5769 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5770 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5771 | FAIL() << "Did not receive Error 'Attachment 0 not written by FS'"; |
| 5772 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5773 | } |
| 5774 | } |
| 5775 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5776 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5777 | // TODO: verify that this matches layer |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5778 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5779 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5780 | "FS writes to output location 1 with no matching attachment"); |
| 5781 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5782 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5783 | |
| 5784 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5785 | "#version 400\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5786 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5787 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5788 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5789 | "out gl_PerVertex {\n" |
| 5790 | " vec4 gl_Position;\n" |
| 5791 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5792 | "void main(){\n" |
| 5793 | " gl_Position = vec4(1);\n" |
| 5794 | "}\n"; |
| 5795 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5796 | "#version 400\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5797 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5798 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5799 | "\n" |
| 5800 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5801 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5802 | "void main(){\n" |
| 5803 | " x = vec4(1);\n" |
| 5804 | " y = vec4(1);\n" |
| 5805 | "}\n"; |
| 5806 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5807 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5808 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5809 | |
| 5810 | VkPipelineObj pipe(m_device); |
| 5811 | pipe.AddShader(&vs); |
| 5812 | pipe.AddShader(&fs); |
| 5813 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5814 | /* set up CB 0, not written */ |
| 5815 | pipe.AddColorAttachment(); |
| 5816 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5817 | /* FS writes CB 1, but we don't configure it */ |
| 5818 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5819 | VkDescriptorSetObj descriptorSet(m_device); |
| 5820 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5821 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5822 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5823 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5824 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5825 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5826 | FAIL() << "Did not receive Error 'FS writes to output location 1 with " |
| 5827 | "no matching attachment'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5828 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5829 | } |
| 5830 | } |
| 5831 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5832 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5833 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5834 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5835 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5836 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5837 | |
| 5838 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5839 | "#version 400\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5840 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5841 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5842 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5843 | "out gl_PerVertex {\n" |
| 5844 | " vec4 gl_Position;\n" |
| 5845 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5846 | "void main(){\n" |
| 5847 | " gl_Position = vec4(1);\n" |
| 5848 | "}\n"; |
| 5849 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5850 | "#version 400\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5851 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5852 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5853 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5854 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5855 | "void main(){\n" |
| 5856 | " x = ivec4(1);\n" |
| 5857 | "}\n"; |
| 5858 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5859 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5860 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5861 | |
| 5862 | VkPipelineObj pipe(m_device); |
| 5863 | pipe.AddShader(&vs); |
| 5864 | pipe.AddShader(&fs); |
| 5865 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5866 | /* set up CB 0; type is UNORM by default */ |
| 5867 | pipe.AddColorAttachment(); |
| 5868 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5869 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5870 | VkDescriptorSetObj descriptorSet(m_device); |
| 5871 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5872 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5873 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5874 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5875 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5876 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5877 | FAIL() << "Did not receive Error 'does not match FS output type'"; |
| 5878 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5879 | } |
| 5880 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 5881 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5882 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5883 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5884 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5885 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5886 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5887 | |
| 5888 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5889 | "#version 400\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5890 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5891 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5892 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5893 | "out gl_PerVertex {\n" |
| 5894 | " vec4 gl_Position;\n" |
| 5895 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5896 | "void main(){\n" |
| 5897 | " gl_Position = vec4(1);\n" |
| 5898 | "}\n"; |
| 5899 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5900 | "#version 400\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5901 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5902 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5903 | "\n" |
| 5904 | "layout(location=0) out vec4 x;\n" |
| 5905 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5906 | "void main(){\n" |
| 5907 | " x = vec4(bar.y);\n" |
| 5908 | "}\n"; |
| 5909 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5910 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5911 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5912 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5913 | VkPipelineObj pipe(m_device); |
| 5914 | pipe.AddShader(&vs); |
| 5915 | pipe.AddShader(&fs); |
| 5916 | |
| 5917 | /* set up CB 0; type is UNORM by default */ |
| 5918 | pipe.AddColorAttachment(); |
| 5919 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5920 | |
| 5921 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5922 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5923 | |
| 5924 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5925 | |
| 5926 | /* should have generated an error -- pipeline layout does not |
| 5927 | * provide a uniform buffer in 0.0 |
| 5928 | */ |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5929 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5930 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 5931 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5932 | } |
| 5933 | } |
| 5934 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5935 | #endif // SHADER_CHECKER_TESTS |
| 5936 | |
| 5937 | #if DEVICE_LIMITS_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5938 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) { |
| 5939 | m_errorMonitor->SetDesiredFailureMsg( |
| 5940 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5941 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5942 | |
| 5943 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5944 | |
| 5945 | // Create an image |
| 5946 | VkImage image; |
| 5947 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5948 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5949 | const int32_t tex_width = 32; |
| 5950 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5951 | |
| 5952 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5953 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5954 | image_create_info.pNext = NULL; |
| 5955 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5956 | image_create_info.format = tex_format; |
| 5957 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5958 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5959 | image_create_info.extent.depth = 1; |
| 5960 | image_create_info.mipLevels = 1; |
| 5961 | image_create_info.arrayLayers = 1; |
| 5962 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5963 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5964 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5965 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5966 | |
| 5967 | // Introduce error by sending down a bogus width extent |
| 5968 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5969 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5970 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5971 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5972 | FAIL() << "Did not receive Error 'CreateImage extents exceed allowable " |
| 5973 | "limits for format'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5974 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5975 | } |
| 5976 | } |
| 5977 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5978 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 5979 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5980 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5981 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5982 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5983 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5984 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5985 | |
| 5986 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5987 | vk_testing::Buffer buffer; |
| 5988 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 5989 | |
| 5990 | BeginCommandBuffer(); |
| 5991 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5992 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5993 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5994 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, " |
| 5995 | "VkDeviceSize dstOffset, is not a multiple of 4'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5996 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5997 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5998 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5999 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6000 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6001 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6002 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6003 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6004 | |
| 6005 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6006 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, " |
| 6007 | "VkDeviceSize dataSize, is not a multiple of 4'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6008 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6009 | } |
| 6010 | EndCommandBuffer(); |
| 6011 | } |
| 6012 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6013 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6014 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6015 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6016 | |
| 6017 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6018 | |
| 6019 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6020 | vk_testing::Buffer buffer; |
| 6021 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 6022 | |
| 6023 | BeginCommandBuffer(); |
| 6024 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6025 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6026 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6027 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, " |
| 6028 | "VkDeviceSize dstOffset, is not a multiple of 4'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6029 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6030 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6031 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6032 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6033 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6034 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6035 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6036 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6037 | |
| 6038 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6039 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, " |
| 6040 | "VkDeviceSize size, is not a multiple of 4'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6041 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6042 | } |
| 6043 | EndCommandBuffer(); |
| 6044 | } |
| 6045 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6046 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6047 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6048 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6049 | TEST_F(VkLayerTest, InvalidImageView) { |
| 6050 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6051 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6052 | m_errorMonitor->SetDesiredFailureMsg( |
| 6053 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6054 | "vkCreateImageView called with baseMipLevel 10 "); |
| 6055 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6056 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6057 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6058 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6059 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6060 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6061 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6062 | const int32_t tex_width = 32; |
| 6063 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6064 | |
| 6065 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6066 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6067 | image_create_info.pNext = NULL; |
| 6068 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6069 | image_create_info.format = tex_format; |
| 6070 | image_create_info.extent.width = tex_width; |
| 6071 | image_create_info.extent.height = tex_height; |
| 6072 | image_create_info.extent.depth = 1; |
| 6073 | image_create_info.mipLevels = 1; |
| 6074 | image_create_info.arrayLayers = 1; |
| 6075 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6076 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6077 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6078 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6079 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6080 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6081 | ASSERT_VK_SUCCESS(err); |
| 6082 | |
| 6083 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6084 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6085 | image_view_create_info.image = image; |
| 6086 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6087 | image_view_create_info.format = tex_format; |
| 6088 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6089 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 6090 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6091 | image_view_create_info.subresourceRange.aspectMask = |
| 6092 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6093 | |
| 6094 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6095 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6096 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6097 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6098 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6099 | FAIL() << "Did not receive Error 'vkCreateImageView called with " |
| 6100 | "baseMipLevel 10...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6101 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6102 | } |
| 6103 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6104 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6105 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 6106 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6107 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6108 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6109 | "vkCreateImageView: Color image " |
| 6110 | "formats must have ONLY the " |
| 6111 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6112 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6113 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6114 | |
| 6115 | // 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] | 6116 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6117 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6118 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6119 | const int32_t tex_width = 32; |
| 6120 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6121 | |
| 6122 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6123 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6124 | image_create_info.pNext = NULL; |
| 6125 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6126 | image_create_info.format = tex_format; |
| 6127 | image_create_info.extent.width = tex_width; |
| 6128 | image_create_info.extent.height = tex_height; |
| 6129 | image_create_info.extent.depth = 1; |
| 6130 | image_create_info.mipLevels = 1; |
| 6131 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6132 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6133 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6134 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6135 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6136 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6137 | ASSERT_VK_SUCCESS(err); |
| 6138 | |
| 6139 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6140 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6141 | image_view_create_info.image = image; |
| 6142 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6143 | image_view_create_info.format = tex_format; |
| 6144 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 6145 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6146 | // Cause an error by setting an invalid image aspect |
| 6147 | image_view_create_info.subresourceRange.aspectMask = |
| 6148 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6149 | |
| 6150 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6151 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6152 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6153 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6154 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6155 | FAIL() << "Did not receive Error 'VkCreateImageView: Color image " |
| 6156 | "formats must have ...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6157 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6158 | } |
| 6159 | } |
| 6160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6161 | TEST_F(VkLayerTest, CopyImageTypeMismatch) { |
| 6162 | VkResult err; |
| 6163 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6165 | m_errorMonitor->SetDesiredFailureMsg( |
| 6166 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6167 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 6168 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6169 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6170 | |
| 6171 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6172 | VkImage srcImage; |
| 6173 | VkImage dstImage; |
| 6174 | VkDeviceMemory srcMem; |
| 6175 | VkDeviceMemory destMem; |
| 6176 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6177 | |
| 6178 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6179 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6180 | image_create_info.pNext = NULL; |
| 6181 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6182 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6183 | image_create_info.extent.width = 32; |
| 6184 | image_create_info.extent.height = 32; |
| 6185 | image_create_info.extent.depth = 1; |
| 6186 | image_create_info.mipLevels = 1; |
| 6187 | image_create_info.arrayLayers = 1; |
| 6188 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6189 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6190 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6191 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6192 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6193 | err = |
| 6194 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6195 | ASSERT_VK_SUCCESS(err); |
| 6196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6197 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6198 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6199 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6200 | err = |
| 6201 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6202 | ASSERT_VK_SUCCESS(err); |
| 6203 | |
| 6204 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6205 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6206 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6207 | memAlloc.pNext = NULL; |
| 6208 | memAlloc.allocationSize = 0; |
| 6209 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6210 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6211 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6212 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6213 | pass = |
| 6214 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6215 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6216 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6217 | ASSERT_VK_SUCCESS(err); |
| 6218 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6219 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6220 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6221 | pass = |
| 6222 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6223 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6224 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6225 | ASSERT_VK_SUCCESS(err); |
| 6226 | |
| 6227 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6228 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6229 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6230 | ASSERT_VK_SUCCESS(err); |
| 6231 | |
| 6232 | BeginCommandBuffer(); |
| 6233 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6234 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6235 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6236 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6237 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6238 | copyRegion.srcOffset.x = 0; |
| 6239 | copyRegion.srcOffset.y = 0; |
| 6240 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6241 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6242 | copyRegion.dstSubresource.mipLevel = 0; |
| 6243 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6244 | copyRegion.dstSubresource.layerCount = 0; |
| 6245 | copyRegion.dstOffset.x = 0; |
| 6246 | copyRegion.dstOffset.y = 0; |
| 6247 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6248 | copyRegion.extent.width = 1; |
| 6249 | copyRegion.extent.height = 1; |
| 6250 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6251 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6252 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6253 | EndCommandBuffer(); |
| 6254 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6255 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6256 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched " |
| 6257 | "source and dest image types'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6258 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6259 | } |
| 6260 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6261 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6262 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6263 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6264 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6265 | } |
| 6266 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6267 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
| 6268 | // TODO : Create two images with different format sizes and vkCmdCopyImage |
| 6269 | // between them |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6270 | } |
| 6271 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6272 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 6273 | VkResult err; |
| 6274 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6275 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6276 | m_errorMonitor->SetDesiredFailureMsg( |
| 6277 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6278 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 6279 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6280 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6281 | |
| 6282 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6283 | VkImage srcImage; |
| 6284 | VkImage dstImage; |
| 6285 | VkDeviceMemory srcMem; |
| 6286 | VkDeviceMemory destMem; |
| 6287 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6288 | |
| 6289 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6290 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6291 | image_create_info.pNext = NULL; |
| 6292 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6293 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6294 | image_create_info.extent.width = 32; |
| 6295 | image_create_info.extent.height = 32; |
| 6296 | image_create_info.extent.depth = 1; |
| 6297 | image_create_info.mipLevels = 1; |
| 6298 | image_create_info.arrayLayers = 1; |
| 6299 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6300 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6301 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6302 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6303 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6304 | err = |
| 6305 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6306 | ASSERT_VK_SUCCESS(err); |
| 6307 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6308 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6309 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6310 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6311 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6312 | err = |
| 6313 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6314 | ASSERT_VK_SUCCESS(err); |
| 6315 | |
| 6316 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6317 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6318 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6319 | memAlloc.pNext = NULL; |
| 6320 | memAlloc.allocationSize = 0; |
| 6321 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6322 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6323 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6324 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6325 | pass = |
| 6326 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6327 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6328 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6329 | ASSERT_VK_SUCCESS(err); |
| 6330 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6331 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6332 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6333 | pass = |
| 6334 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6335 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6336 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6337 | ASSERT_VK_SUCCESS(err); |
| 6338 | |
| 6339 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6340 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6341 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6342 | ASSERT_VK_SUCCESS(err); |
| 6343 | |
| 6344 | BeginCommandBuffer(); |
| 6345 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6346 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6347 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6348 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6349 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6350 | copyRegion.srcOffset.x = 0; |
| 6351 | copyRegion.srcOffset.y = 0; |
| 6352 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6353 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6354 | copyRegion.dstSubresource.mipLevel = 0; |
| 6355 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6356 | copyRegion.dstSubresource.layerCount = 0; |
| 6357 | copyRegion.dstOffset.x = 0; |
| 6358 | copyRegion.dstOffset.y = 0; |
| 6359 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6360 | copyRegion.extent.width = 1; |
| 6361 | copyRegion.extent.height = 1; |
| 6362 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6363 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6364 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6365 | EndCommandBuffer(); |
| 6366 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6367 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6368 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched " |
| 6369 | "source and dest image types'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6370 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6371 | } |
| 6372 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6373 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6374 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6375 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6376 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6377 | } |
| 6378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6379 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 6380 | VkResult err; |
| 6381 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6382 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6383 | m_errorMonitor->SetDesiredFailureMsg( |
| 6384 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6385 | "vkCmdResolveImage called with source sample count less than 2."); |
| 6386 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6387 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6388 | |
| 6389 | // 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] | 6390 | VkImage srcImage; |
| 6391 | VkImage dstImage; |
| 6392 | VkDeviceMemory srcMem; |
| 6393 | VkDeviceMemory destMem; |
| 6394 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6395 | |
| 6396 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6397 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6398 | image_create_info.pNext = NULL; |
| 6399 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6400 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6401 | image_create_info.extent.width = 32; |
| 6402 | image_create_info.extent.height = 1; |
| 6403 | image_create_info.extent.depth = 1; |
| 6404 | image_create_info.mipLevels = 1; |
| 6405 | image_create_info.arrayLayers = 1; |
| 6406 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6407 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6408 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6409 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6410 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6411 | err = |
| 6412 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6413 | ASSERT_VK_SUCCESS(err); |
| 6414 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6415 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6416 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6417 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6418 | err = |
| 6419 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6420 | ASSERT_VK_SUCCESS(err); |
| 6421 | |
| 6422 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6423 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6424 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6425 | memAlloc.pNext = NULL; |
| 6426 | memAlloc.allocationSize = 0; |
| 6427 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6428 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6429 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6430 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6431 | pass = |
| 6432 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6433 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6434 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6435 | ASSERT_VK_SUCCESS(err); |
| 6436 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6437 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6438 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6439 | pass = |
| 6440 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6441 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6442 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6443 | ASSERT_VK_SUCCESS(err); |
| 6444 | |
| 6445 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6446 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6447 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6448 | ASSERT_VK_SUCCESS(err); |
| 6449 | |
| 6450 | BeginCommandBuffer(); |
| 6451 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6452 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6453 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6454 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6455 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6456 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6457 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6458 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6459 | resolveRegion.srcOffset.x = 0; |
| 6460 | resolveRegion.srcOffset.y = 0; |
| 6461 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6462 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6463 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6464 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6465 | resolveRegion.dstSubresource.layerCount = 0; |
| 6466 | resolveRegion.dstOffset.x = 0; |
| 6467 | resolveRegion.dstOffset.y = 0; |
| 6468 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6469 | resolveRegion.extent.width = 1; |
| 6470 | resolveRegion.extent.height = 1; |
| 6471 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6472 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6473 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6474 | EndCommandBuffer(); |
| 6475 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6476 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6477 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with source " |
| 6478 | "sample count less than 2.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6479 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6480 | } |
| 6481 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6482 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6483 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6484 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6485 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6486 | } |
| 6487 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6488 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 6489 | VkResult err; |
| 6490 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6491 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6492 | m_errorMonitor->SetDesiredFailureMsg( |
| 6493 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6494 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 6495 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6496 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6497 | |
| 6498 | // 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] | 6499 | VkImage srcImage; |
| 6500 | VkImage dstImage; |
| 6501 | VkDeviceMemory srcMem; |
| 6502 | VkDeviceMemory destMem; |
| 6503 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6504 | |
| 6505 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6506 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6507 | image_create_info.pNext = NULL; |
| 6508 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6509 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6510 | image_create_info.extent.width = 32; |
| 6511 | image_create_info.extent.height = 1; |
| 6512 | image_create_info.extent.depth = 1; |
| 6513 | image_create_info.mipLevels = 1; |
| 6514 | image_create_info.arrayLayers = 1; |
| 6515 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6516 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6517 | // Note: Some implementations expect color attachment usage for any |
| 6518 | // multisample surface |
| 6519 | image_create_info.usage = |
| 6520 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6521 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6522 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6523 | err = |
| 6524 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6525 | ASSERT_VK_SUCCESS(err); |
| 6526 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6527 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6528 | // Note: Some implementations expect color attachment usage for any |
| 6529 | // multisample surface |
| 6530 | image_create_info.usage = |
| 6531 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6532 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6533 | err = |
| 6534 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6535 | ASSERT_VK_SUCCESS(err); |
| 6536 | |
| 6537 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6538 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6539 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6540 | memAlloc.pNext = NULL; |
| 6541 | memAlloc.allocationSize = 0; |
| 6542 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6543 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6544 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6545 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6546 | pass = |
| 6547 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6548 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6549 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6550 | ASSERT_VK_SUCCESS(err); |
| 6551 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6552 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6553 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6554 | pass = |
| 6555 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6556 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6557 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6558 | ASSERT_VK_SUCCESS(err); |
| 6559 | |
| 6560 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6561 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6562 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6563 | ASSERT_VK_SUCCESS(err); |
| 6564 | |
| 6565 | BeginCommandBuffer(); |
| 6566 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6567 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6568 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6569 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6570 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6571 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6572 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6573 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6574 | resolveRegion.srcOffset.x = 0; |
| 6575 | resolveRegion.srcOffset.y = 0; |
| 6576 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6577 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6578 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6579 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6580 | resolveRegion.dstSubresource.layerCount = 0; |
| 6581 | resolveRegion.dstOffset.x = 0; |
| 6582 | resolveRegion.dstOffset.y = 0; |
| 6583 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6584 | resolveRegion.extent.width = 1; |
| 6585 | resolveRegion.extent.height = 1; |
| 6586 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6587 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6588 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6589 | EndCommandBuffer(); |
| 6590 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6591 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6592 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with dest " |
| 6593 | "sample count greater than 1.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6594 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6595 | } |
| 6596 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6597 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6598 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6599 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6600 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6601 | } |
| 6602 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6603 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 6604 | VkResult err; |
| 6605 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6606 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6607 | m_errorMonitor->SetDesiredFailureMsg( |
| 6608 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6609 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 6610 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6611 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6612 | |
| 6613 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6614 | VkImage srcImage; |
| 6615 | VkImage dstImage; |
| 6616 | VkDeviceMemory srcMem; |
| 6617 | VkDeviceMemory destMem; |
| 6618 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6619 | |
| 6620 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6621 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6622 | image_create_info.pNext = NULL; |
| 6623 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6624 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6625 | image_create_info.extent.width = 32; |
| 6626 | image_create_info.extent.height = 1; |
| 6627 | image_create_info.extent.depth = 1; |
| 6628 | image_create_info.mipLevels = 1; |
| 6629 | image_create_info.arrayLayers = 1; |
| 6630 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6631 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6632 | // Note: Some implementations expect color attachment usage for any |
| 6633 | // multisample surface |
| 6634 | image_create_info.usage = |
| 6635 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6636 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6637 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6638 | err = |
| 6639 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6640 | ASSERT_VK_SUCCESS(err); |
| 6641 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6642 | // Set format to something other than source image |
| 6643 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 6644 | // Note: Some implementations expect color attachment usage for any |
| 6645 | // multisample surface |
| 6646 | image_create_info.usage = |
| 6647 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6648 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6649 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6650 | err = |
| 6651 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6652 | ASSERT_VK_SUCCESS(err); |
| 6653 | |
| 6654 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6655 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6656 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6657 | memAlloc.pNext = NULL; |
| 6658 | memAlloc.allocationSize = 0; |
| 6659 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6660 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6661 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6662 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6663 | pass = |
| 6664 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6665 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6666 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6667 | ASSERT_VK_SUCCESS(err); |
| 6668 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6669 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6670 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6671 | pass = |
| 6672 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6673 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6674 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6675 | ASSERT_VK_SUCCESS(err); |
| 6676 | |
| 6677 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6678 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6679 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6680 | ASSERT_VK_SUCCESS(err); |
| 6681 | |
| 6682 | BeginCommandBuffer(); |
| 6683 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6684 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6685 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6686 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6687 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6688 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6689 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6690 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6691 | resolveRegion.srcOffset.x = 0; |
| 6692 | resolveRegion.srcOffset.y = 0; |
| 6693 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6694 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6695 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6696 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6697 | resolveRegion.dstSubresource.layerCount = 0; |
| 6698 | resolveRegion.dstOffset.x = 0; |
| 6699 | resolveRegion.dstOffset.y = 0; |
| 6700 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6701 | resolveRegion.extent.width = 1; |
| 6702 | resolveRegion.extent.height = 1; |
| 6703 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6704 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6705 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6706 | EndCommandBuffer(); |
| 6707 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6708 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6709 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with " |
| 6710 | "unmatched source and dest formats.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6711 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6712 | } |
| 6713 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6714 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6715 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6716 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6717 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6718 | } |
| 6719 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6720 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 6721 | VkResult err; |
| 6722 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6723 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6724 | m_errorMonitor->SetDesiredFailureMsg( |
| 6725 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6726 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 6727 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6728 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6729 | |
| 6730 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6731 | VkImage srcImage; |
| 6732 | VkImage dstImage; |
| 6733 | VkDeviceMemory srcMem; |
| 6734 | VkDeviceMemory destMem; |
| 6735 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6736 | |
| 6737 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6738 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6739 | image_create_info.pNext = NULL; |
| 6740 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6741 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6742 | image_create_info.extent.width = 32; |
| 6743 | image_create_info.extent.height = 1; |
| 6744 | image_create_info.extent.depth = 1; |
| 6745 | image_create_info.mipLevels = 1; |
| 6746 | image_create_info.arrayLayers = 1; |
| 6747 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6748 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6749 | // Note: Some implementations expect color attachment usage for any |
| 6750 | // multisample surface |
| 6751 | image_create_info.usage = |
| 6752 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6753 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6754 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6755 | err = |
| 6756 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6757 | ASSERT_VK_SUCCESS(err); |
| 6758 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6759 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6760 | // Note: Some implementations expect color attachment usage for any |
| 6761 | // multisample surface |
| 6762 | image_create_info.usage = |
| 6763 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6764 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6765 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6766 | err = |
| 6767 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6768 | ASSERT_VK_SUCCESS(err); |
| 6769 | |
| 6770 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6771 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6772 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6773 | memAlloc.pNext = NULL; |
| 6774 | memAlloc.allocationSize = 0; |
| 6775 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6776 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6777 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6778 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6779 | pass = |
| 6780 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6781 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6782 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6783 | ASSERT_VK_SUCCESS(err); |
| 6784 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6785 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6786 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6787 | pass = |
| 6788 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6789 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6790 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6791 | ASSERT_VK_SUCCESS(err); |
| 6792 | |
| 6793 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6794 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6795 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6796 | ASSERT_VK_SUCCESS(err); |
| 6797 | |
| 6798 | BeginCommandBuffer(); |
| 6799 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6800 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6801 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6802 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6803 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6804 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6805 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6806 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6807 | resolveRegion.srcOffset.x = 0; |
| 6808 | resolveRegion.srcOffset.y = 0; |
| 6809 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6810 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6811 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6812 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6813 | resolveRegion.dstSubresource.layerCount = 0; |
| 6814 | resolveRegion.dstOffset.x = 0; |
| 6815 | resolveRegion.dstOffset.y = 0; |
| 6816 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6817 | resolveRegion.extent.width = 1; |
| 6818 | resolveRegion.extent.height = 1; |
| 6819 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6820 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6821 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6822 | EndCommandBuffer(); |
| 6823 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6824 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6825 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with " |
| 6826 | "unmatched source and dest image types.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6827 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6828 | } |
| 6829 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6830 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6831 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6832 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6833 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6834 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6835 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6836 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6837 | // 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] | 6838 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 6839 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6840 | // The image format check comes 2nd in validation so we trigger it first, |
| 6841 | // 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] | 6842 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6843 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6844 | m_errorMonitor->SetDesiredFailureMsg( |
| 6845 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6846 | "Combination depth/stencil image formats can have only the "); |
| 6847 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6848 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6849 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6850 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6851 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 6852 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6853 | |
| 6854 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6855 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6856 | ds_pool_ci.pNext = NULL; |
| 6857 | ds_pool_ci.maxSets = 1; |
| 6858 | ds_pool_ci.poolSizeCount = 1; |
| 6859 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6860 | |
| 6861 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6862 | err = |
| 6863 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6864 | ASSERT_VK_SUCCESS(err); |
| 6865 | |
| 6866 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6867 | dsl_binding.binding = 0; |
| 6868 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 6869 | dsl_binding.descriptorCount = 1; |
| 6870 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6871 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6872 | |
| 6873 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6874 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6875 | ds_layout_ci.pNext = NULL; |
| 6876 | ds_layout_ci.bindingCount = 1; |
| 6877 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6878 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6879 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6880 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6881 | ASSERT_VK_SUCCESS(err); |
| 6882 | |
| 6883 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6884 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6885 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6886 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6887 | alloc_info.descriptorPool = ds_pool; |
| 6888 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6889 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6890 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6891 | ASSERT_VK_SUCCESS(err); |
| 6892 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6893 | VkImage image_bad; |
| 6894 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6895 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6896 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6897 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6898 | const int32_t tex_width = 32; |
| 6899 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6900 | |
| 6901 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6902 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6903 | image_create_info.pNext = NULL; |
| 6904 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6905 | image_create_info.format = tex_format_bad; |
| 6906 | image_create_info.extent.width = tex_width; |
| 6907 | image_create_info.extent.height = tex_height; |
| 6908 | image_create_info.extent.depth = 1; |
| 6909 | image_create_info.mipLevels = 1; |
| 6910 | image_create_info.arrayLayers = 1; |
| 6911 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6912 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6913 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 6914 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 6915 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6916 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6917 | err = |
| 6918 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6919 | ASSERT_VK_SUCCESS(err); |
| 6920 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6921 | image_create_info.usage = |
| 6922 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6923 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 6924 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6925 | ASSERT_VK_SUCCESS(err); |
| 6926 | |
| 6927 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6928 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6929 | image_view_create_info.image = image_bad; |
| 6930 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6931 | image_view_create_info.format = tex_format_bad; |
| 6932 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 6933 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 6934 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6935 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6936 | image_view_create_info.subresourceRange.aspectMask = |
| 6937 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6938 | |
| 6939 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6940 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6941 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6942 | |
| 6943 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6944 | FAIL() << "Did not receive Error 'Combination depth-stencil image " |
| 6945 | "formats can have only the....'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6946 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6947 | } |
| 6948 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6949 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 6950 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6951 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6952 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6953 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6954 | #endif // IMAGE_TESTS |
| 6955 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 6956 | int main(int argc, char **argv) { |
| 6957 | int result; |
| 6958 | |
| 6959 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 6960 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 6961 | |
| 6962 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 6963 | |
| 6964 | result = RUN_ALL_TESTS(); |
| 6965 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 6966 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 6967 | return result; |
| 6968 | } |