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; |
Tony Barbour | aabb359 | 2016-02-25 13:58:50 -0700 | [diff] [blame] | 287 | this->app_info.apiVersion = VK_MAKE_VERSION(1, 0, 0); |
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 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3723 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 3724 | // Create an out-of-range queueFamilyIndex |
| 3725 | m_errorMonitor->SetDesiredFailureMsg( |
| 3726 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3727 | "vkCreateBuffer has QueueFamilyIndex greater than"); |
| 3728 | |
| 3729 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3730 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3731 | VkBufferCreateInfo buffCI = {}; |
| 3732 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3733 | buffCI.size = 1024; |
| 3734 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 3735 | buffCI.queueFamilyIndexCount = 1; |
| 3736 | // Introduce failure by specifying invalid queue_family_index |
| 3737 | uint32_t qfi = 777; |
| 3738 | buffCI.pQueueFamilyIndices = &qfi; |
| 3739 | |
| 3740 | VkBuffer ib; |
| 3741 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 3742 | |
| 3743 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3744 | FAIL() << "Did not receive Error 'vkCreateBuffer() has " |
| 3745 | "QueueFamilyIndex greater than...'"; |
| 3746 | m_errorMonitor->DumpFailureMsgs(); |
| 3747 | } |
| 3748 | } |
| 3749 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3750 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 3751 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 3752 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3753 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3754 | m_errorMonitor->SetDesiredFailureMsg( |
| 3755 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3756 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3757 | |
| 3758 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3759 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3760 | |
| 3761 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3762 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3763 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 3764 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3765 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3766 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3767 | FAIL() << "Did not receive Error 'vkCmdExecuteCommands() called w/ " |
| 3768 | "Primary Cmd Buffer '"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3769 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3770 | } |
| 3771 | } |
| 3772 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3773 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3774 | // 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] | 3775 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3776 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3777 | m_errorMonitor->SetDesiredFailureMsg( |
| 3778 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Write descriptor update has descriptor " |
| 3779 | "type VK_DESCRIPTOR_TYPE_SAMPLER that " |
| 3780 | "does not match "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3781 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3782 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3783 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3784 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3785 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3786 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3787 | |
| 3788 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3789 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3790 | ds_pool_ci.pNext = NULL; |
| 3791 | ds_pool_ci.maxSets = 1; |
| 3792 | ds_pool_ci.poolSizeCount = 1; |
| 3793 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3794 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3795 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3796 | err = |
| 3797 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3798 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3799 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3800 | dsl_binding.binding = 0; |
| 3801 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3802 | dsl_binding.descriptorCount = 1; |
| 3803 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3804 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3805 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3806 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3807 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3808 | ds_layout_ci.pNext = NULL; |
| 3809 | ds_layout_ci.bindingCount = 1; |
| 3810 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3811 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3812 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3813 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3814 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3815 | ASSERT_VK_SUCCESS(err); |
| 3816 | |
| 3817 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3818 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3819 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3820 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3821 | alloc_info.descriptorPool = ds_pool; |
| 3822 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3823 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3824 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3825 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3826 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3827 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3828 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3829 | sampler_ci.pNext = NULL; |
| 3830 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3831 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3832 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3833 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3834 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3835 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3836 | sampler_ci.mipLodBias = 1.0; |
| 3837 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3838 | sampler_ci.maxAnisotropy = 1; |
| 3839 | sampler_ci.compareEnable = VK_FALSE; |
| 3840 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3841 | sampler_ci.minLod = 1.0; |
| 3842 | sampler_ci.maxLod = 1.0; |
| 3843 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3844 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3845 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3846 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3847 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3848 | ASSERT_VK_SUCCESS(err); |
| 3849 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3850 | VkDescriptorImageInfo info = {}; |
| 3851 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3852 | |
| 3853 | VkWriteDescriptorSet descriptor_write; |
| 3854 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3855 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3856 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3857 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3858 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3859 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3860 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3861 | |
| 3862 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3863 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3864 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3865 | FAIL() << "Did not receive Error 'Write descriptor update has " |
| 3866 | "descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not " |
| 3867 | "match...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3868 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3869 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3870 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3871 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3872 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3873 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3874 | } |
| 3875 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3876 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3877 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3878 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3879 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3880 | m_errorMonitor->SetDesiredFailureMsg( |
| 3881 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Descriptor update type of " |
| 3882 | "VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET " |
| 3883 | "is out of bounds for matching binding"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3884 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3885 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3886 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3887 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3888 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3889 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3890 | |
| 3891 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3892 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3893 | ds_pool_ci.pNext = NULL; |
| 3894 | ds_pool_ci.maxSets = 1; |
| 3895 | ds_pool_ci.poolSizeCount = 1; |
| 3896 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3897 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3898 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3899 | err = |
| 3900 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3901 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3902 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3903 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3904 | dsl_binding.binding = 0; |
| 3905 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3906 | dsl_binding.descriptorCount = 1; |
| 3907 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3908 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3909 | |
| 3910 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3911 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3912 | ds_layout_ci.pNext = NULL; |
| 3913 | ds_layout_ci.bindingCount = 1; |
| 3914 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3915 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3916 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3917 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3918 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3919 | ASSERT_VK_SUCCESS(err); |
| 3920 | |
| 3921 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3922 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3923 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3924 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3925 | alloc_info.descriptorPool = ds_pool; |
| 3926 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3927 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3928 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3929 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3930 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3931 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3932 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3933 | sampler_ci.pNext = NULL; |
| 3934 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3935 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3936 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3937 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3938 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3939 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3940 | sampler_ci.mipLodBias = 1.0; |
| 3941 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3942 | sampler_ci.maxAnisotropy = 1; |
| 3943 | sampler_ci.compareEnable = VK_FALSE; |
| 3944 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3945 | sampler_ci.minLod = 1.0; |
| 3946 | sampler_ci.maxLod = 1.0; |
| 3947 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3948 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3949 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3950 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3951 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3952 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3953 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3954 | VkDescriptorImageInfo info = {}; |
| 3955 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3956 | |
| 3957 | VkWriteDescriptorSet descriptor_write; |
| 3958 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3959 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3960 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3961 | descriptor_write.dstArrayElement = |
| 3962 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3963 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3964 | // 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] | 3965 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3966 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3967 | |
| 3968 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3969 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3970 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3971 | FAIL() << "Did not receive Error 'Descriptor update type of " |
| 3972 | "VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for " |
| 3973 | "matching binding...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3974 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3975 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3976 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3977 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3978 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3979 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3980 | } |
| 3981 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3982 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 3983 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 3984 | // index 2 |
| 3985 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3986 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3987 | m_errorMonitor->SetDesiredFailureMsg( |
| 3988 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3989 | " does not have binding to match update binding "); |
| 3990 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3991 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3992 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3993 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3994 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3995 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3996 | |
| 3997 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3998 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3999 | ds_pool_ci.pNext = NULL; |
| 4000 | ds_pool_ci.maxSets = 1; |
| 4001 | ds_pool_ci.poolSizeCount = 1; |
| 4002 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4003 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4004 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4005 | err = |
| 4006 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
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 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4010 | dsl_binding.binding = 0; |
| 4011 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4012 | dsl_binding.descriptorCount = 1; |
| 4013 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4014 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4015 | |
| 4016 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4017 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4018 | ds_layout_ci.pNext = NULL; |
| 4019 | ds_layout_ci.bindingCount = 1; |
| 4020 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4021 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4022 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4023 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4024 | ASSERT_VK_SUCCESS(err); |
| 4025 | |
| 4026 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4027 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4028 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4029 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4030 | alloc_info.descriptorPool = ds_pool; |
| 4031 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4032 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4033 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4034 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4035 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4036 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4037 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4038 | sampler_ci.pNext = NULL; |
| 4039 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4040 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4041 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4042 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4043 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4044 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4045 | sampler_ci.mipLodBias = 1.0; |
| 4046 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4047 | sampler_ci.maxAnisotropy = 1; |
| 4048 | sampler_ci.compareEnable = VK_FALSE; |
| 4049 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4050 | sampler_ci.minLod = 1.0; |
| 4051 | sampler_ci.maxLod = 1.0; |
| 4052 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4053 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4054 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4055 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4056 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4057 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4058 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4059 | VkDescriptorImageInfo info = {}; |
| 4060 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4061 | |
| 4062 | VkWriteDescriptorSet descriptor_write; |
| 4063 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4064 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4065 | descriptor_write.dstSet = descriptorSet; |
| 4066 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4067 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4068 | // 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] | 4069 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4070 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4071 | |
| 4072 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4073 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4074 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4075 | FAIL() << "Did not receive Error 'Descriptor Set <blah> does not have " |
| 4076 | "binding to match update binding '"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4077 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4078 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4079 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4080 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4081 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4082 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4083 | } |
| 4084 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4085 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 4086 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 4087 | // types |
| 4088 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4089 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4090 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4091 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4092 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4093 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4094 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4095 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4096 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4097 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4098 | |
| 4099 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4100 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4101 | ds_pool_ci.pNext = NULL; |
| 4102 | ds_pool_ci.maxSets = 1; |
| 4103 | ds_pool_ci.poolSizeCount = 1; |
| 4104 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4105 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4106 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4107 | err = |
| 4108 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4109 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4110 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4111 | dsl_binding.binding = 0; |
| 4112 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4113 | dsl_binding.descriptorCount = 1; |
| 4114 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4115 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4116 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4117 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4118 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4119 | ds_layout_ci.pNext = NULL; |
| 4120 | ds_layout_ci.bindingCount = 1; |
| 4121 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4122 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4123 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4124 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4125 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4126 | ASSERT_VK_SUCCESS(err); |
| 4127 | |
| 4128 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4129 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4130 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4131 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4132 | alloc_info.descriptorPool = ds_pool; |
| 4133 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4134 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4135 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4136 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4137 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4138 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4139 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4140 | sampler_ci.pNext = NULL; |
| 4141 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4142 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4143 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4144 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4145 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4146 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4147 | sampler_ci.mipLodBias = 1.0; |
| 4148 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4149 | sampler_ci.maxAnisotropy = 1; |
| 4150 | sampler_ci.compareEnable = VK_FALSE; |
| 4151 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4152 | sampler_ci.minLod = 1.0; |
| 4153 | sampler_ci.maxLod = 1.0; |
| 4154 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4155 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4156 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4157 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4158 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4159 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4160 | VkDescriptorImageInfo info = {}; |
| 4161 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4162 | |
| 4163 | VkWriteDescriptorSet descriptor_write; |
| 4164 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4165 | descriptor_write.sType = |
| 4166 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4167 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4168 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4169 | // 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] | 4170 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4171 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4172 | |
| 4173 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4174 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4175 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4176 | FAIL() << "Did not receive Error 'Unexpected UPDATE struct of type '"; |
| 4177 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4178 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4179 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4180 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4181 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4182 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4183 | } |
| 4184 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4185 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4186 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4187 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4188 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4189 | m_errorMonitor->SetDesiredFailureMsg( |
| 4190 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4191 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 4192 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4193 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4194 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 4195 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4196 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4197 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4198 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4199 | |
| 4200 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4201 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4202 | ds_pool_ci.pNext = NULL; |
| 4203 | ds_pool_ci.maxSets = 1; |
| 4204 | ds_pool_ci.poolSizeCount = 1; |
| 4205 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4206 | |
| 4207 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4208 | err = |
| 4209 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4210 | ASSERT_VK_SUCCESS(err); |
| 4211 | |
| 4212 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4213 | dsl_binding.binding = 0; |
| 4214 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4215 | dsl_binding.descriptorCount = 1; |
| 4216 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4217 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4218 | |
| 4219 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4220 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4221 | ds_layout_ci.pNext = NULL; |
| 4222 | ds_layout_ci.bindingCount = 1; |
| 4223 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4224 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4225 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4226 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4227 | ASSERT_VK_SUCCESS(err); |
| 4228 | |
| 4229 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4230 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4231 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4232 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4233 | alloc_info.descriptorPool = ds_pool; |
| 4234 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4235 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4236 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4237 | ASSERT_VK_SUCCESS(err); |
| 4238 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4239 | VkSampler sampler = |
| 4240 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4241 | |
| 4242 | VkDescriptorImageInfo descriptor_info; |
| 4243 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 4244 | descriptor_info.sampler = sampler; |
| 4245 | |
| 4246 | VkWriteDescriptorSet descriptor_write; |
| 4247 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4248 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4249 | descriptor_write.dstSet = descriptorSet; |
| 4250 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4251 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4252 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4253 | descriptor_write.pImageInfo = &descriptor_info; |
| 4254 | |
| 4255 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4256 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4257 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4258 | FAIL() << "Did not receive Error 'Attempt to update descriptor with " |
| 4259 | "invalid sampler...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4260 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4261 | } |
| 4262 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4263 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4264 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4265 | } |
| 4266 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4267 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 4268 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 4269 | // imageView |
| 4270 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4271 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4272 | m_errorMonitor->SetDesiredFailureMsg( |
| 4273 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4274 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 4275 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4276 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4277 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4278 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4279 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4280 | |
| 4281 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4282 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4283 | ds_pool_ci.pNext = NULL; |
| 4284 | ds_pool_ci.maxSets = 1; |
| 4285 | ds_pool_ci.poolSizeCount = 1; |
| 4286 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4287 | |
| 4288 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4289 | err = |
| 4290 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4291 | ASSERT_VK_SUCCESS(err); |
| 4292 | |
| 4293 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4294 | dsl_binding.binding = 0; |
| 4295 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4296 | dsl_binding.descriptorCount = 1; |
| 4297 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4298 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4299 | |
| 4300 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4301 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4302 | ds_layout_ci.pNext = NULL; |
| 4303 | ds_layout_ci.bindingCount = 1; |
| 4304 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4305 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4306 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4307 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4308 | ASSERT_VK_SUCCESS(err); |
| 4309 | |
| 4310 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4311 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4312 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4313 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4314 | alloc_info.descriptorPool = ds_pool; |
| 4315 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4316 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4317 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4318 | ASSERT_VK_SUCCESS(err); |
| 4319 | |
| 4320 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4321 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4322 | sampler_ci.pNext = NULL; |
| 4323 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4324 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4325 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4326 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4327 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4328 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4329 | sampler_ci.mipLodBias = 1.0; |
| 4330 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4331 | sampler_ci.maxAnisotropy = 1; |
| 4332 | sampler_ci.compareEnable = VK_FALSE; |
| 4333 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4334 | sampler_ci.minLod = 1.0; |
| 4335 | sampler_ci.maxLod = 1.0; |
| 4336 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4337 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4338 | |
| 4339 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4340 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4341 | ASSERT_VK_SUCCESS(err); |
| 4342 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4343 | VkImageView view = |
| 4344 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4345 | |
| 4346 | VkDescriptorImageInfo descriptor_info; |
| 4347 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 4348 | descriptor_info.sampler = sampler; |
| 4349 | descriptor_info.imageView = view; |
| 4350 | |
| 4351 | VkWriteDescriptorSet descriptor_write; |
| 4352 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4353 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4354 | descriptor_write.dstSet = descriptorSet; |
| 4355 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4356 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4357 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4358 | descriptor_write.pImageInfo = &descriptor_info; |
| 4359 | |
| 4360 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4361 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4362 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4363 | FAIL() << "Did not receive Error 'Attempt to update descriptor with " |
| 4364 | "invalid imageView...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4365 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4366 | } |
| 4367 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4368 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4369 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4370 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4371 | } |
| 4372 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4373 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 4374 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 4375 | // into the other |
| 4376 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4377 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4378 | m_errorMonitor->SetDesiredFailureMsg( |
| 4379 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Copy descriptor update index 0, update " |
| 4380 | "count #1, has src update descriptor " |
| 4381 | "type VK_DESCRIPTOR_TYPE_SAMPLER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4382 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4383 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4384 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4385 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4386 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4387 | ds_type_count[0].descriptorCount = 1; |
| 4388 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4389 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4390 | |
| 4391 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4392 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4393 | ds_pool_ci.pNext = NULL; |
| 4394 | ds_pool_ci.maxSets = 1; |
| 4395 | ds_pool_ci.poolSizeCount = 2; |
| 4396 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4397 | |
| 4398 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4399 | err = |
| 4400 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4401 | ASSERT_VK_SUCCESS(err); |
| 4402 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4403 | dsl_binding[0].binding = 0; |
| 4404 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4405 | dsl_binding[0].descriptorCount = 1; |
| 4406 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4407 | dsl_binding[0].pImmutableSamplers = NULL; |
| 4408 | dsl_binding[1].binding = 1; |
| 4409 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4410 | dsl_binding[1].descriptorCount = 1; |
| 4411 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 4412 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4413 | |
| 4414 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4415 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4416 | ds_layout_ci.pNext = NULL; |
| 4417 | ds_layout_ci.bindingCount = 2; |
| 4418 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4419 | |
| 4420 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4421 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4422 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4423 | ASSERT_VK_SUCCESS(err); |
| 4424 | |
| 4425 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4426 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4427 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4428 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4429 | alloc_info.descriptorPool = ds_pool; |
| 4430 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4431 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4432 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4433 | ASSERT_VK_SUCCESS(err); |
| 4434 | |
| 4435 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4436 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4437 | sampler_ci.pNext = NULL; |
| 4438 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4439 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4440 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4441 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4442 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4443 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4444 | sampler_ci.mipLodBias = 1.0; |
| 4445 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4446 | sampler_ci.maxAnisotropy = 1; |
| 4447 | sampler_ci.compareEnable = VK_FALSE; |
| 4448 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4449 | sampler_ci.minLod = 1.0; |
| 4450 | sampler_ci.maxLod = 1.0; |
| 4451 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4452 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4453 | |
| 4454 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4455 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4456 | ASSERT_VK_SUCCESS(err); |
| 4457 | |
| 4458 | VkDescriptorImageInfo info = {}; |
| 4459 | info.sampler = sampler; |
| 4460 | |
| 4461 | VkWriteDescriptorSet descriptor_write; |
| 4462 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 4463 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4464 | descriptor_write.dstSet = descriptorSet; |
| 4465 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4466 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4467 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4468 | descriptor_write.pImageInfo = &info; |
| 4469 | // This write update should succeed |
| 4470 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4471 | // Now perform a copy update that fails due to type mismatch |
| 4472 | VkCopyDescriptorSet copy_ds_update; |
| 4473 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4474 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4475 | copy_ds_update.srcSet = descriptorSet; |
| 4476 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4477 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4478 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4479 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4480 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4481 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4482 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4483 | FAIL() << "Did not receive Error 'Copy descriptor update index 0, " |
| 4484 | "update count #1, has src update descriptor " |
| 4485 | "type_DESCRIPTOR_TYPE_SAMPLER'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4486 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4487 | } |
| 4488 | // 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] | 4489 | m_errorMonitor->SetDesiredFailureMsg( |
| 4490 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4491 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4492 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4493 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4494 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4495 | copy_ds_update.srcBinding = |
| 4496 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4497 | copy_ds_update.dstSet = descriptorSet; |
| 4498 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4499 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4500 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4501 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4502 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4503 | FAIL() << "Did not receive Error 'Copy descriptor update 0 has " |
| 4504 | "srcBinding 3 which is out of bounds...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4505 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4506 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4507 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4508 | // 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] | 4509 | m_errorMonitor->SetDesiredFailureMsg( |
| 4510 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4511 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 4512 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4513 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4514 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4515 | copy_ds_update.srcSet = descriptorSet; |
| 4516 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4517 | copy_ds_update.dstSet = descriptorSet; |
| 4518 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4519 | copy_ds_update.descriptorCount = |
| 4520 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4521 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4522 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4523 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4524 | FAIL() << "Did not receive Error 'Copy descriptor src update is out of " |
| 4525 | "bounds for matching binding 1...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4526 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4527 | } |
| 4528 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4529 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4530 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4531 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4532 | } |
| 4533 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4534 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 4535 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 4536 | // sampleCount |
| 4537 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4538 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4539 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4540 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4541 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4542 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4543 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4544 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4545 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4546 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4547 | |
| 4548 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4549 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4550 | ds_pool_ci.pNext = NULL; |
| 4551 | ds_pool_ci.maxSets = 1; |
| 4552 | ds_pool_ci.poolSizeCount = 1; |
| 4553 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4554 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4555 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4556 | err = |
| 4557 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4558 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4559 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4560 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4561 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4562 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4563 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4564 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4565 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4566 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4567 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4568 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4569 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4570 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4571 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4572 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4573 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4574 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4575 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4576 | ASSERT_VK_SUCCESS(err); |
| 4577 | |
| 4578 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4579 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4580 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4581 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4582 | alloc_info.descriptorPool = ds_pool; |
| 4583 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4584 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4585 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4586 | ASSERT_VK_SUCCESS(err); |
| 4587 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4588 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4589 | pipe_ms_state_ci.sType = |
| 4590 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4591 | pipe_ms_state_ci.pNext = NULL; |
| 4592 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 4593 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4594 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4595 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4596 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4597 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4598 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4599 | pipeline_layout_ci.pNext = NULL; |
| 4600 | pipeline_layout_ci.setLayoutCount = 1; |
| 4601 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4602 | |
| 4603 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4604 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4605 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4606 | ASSERT_VK_SUCCESS(err); |
| 4607 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4608 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4609 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4610 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4611 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4612 | this); // TODO - We shouldn't need a fragment shader |
| 4613 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4614 | VkPipelineObj pipe(m_device); |
| 4615 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4616 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4617 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4618 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4619 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4620 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4621 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4622 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4623 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4624 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4625 | FAIL() << "Did not recieve Error 'Num samples mismatch!...'"; |
| 4626 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4627 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4628 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4629 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4630 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4631 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4632 | } |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4633 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4634 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 4635 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 4636 | // to issuing a Draw |
| 4637 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4638 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4639 | // TODO: verify that this matches layer |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4640 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4641 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4642 | "vkCmdClearAttachments() issued on CB object "); |
| 4643 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4644 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4645 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4646 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4647 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4648 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4649 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4650 | |
| 4651 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4652 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4653 | ds_pool_ci.pNext = NULL; |
| 4654 | ds_pool_ci.maxSets = 1; |
| 4655 | ds_pool_ci.poolSizeCount = 1; |
| 4656 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4657 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4658 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4659 | err = |
| 4660 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4661 | ASSERT_VK_SUCCESS(err); |
| 4662 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4663 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4664 | dsl_binding.binding = 0; |
| 4665 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4666 | dsl_binding.descriptorCount = 1; |
| 4667 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4668 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4669 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4670 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4671 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4672 | ds_layout_ci.pNext = NULL; |
| 4673 | ds_layout_ci.bindingCount = 1; |
| 4674 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4675 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4676 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4677 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4678 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4679 | ASSERT_VK_SUCCESS(err); |
| 4680 | |
| 4681 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4682 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4683 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4684 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4685 | alloc_info.descriptorPool = ds_pool; |
| 4686 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4687 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4688 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4689 | ASSERT_VK_SUCCESS(err); |
| 4690 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4691 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4692 | pipe_ms_state_ci.sType = |
| 4693 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4694 | pipe_ms_state_ci.pNext = NULL; |
| 4695 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 4696 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4697 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4698 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4699 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4700 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4701 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4702 | pipeline_layout_ci.pNext = NULL; |
| 4703 | pipeline_layout_ci.setLayoutCount = 1; |
| 4704 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4705 | |
| 4706 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4707 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4708 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4709 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4710 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4711 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4712 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4713 | // TODO - We shouldn't need a fragment shader but add it to be able to run |
| 4714 | // on more devices |
| 4715 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4716 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4717 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4718 | VkPipelineObj pipe(m_device); |
| 4719 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4720 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4721 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4722 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4723 | |
| 4724 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4725 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4726 | // Main thing we care about for this test is that the VkImage obj we're |
| 4727 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4728 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4729 | VkClearAttachment color_attachment; |
| 4730 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4731 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 4732 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 4733 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 4734 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 4735 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4736 | VkClearRect clear_rect = { |
| 4737 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4738 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4739 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 4740 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4741 | |
| 4742 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4743 | FAIL() << "Did not receive Error 'vkCommandClearAttachments() issued " |
| 4744 | "on CB object...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4745 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4746 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4747 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4748 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4749 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4750 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4751 | } |
| 4752 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4753 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 4754 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4755 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4756 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4757 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 4758 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4759 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4760 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4761 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4762 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4763 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4764 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4765 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4766 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4767 | |
| 4768 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4769 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4770 | ds_pool_ci.pNext = NULL; |
| 4771 | ds_pool_ci.maxSets = 1; |
| 4772 | ds_pool_ci.poolSizeCount = 1; |
| 4773 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4774 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4775 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4776 | err = |
| 4777 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4778 | ASSERT_VK_SUCCESS(err); |
| 4779 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4780 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4781 | dsl_binding.binding = 0; |
| 4782 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4783 | dsl_binding.descriptorCount = 1; |
| 4784 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4785 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4786 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4787 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4788 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4789 | ds_layout_ci.pNext = NULL; |
| 4790 | ds_layout_ci.bindingCount = 1; |
| 4791 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4792 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4793 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4794 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4795 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4796 | ASSERT_VK_SUCCESS(err); |
| 4797 | |
| 4798 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4799 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4800 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4801 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4802 | alloc_info.descriptorPool = ds_pool; |
| 4803 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4804 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4805 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4806 | ASSERT_VK_SUCCESS(err); |
| 4807 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4808 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4809 | pipe_ms_state_ci.sType = |
| 4810 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4811 | pipe_ms_state_ci.pNext = NULL; |
| 4812 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 4813 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4814 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4815 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4816 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4817 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4818 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4819 | pipeline_layout_ci.pNext = NULL; |
| 4820 | pipeline_layout_ci.setLayoutCount = 1; |
| 4821 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4822 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4823 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4824 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4825 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4826 | ASSERT_VK_SUCCESS(err); |
| 4827 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4828 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4829 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4830 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4831 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4832 | this); // TODO - We shouldn't need a fragment shader |
| 4833 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4834 | VkPipelineObj pipe(m_device); |
| 4835 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4836 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4837 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4838 | pipe.SetViewport(m_viewports); |
| 4839 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4840 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4841 | |
| 4842 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4843 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4844 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4845 | // Don't care about actual data, just need to get to draw to flag error |
| 4846 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4847 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 4848 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4849 | 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] | 4850 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4851 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4852 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4853 | FAIL() << "Did not receive Error 'Vtx Buffer Index 0 was bound, but no " |
| 4854 | "vtx buffers are attached to PSO.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4855 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4856 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4857 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4858 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4859 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4860 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4861 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4862 | #endif // DRAW_STATE_TESTS |
| 4863 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 4864 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4865 | #if GTEST_IS_THREADSAFE |
| 4866 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4867 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4868 | VkEvent event; |
| 4869 | bool bailout; |
| 4870 | }; |
| 4871 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4872 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 4873 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4874 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4875 | for (int i = 0; i < 10000; i++) { |
| 4876 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 4877 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4878 | if (data->bailout) { |
| 4879 | break; |
| 4880 | } |
| 4881 | } |
| 4882 | return NULL; |
| 4883 | } |
| 4884 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4885 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4886 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4887 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4888 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4889 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4890 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4891 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4892 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4893 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4894 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4895 | // Calls AllocateCommandBuffers |
| 4896 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4897 | |
| 4898 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4899 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4900 | |
| 4901 | VkEventCreateInfo event_info; |
| 4902 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4903 | VkResult err; |
| 4904 | |
| 4905 | memset(&event_info, 0, sizeof(event_info)); |
| 4906 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 4907 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4908 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4909 | ASSERT_VK_SUCCESS(err); |
| 4910 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4911 | err = vkResetEvent(device(), event); |
| 4912 | ASSERT_VK_SUCCESS(err); |
| 4913 | |
| 4914 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4915 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4916 | data.event = event; |
| 4917 | data.bailout = false; |
| 4918 | m_errorMonitor->SetBailout(&data.bailout); |
| 4919 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4920 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4921 | // Add many entries to command buffer from this thread at the same time. |
| 4922 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4923 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4924 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4925 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4926 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 4927 | m_errorMonitor->SetBailout(NULL); |
| 4928 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4929 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4930 | FAIL() << "Did not receive Error 'THREADING ERROR' from using one " |
| 4931 | "VkCommandBufferObj in two threads"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4932 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4933 | } |
| 4934 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4935 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4936 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4937 | #endif // GTEST_IS_THREADSAFE |
| 4938 | #endif // THREADING_TESTS |
| 4939 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4940 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4941 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4942 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4943 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4944 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4945 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4946 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4947 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4948 | VkShaderModule module; |
| 4949 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4950 | struct icd_spv_header spv; |
| 4951 | |
| 4952 | spv.magic = ICD_SPV_MAGIC; |
| 4953 | spv.version = ICD_SPV_VERSION; |
| 4954 | spv.gen_magic = 0; |
| 4955 | |
| 4956 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4957 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4958 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4959 | moduleCreateInfo.codeSize = 4; |
| 4960 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4961 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4962 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4963 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4964 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4965 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4966 | } |
| 4967 | } |
| 4968 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4969 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4970 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4971 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4972 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4973 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4974 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4975 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4976 | VkShaderModule module; |
| 4977 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4978 | struct icd_spv_header spv; |
| 4979 | |
| 4980 | spv.magic = ~ICD_SPV_MAGIC; |
| 4981 | spv.version = ICD_SPV_VERSION; |
| 4982 | spv.gen_magic = 0; |
| 4983 | |
| 4984 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4985 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4986 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4987 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4988 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4989 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4990 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4991 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4992 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4993 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4994 | } |
| 4995 | } |
| 4996 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4997 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4998 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4999 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5000 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5001 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5002 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5003 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5004 | VkShaderModule module; |
| 5005 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 5006 | struct icd_spv_header spv; |
| 5007 | |
| 5008 | spv.magic = ICD_SPV_MAGIC; |
| 5009 | spv.version = ~ICD_SPV_VERSION; |
| 5010 | spv.gen_magic = 0; |
| 5011 | |
| 5012 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 5013 | moduleCreateInfo.pNext = NULL; |
| 5014 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5015 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5016 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 5017 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5018 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5019 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5020 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5021 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 5022 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5023 | } |
| 5024 | } |
| 5025 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5026 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5027 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5028 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5029 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5030 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5031 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5032 | |
| 5033 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5034 | "#version 400\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5035 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5036 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5037 | "\n" |
| 5038 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5039 | "out gl_PerVertex {\n" |
| 5040 | " vec4 gl_Position;\n" |
| 5041 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5042 | "void main(){\n" |
| 5043 | " gl_Position = vec4(1);\n" |
| 5044 | " x = 0;\n" |
| 5045 | "}\n"; |
| 5046 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5047 | "#version 400\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5048 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5049 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5050 | "\n" |
| 5051 | "layout(location=0) out vec4 color;\n" |
| 5052 | "void main(){\n" |
| 5053 | " color = vec4(1);\n" |
| 5054 | "}\n"; |
| 5055 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5056 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5057 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5058 | |
| 5059 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5060 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5061 | pipe.AddShader(&vs); |
| 5062 | pipe.AddShader(&fs); |
| 5063 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5064 | VkDescriptorSetObj descriptorSet(m_device); |
| 5065 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5066 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5067 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5068 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5069 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5070 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5071 | FAIL() << "Did not receive Warning 'not consumed by fragment shader'"; |
| 5072 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5073 | } |
| 5074 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5075 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5076 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5077 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5078 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5079 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5080 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5081 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5082 | |
| 5083 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5084 | "#version 400\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5085 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5086 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5087 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5088 | "out gl_PerVertex {\n" |
| 5089 | " vec4 gl_Position;\n" |
| 5090 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5091 | "void main(){\n" |
| 5092 | " gl_Position = vec4(1);\n" |
| 5093 | "}\n"; |
| 5094 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5095 | "#version 400\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5096 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5097 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5098 | "\n" |
| 5099 | "layout(location=0) in float x;\n" |
| 5100 | "layout(location=0) out vec4 color;\n" |
| 5101 | "void main(){\n" |
| 5102 | " color = vec4(x);\n" |
| 5103 | "}\n"; |
| 5104 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5105 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5106 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5107 | |
| 5108 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5109 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5110 | pipe.AddShader(&vs); |
| 5111 | pipe.AddShader(&fs); |
| 5112 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5113 | VkDescriptorSetObj descriptorSet(m_device); |
| 5114 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5115 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5116 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5117 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5118 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5119 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5120 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 5121 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5122 | } |
| 5123 | } |
| 5124 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5125 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5126 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5127 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5128 | |
| 5129 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5130 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5131 | |
| 5132 | char const *vsSource = |
| 5133 | "#version 400\n" |
| 5134 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5135 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5136 | "\n" |
| 5137 | "out gl_PerVertex {\n" |
| 5138 | " vec4 gl_Position;\n" |
| 5139 | "};\n" |
| 5140 | "void main(){\n" |
| 5141 | " gl_Position = vec4(1);\n" |
| 5142 | "}\n"; |
| 5143 | char const *fsSource = |
| 5144 | "#version 450\n" |
| 5145 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5146 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5147 | "\n" |
| 5148 | "in block { layout(location=0) float x; } ins;\n" |
| 5149 | "layout(location=0) out vec4 color;\n" |
| 5150 | "void main(){\n" |
| 5151 | " color = vec4(ins.x);\n" |
| 5152 | "}\n"; |
| 5153 | |
| 5154 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5155 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5156 | |
| 5157 | VkPipelineObj pipe(m_device); |
| 5158 | pipe.AddColorAttachment(); |
| 5159 | pipe.AddShader(&vs); |
| 5160 | pipe.AddShader(&fs); |
| 5161 | |
| 5162 | VkDescriptorSetObj descriptorSet(m_device); |
| 5163 | descriptorSet.AppendDummy(); |
| 5164 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5165 | |
| 5166 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5167 | |
| 5168 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5169 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 5170 | m_errorMonitor->DumpFailureMsgs(); |
| 5171 | } |
| 5172 | } |
| 5173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5174 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5175 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5176 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5177 | "output arr[2] of float32' vs 'ptr to " |
| 5178 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5179 | |
| 5180 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5181 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5182 | |
| 5183 | char const *vsSource = |
| 5184 | "#version 400\n" |
| 5185 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5186 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5187 | "\n" |
| 5188 | "layout(location=0) out float x[2];\n" |
| 5189 | "out gl_PerVertex {\n" |
| 5190 | " vec4 gl_Position;\n" |
| 5191 | "};\n" |
| 5192 | "void main(){\n" |
| 5193 | " x[0] = 0; x[1] = 0;\n" |
| 5194 | " gl_Position = vec4(1);\n" |
| 5195 | "}\n"; |
| 5196 | char const *fsSource = |
| 5197 | "#version 400\n" |
| 5198 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5199 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5200 | "\n" |
| 5201 | "layout(location=0) in float x[3];\n" |
| 5202 | "layout(location=0) out vec4 color;\n" |
| 5203 | "void main(){\n" |
| 5204 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 5205 | "}\n"; |
| 5206 | |
| 5207 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5208 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5209 | |
| 5210 | VkPipelineObj pipe(m_device); |
| 5211 | pipe.AddColorAttachment(); |
| 5212 | pipe.AddShader(&vs); |
| 5213 | pipe.AddShader(&fs); |
| 5214 | |
| 5215 | VkDescriptorSetObj descriptorSet(m_device); |
| 5216 | descriptorSet.AppendDummy(); |
| 5217 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5218 | |
| 5219 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5220 | |
| 5221 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5222 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5223 | FAIL() << "Did not receive Error 'Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5224 | "output arr[2] of float32' vs 'ptr to input arr[3] of " |
| 5225 | "float32''"; |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5226 | } |
| 5227 | } |
| 5228 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5229 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5230 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5231 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5232 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5233 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5234 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5235 | |
| 5236 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5237 | "#version 400\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5238 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5239 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5240 | "\n" |
| 5241 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5242 | "out gl_PerVertex {\n" |
| 5243 | " vec4 gl_Position;\n" |
| 5244 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5245 | "void main(){\n" |
| 5246 | " x = 0;\n" |
| 5247 | " gl_Position = vec4(1);\n" |
| 5248 | "}\n"; |
| 5249 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5250 | "#version 400\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5251 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5252 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5253 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5254 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5255 | "layout(location=0) out vec4 color;\n" |
| 5256 | "void main(){\n" |
| 5257 | " color = vec4(x);\n" |
| 5258 | "}\n"; |
| 5259 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5260 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5261 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5262 | |
| 5263 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5264 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5265 | pipe.AddShader(&vs); |
| 5266 | pipe.AddShader(&fs); |
| 5267 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5268 | VkDescriptorSetObj descriptorSet(m_device); |
| 5269 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5270 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5271 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5272 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5273 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5274 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5275 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 5276 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5277 | } |
| 5278 | } |
| 5279 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5280 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5281 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5282 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5283 | |
| 5284 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5285 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5286 | |
| 5287 | char const *vsSource = |
| 5288 | "#version 450\n" |
| 5289 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5290 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5291 | "\n" |
| 5292 | "out block { layout(location=0) int x; } outs;\n" |
| 5293 | "out gl_PerVertex {\n" |
| 5294 | " vec4 gl_Position;\n" |
| 5295 | "};\n" |
| 5296 | "void main(){\n" |
| 5297 | " outs.x = 0;\n" |
| 5298 | " gl_Position = vec4(1);\n" |
| 5299 | "}\n"; |
| 5300 | char const *fsSource = |
| 5301 | "#version 450\n" |
| 5302 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5303 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5304 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5305 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5306 | "layout(location=0) out vec4 color;\n" |
| 5307 | "void main(){\n" |
| 5308 | " color = vec4(ins.x);\n" |
| 5309 | "}\n"; |
| 5310 | |
| 5311 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5312 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5313 | |
| 5314 | VkPipelineObj pipe(m_device); |
| 5315 | pipe.AddColorAttachment(); |
| 5316 | pipe.AddShader(&vs); |
| 5317 | pipe.AddShader(&fs); |
| 5318 | |
| 5319 | VkDescriptorSetObj descriptorSet(m_device); |
| 5320 | descriptorSet.AppendDummy(); |
| 5321 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5322 | |
| 5323 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5324 | |
| 5325 | if (!m_errorMonitor->DesiredMsgFound()) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5326 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5327 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 5328 | } |
| 5329 | } |
| 5330 | |
| 5331 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 5332 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5333 | "location 0.0 which is not written by vertex shader"); |
| 5334 | |
| 5335 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5336 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5337 | |
| 5338 | char const *vsSource = |
| 5339 | "#version 450\n" |
| 5340 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5341 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5342 | "\n" |
| 5343 | "out block { layout(location=1) float x; } outs;\n" |
| 5344 | "out gl_PerVertex {\n" |
| 5345 | " vec4 gl_Position;\n" |
| 5346 | "};\n" |
| 5347 | "void main(){\n" |
| 5348 | " outs.x = 0;\n" |
| 5349 | " gl_Position = vec4(1);\n" |
| 5350 | "}\n"; |
| 5351 | char const *fsSource = |
| 5352 | "#version 450\n" |
| 5353 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5354 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5355 | "\n" |
| 5356 | "in block { layout(location=0) float x; } ins;\n" |
| 5357 | "layout(location=0) out vec4 color;\n" |
| 5358 | "void main(){\n" |
| 5359 | " color = vec4(ins.x);\n" |
| 5360 | "}\n"; |
| 5361 | |
| 5362 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5363 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5364 | |
| 5365 | VkPipelineObj pipe(m_device); |
| 5366 | pipe.AddColorAttachment(); |
| 5367 | pipe.AddShader(&vs); |
| 5368 | pipe.AddShader(&fs); |
| 5369 | |
| 5370 | VkDescriptorSetObj descriptorSet(m_device); |
| 5371 | descriptorSet.AppendDummy(); |
| 5372 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5373 | |
| 5374 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5375 | |
| 5376 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5377 | m_errorMonitor->DumpFailureMsgs(); |
| 5378 | FAIL() << "Did not receive Error 'location 0.0 which is not written by vertex shader'"; |
| 5379 | } |
| 5380 | } |
| 5381 | |
| 5382 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 5383 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5384 | "location 0.1 which is not written by vertex shader"); |
| 5385 | |
| 5386 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5387 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5388 | |
| 5389 | char const *vsSource = |
| 5390 | "#version 450\n" |
| 5391 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5392 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5393 | "\n" |
| 5394 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 5395 | "out gl_PerVertex {\n" |
| 5396 | " vec4 gl_Position;\n" |
| 5397 | "};\n" |
| 5398 | "void main(){\n" |
| 5399 | " outs.x = 0;\n" |
| 5400 | " gl_Position = vec4(1);\n" |
| 5401 | "}\n"; |
| 5402 | char const *fsSource = |
| 5403 | "#version 450\n" |
| 5404 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5405 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5406 | "\n" |
| 5407 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 5408 | "layout(location=0) out vec4 color;\n" |
| 5409 | "void main(){\n" |
| 5410 | " color = vec4(ins.x);\n" |
| 5411 | "}\n"; |
| 5412 | |
| 5413 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5414 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5415 | |
| 5416 | VkPipelineObj pipe(m_device); |
| 5417 | pipe.AddColorAttachment(); |
| 5418 | pipe.AddShader(&vs); |
| 5419 | pipe.AddShader(&fs); |
| 5420 | |
| 5421 | VkDescriptorSetObj descriptorSet(m_device); |
| 5422 | descriptorSet.AppendDummy(); |
| 5423 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5424 | |
| 5425 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5426 | |
| 5427 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5428 | m_errorMonitor->DumpFailureMsgs(); |
| 5429 | FAIL() << "Did not receive Error 'location 0.1 which is not written by vertex shader'"; |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5430 | } |
| 5431 | } |
| 5432 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5433 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5434 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5435 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5436 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5437 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5438 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5439 | |
| 5440 | VkVertexInputBindingDescription input_binding; |
| 5441 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5442 | |
| 5443 | VkVertexInputAttributeDescription input_attrib; |
| 5444 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5445 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5446 | |
| 5447 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5448 | "#version 400\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5449 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5450 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5451 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5452 | "out gl_PerVertex {\n" |
| 5453 | " vec4 gl_Position;\n" |
| 5454 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5455 | "void main(){\n" |
| 5456 | " gl_Position = vec4(1);\n" |
| 5457 | "}\n"; |
| 5458 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5459 | "#version 400\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5460 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5461 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5462 | "\n" |
| 5463 | "layout(location=0) out vec4 color;\n" |
| 5464 | "void main(){\n" |
| 5465 | " color = vec4(1);\n" |
| 5466 | "}\n"; |
| 5467 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5468 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5469 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5470 | |
| 5471 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5472 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5473 | pipe.AddShader(&vs); |
| 5474 | pipe.AddShader(&fs); |
| 5475 | |
| 5476 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5477 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5478 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5479 | VkDescriptorSetObj descriptorSet(m_device); |
| 5480 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5481 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5482 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5483 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5484 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5485 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5486 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 5487 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5488 | } |
| 5489 | } |
| 5490 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5491 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5492 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5493 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5494 | |
| 5495 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5496 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5497 | |
| 5498 | VkVertexInputBindingDescription input_binding; |
| 5499 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5500 | |
| 5501 | VkVertexInputAttributeDescription input_attrib; |
| 5502 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5503 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5504 | |
| 5505 | char const *vsSource = |
| 5506 | "#version 400\n" |
| 5507 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5508 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5509 | "\n" |
| 5510 | "layout(location=1) in float x;\n" |
| 5511 | "out gl_PerVertex {\n" |
| 5512 | " vec4 gl_Position;\n" |
| 5513 | "};\n" |
| 5514 | "void main(){\n" |
| 5515 | " gl_Position = vec4(x);\n" |
| 5516 | "}\n"; |
| 5517 | char const *fsSource = |
| 5518 | "#version 400\n" |
| 5519 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5520 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5521 | "\n" |
| 5522 | "layout(location=0) out vec4 color;\n" |
| 5523 | "void main(){\n" |
| 5524 | " color = vec4(1);\n" |
| 5525 | "}\n"; |
| 5526 | |
| 5527 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5528 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5529 | |
| 5530 | VkPipelineObj pipe(m_device); |
| 5531 | pipe.AddColorAttachment(); |
| 5532 | pipe.AddShader(&vs); |
| 5533 | pipe.AddShader(&fs); |
| 5534 | |
| 5535 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5536 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5537 | |
| 5538 | VkDescriptorSetObj descriptorSet(m_device); |
| 5539 | descriptorSet.AppendDummy(); |
| 5540 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5541 | |
| 5542 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5543 | |
| 5544 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5545 | m_errorMonitor->DumpFailureMsgs(); |
| 5546 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 5547 | } |
| 5548 | } |
| 5549 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5550 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 5551 | m_errorMonitor->SetDesiredFailureMsg( |
| 5552 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5553 | "VS consumes input at location 0 but not provided"); |
| 5554 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5555 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5556 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5557 | |
| 5558 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5559 | "#version 400\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5560 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5561 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5562 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5563 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5564 | "out gl_PerVertex {\n" |
| 5565 | " vec4 gl_Position;\n" |
| 5566 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5567 | "void main(){\n" |
| 5568 | " gl_Position = x;\n" |
| 5569 | "}\n"; |
| 5570 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5571 | "#version 400\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5572 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5573 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5574 | "\n" |
| 5575 | "layout(location=0) out vec4 color;\n" |
| 5576 | "void main(){\n" |
| 5577 | " color = vec4(1);\n" |
| 5578 | "}\n"; |
| 5579 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5580 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5581 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5582 | |
| 5583 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5584 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5585 | pipe.AddShader(&vs); |
| 5586 | pipe.AddShader(&fs); |
| 5587 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5588 | VkDescriptorSetObj descriptorSet(m_device); |
| 5589 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5590 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5591 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5592 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5593 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5594 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5595 | FAIL() << "Did not receive Error 'VS consumes input at location 0 but " |
| 5596 | "not provided'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5597 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5598 | } |
| 5599 | } |
| 5600 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5601 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 5602 | m_errorMonitor->SetDesiredFailureMsg( |
| 5603 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5604 | "location 0 does not match VS input type"); |
| 5605 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5606 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5607 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5608 | |
| 5609 | VkVertexInputBindingDescription input_binding; |
| 5610 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5611 | |
| 5612 | VkVertexInputAttributeDescription input_attrib; |
| 5613 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5614 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5615 | |
| 5616 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5617 | "#version 400\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5618 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5619 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5620 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5621 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5622 | "out gl_PerVertex {\n" |
| 5623 | " vec4 gl_Position;\n" |
| 5624 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5625 | "void main(){\n" |
| 5626 | " gl_Position = vec4(x);\n" |
| 5627 | "}\n"; |
| 5628 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5629 | "#version 400\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5630 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5631 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5632 | "\n" |
| 5633 | "layout(location=0) out vec4 color;\n" |
| 5634 | "void main(){\n" |
| 5635 | " color = vec4(1);\n" |
| 5636 | "}\n"; |
| 5637 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5638 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5639 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5640 | |
| 5641 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5642 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5643 | pipe.AddShader(&vs); |
| 5644 | pipe.AddShader(&fs); |
| 5645 | |
| 5646 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5647 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5648 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5649 | VkDescriptorSetObj descriptorSet(m_device); |
| 5650 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5651 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5652 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5653 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5654 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5655 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5656 | FAIL() << "Did not receive Error 'location 0 does not match VS input " |
| 5657 | "type'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5658 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5659 | } |
| 5660 | } |
| 5661 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5662 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5663 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 5664 | |
| 5665 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5666 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5667 | |
| 5668 | VkVertexInputBindingDescription input_binding; |
| 5669 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5670 | |
| 5671 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5672 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5673 | |
| 5674 | for (int i = 0; i < 2; i++) { |
| 5675 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5676 | input_attribs[i].location = i; |
| 5677 | } |
| 5678 | |
| 5679 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5680 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5681 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5682 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5683 | "\n" |
| 5684 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5685 | "out gl_PerVertex {\n" |
| 5686 | " vec4 gl_Position;\n" |
| 5687 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5688 | "void main(){\n" |
| 5689 | " gl_Position = x[0] + x[1];\n" |
| 5690 | "}\n"; |
| 5691 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5692 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5693 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5694 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5695 | "\n" |
| 5696 | "layout(location=0) out vec4 color;\n" |
| 5697 | "void main(){\n" |
| 5698 | " color = vec4(1);\n" |
| 5699 | "}\n"; |
| 5700 | |
| 5701 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5702 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5703 | |
| 5704 | VkPipelineObj pipe(m_device); |
| 5705 | pipe.AddColorAttachment(); |
| 5706 | pipe.AddShader(&vs); |
| 5707 | pipe.AddShader(&fs); |
| 5708 | |
| 5709 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5710 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5711 | |
| 5712 | VkDescriptorSetObj descriptorSet(m_device); |
| 5713 | descriptorSet.AppendDummy(); |
| 5714 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5715 | |
| 5716 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5717 | |
| 5718 | /* expect success */ |
| 5719 | if (m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5720 | FAIL() << "Expected to succeed but: " |
| 5721 | << m_errorMonitor->GetFailureMsg(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5722 | m_errorMonitor->DumpFailureMsgs(); |
| 5723 | } |
| 5724 | } |
| 5725 | |
| 5726 | /* |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5727 | * Would work, but not supported by glslang! This is similar to the matrix case |
| 5728 | above. |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5729 | * |
| 5730 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 5731 | { |
| 5732 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 5733 | |
| 5734 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5735 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5736 | |
| 5737 | VkVertexInputBindingDescription input_binding; |
| 5738 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5739 | |
| 5740 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5741 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5742 | |
| 5743 | for (int i = 0; i < 2; i++) { |
| 5744 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5745 | input_attribs[i].location = i; |
| 5746 | } |
| 5747 | |
| 5748 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5749 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5750 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5751 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5752 | "\n" |
| 5753 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5754 | "out gl_PerVertex {\n" |
| 5755 | " vec4 gl_Position;\n" |
| 5756 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5757 | "void main(){\n" |
| 5758 | " gl_Position = x[0] + x[1];\n" |
| 5759 | "}\n"; |
| 5760 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5761 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5762 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5763 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5764 | "\n" |
| 5765 | "layout(location=0) out vec4 color;\n" |
| 5766 | "void main(){\n" |
| 5767 | " color = vec4(1);\n" |
| 5768 | "}\n"; |
| 5769 | |
| 5770 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5771 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5772 | |
| 5773 | VkPipelineObj pipe(m_device); |
| 5774 | pipe.AddColorAttachment(); |
| 5775 | pipe.AddShader(&vs); |
| 5776 | pipe.AddShader(&fs); |
| 5777 | |
| 5778 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5779 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5780 | |
| 5781 | VkDescriptorSetObj descriptorSet(m_device); |
| 5782 | descriptorSet.AppendDummy(); |
| 5783 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5784 | |
| 5785 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5786 | |
| 5787 | if (m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5788 | FAIL() << "Expected to succeed but: " << |
| 5789 | m_errorMonitor->GetFailureMsg(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5790 | m_errorMonitor->DumpFailureMsgs(); |
| 5791 | } |
| 5792 | } |
| 5793 | */ |
| 5794 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5795 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 5796 | m_errorMonitor->SetDesiredFailureMsg( |
| 5797 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5798 | "Duplicate vertex input binding descriptions for binding 0"); |
| 5799 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5800 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5801 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5802 | |
| 5803 | /* Two binding descriptions for binding 0 */ |
| 5804 | VkVertexInputBindingDescription input_bindings[2]; |
| 5805 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 5806 | |
| 5807 | VkVertexInputAttributeDescription input_attrib; |
| 5808 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5809 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5810 | |
| 5811 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5812 | "#version 400\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5813 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5814 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5815 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5816 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5817 | "out gl_PerVertex {\n" |
| 5818 | " vec4 gl_Position;\n" |
| 5819 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5820 | "void main(){\n" |
| 5821 | " gl_Position = vec4(x);\n" |
| 5822 | "}\n"; |
| 5823 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5824 | "#version 400\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5825 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5826 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5827 | "\n" |
| 5828 | "layout(location=0) out vec4 color;\n" |
| 5829 | "void main(){\n" |
| 5830 | " color = vec4(1);\n" |
| 5831 | "}\n"; |
| 5832 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5833 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5834 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5835 | |
| 5836 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5837 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5838 | pipe.AddShader(&vs); |
| 5839 | pipe.AddShader(&fs); |
| 5840 | |
| 5841 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 5842 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5843 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5844 | VkDescriptorSetObj descriptorSet(m_device); |
| 5845 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5846 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5847 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5848 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5849 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5850 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5851 | FAIL() << "Did not receive Error 'Duplicate vertex input binding " |
| 5852 | "descriptions for binding 0'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5853 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5854 | } |
| 5855 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 5856 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5857 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5858 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5859 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5860 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5861 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5862 | |
| 5863 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5864 | "#version 400\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5865 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5866 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5867 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5868 | "out gl_PerVertex {\n" |
| 5869 | " vec4 gl_Position;\n" |
| 5870 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5871 | "void main(){\n" |
| 5872 | " gl_Position = vec4(1);\n" |
| 5873 | "}\n"; |
| 5874 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5875 | "#version 400\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5876 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5877 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5878 | "\n" |
| 5879 | "void main(){\n" |
| 5880 | "}\n"; |
| 5881 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5882 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5883 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5884 | |
| 5885 | VkPipelineObj pipe(m_device); |
| 5886 | pipe.AddShader(&vs); |
| 5887 | pipe.AddShader(&fs); |
| 5888 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5889 | /* set up CB 0, not written */ |
| 5890 | pipe.AddColorAttachment(); |
| 5891 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5892 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5893 | VkDescriptorSetObj descriptorSet(m_device); |
| 5894 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5895 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5896 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5897 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5898 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5899 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5900 | FAIL() << "Did not receive Error 'Attachment 0 not written by FS'"; |
| 5901 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5902 | } |
| 5903 | } |
| 5904 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5905 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5906 | // TODO: verify that this matches layer |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5907 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5908 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5909 | "FS writes to output location 1 with no matching attachment"); |
| 5910 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5911 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5912 | |
| 5913 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5914 | "#version 400\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5915 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5916 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5917 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5918 | "out gl_PerVertex {\n" |
| 5919 | " vec4 gl_Position;\n" |
| 5920 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5921 | "void main(){\n" |
| 5922 | " gl_Position = vec4(1);\n" |
| 5923 | "}\n"; |
| 5924 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5925 | "#version 400\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5926 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5927 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5928 | "\n" |
| 5929 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5930 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5931 | "void main(){\n" |
| 5932 | " x = vec4(1);\n" |
| 5933 | " y = vec4(1);\n" |
| 5934 | "}\n"; |
| 5935 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5936 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5937 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5938 | |
| 5939 | VkPipelineObj pipe(m_device); |
| 5940 | pipe.AddShader(&vs); |
| 5941 | pipe.AddShader(&fs); |
| 5942 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5943 | /* set up CB 0, not written */ |
| 5944 | pipe.AddColorAttachment(); |
| 5945 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5946 | /* FS writes CB 1, but we don't configure it */ |
| 5947 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5948 | VkDescriptorSetObj descriptorSet(m_device); |
| 5949 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5950 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5951 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5952 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5953 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5954 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5955 | FAIL() << "Did not receive Error 'FS writes to output location 1 with " |
| 5956 | "no matching attachment'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5957 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5958 | } |
| 5959 | } |
| 5960 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5961 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5962 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5963 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5964 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5965 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5966 | |
| 5967 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5968 | "#version 400\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5969 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5970 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5971 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5972 | "out gl_PerVertex {\n" |
| 5973 | " vec4 gl_Position;\n" |
| 5974 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5975 | "void main(){\n" |
| 5976 | " gl_Position = vec4(1);\n" |
| 5977 | "}\n"; |
| 5978 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5979 | "#version 400\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5980 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5981 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5982 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5983 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5984 | "void main(){\n" |
| 5985 | " x = ivec4(1);\n" |
| 5986 | "}\n"; |
| 5987 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5988 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5989 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5990 | |
| 5991 | VkPipelineObj pipe(m_device); |
| 5992 | pipe.AddShader(&vs); |
| 5993 | pipe.AddShader(&fs); |
| 5994 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5995 | /* set up CB 0; type is UNORM by default */ |
| 5996 | pipe.AddColorAttachment(); |
| 5997 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5998 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5999 | VkDescriptorSetObj descriptorSet(m_device); |
| 6000 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6001 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6002 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6003 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6004 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6005 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6006 | FAIL() << "Did not receive Error 'does not match FS output type'"; |
| 6007 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6008 | } |
| 6009 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 6010 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6011 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6012 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6013 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6014 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6015 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6016 | |
| 6017 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6018 | "#version 400\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6019 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 6020 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 6021 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6022 | "out gl_PerVertex {\n" |
| 6023 | " vec4 gl_Position;\n" |
| 6024 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6025 | "void main(){\n" |
| 6026 | " gl_Position = vec4(1);\n" |
| 6027 | "}\n"; |
| 6028 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6029 | "#version 400\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6030 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 6031 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 6032 | "\n" |
| 6033 | "layout(location=0) out vec4 x;\n" |
| 6034 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 6035 | "void main(){\n" |
| 6036 | " x = vec4(bar.y);\n" |
| 6037 | "}\n"; |
| 6038 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6039 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6040 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6041 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6042 | VkPipelineObj pipe(m_device); |
| 6043 | pipe.AddShader(&vs); |
| 6044 | pipe.AddShader(&fs); |
| 6045 | |
| 6046 | /* set up CB 0; type is UNORM by default */ |
| 6047 | pipe.AddColorAttachment(); |
| 6048 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6049 | |
| 6050 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6051 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6052 | |
| 6053 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6054 | |
| 6055 | /* should have generated an error -- pipeline layout does not |
| 6056 | * provide a uniform buffer in 0.0 |
| 6057 | */ |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6058 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6059 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 6060 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6061 | } |
| 6062 | } |
| 6063 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6064 | #endif // SHADER_CHECKER_TESTS |
| 6065 | |
| 6066 | #if DEVICE_LIMITS_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6067 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) { |
| 6068 | m_errorMonitor->SetDesiredFailureMsg( |
| 6069 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6070 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6071 | |
| 6072 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6073 | |
| 6074 | // Create an image |
| 6075 | VkImage image; |
| 6076 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6077 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6078 | const int32_t tex_width = 32; |
| 6079 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6080 | |
| 6081 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6082 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6083 | image_create_info.pNext = NULL; |
| 6084 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6085 | image_create_info.format = tex_format; |
| 6086 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6087 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6088 | image_create_info.extent.depth = 1; |
| 6089 | image_create_info.mipLevels = 1; |
| 6090 | image_create_info.arrayLayers = 1; |
| 6091 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6092 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6093 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6094 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6095 | |
| 6096 | // Introduce error by sending down a bogus width extent |
| 6097 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6098 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6099 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6100 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6101 | FAIL() << "Did not receive Error 'CreateImage extents exceed allowable " |
| 6102 | "limits for format'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6103 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6104 | } |
| 6105 | } |
| 6106 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6107 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 6108 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6109 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6110 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6111 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6112 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6113 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6114 | |
| 6115 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6116 | vk_testing::Buffer buffer; |
| 6117 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 6118 | |
| 6119 | BeginCommandBuffer(); |
| 6120 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6121 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6122 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6123 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, " |
| 6124 | "VkDeviceSize dstOffset, is not a multiple of 4'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6125 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6126 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6127 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6128 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6129 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6130 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6131 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6132 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6133 | |
| 6134 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6135 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, " |
| 6136 | "VkDeviceSize dataSize, is not a multiple of 4'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6137 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6138 | } |
| 6139 | EndCommandBuffer(); |
| 6140 | } |
| 6141 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6142 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6143 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6144 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6145 | |
| 6146 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6147 | |
| 6148 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6149 | vk_testing::Buffer buffer; |
| 6150 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 6151 | |
| 6152 | BeginCommandBuffer(); |
| 6153 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6154 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6155 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6156 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, " |
| 6157 | "VkDeviceSize dstOffset, is not a multiple of 4'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6158 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6159 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6160 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6161 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6162 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6163 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6164 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6165 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6166 | |
| 6167 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6168 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, " |
| 6169 | "VkDeviceSize size, is not a multiple of 4'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6170 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6171 | } |
| 6172 | EndCommandBuffer(); |
| 6173 | } |
| 6174 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6175 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6176 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6177 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6178 | TEST_F(VkLayerTest, InvalidImageView) { |
| 6179 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6180 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6181 | m_errorMonitor->SetDesiredFailureMsg( |
| 6182 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6183 | "vkCreateImageView called with baseMipLevel 10 "); |
| 6184 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6185 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6186 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6187 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6188 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6189 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6190 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6191 | const int32_t tex_width = 32; |
| 6192 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6193 | |
| 6194 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6195 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6196 | image_create_info.pNext = NULL; |
| 6197 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6198 | image_create_info.format = tex_format; |
| 6199 | image_create_info.extent.width = tex_width; |
| 6200 | image_create_info.extent.height = tex_height; |
| 6201 | image_create_info.extent.depth = 1; |
| 6202 | image_create_info.mipLevels = 1; |
| 6203 | image_create_info.arrayLayers = 1; |
| 6204 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6205 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6206 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6207 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6208 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6209 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6210 | ASSERT_VK_SUCCESS(err); |
| 6211 | |
| 6212 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6213 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6214 | image_view_create_info.image = image; |
| 6215 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6216 | image_view_create_info.format = tex_format; |
| 6217 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6218 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 6219 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6220 | image_view_create_info.subresourceRange.aspectMask = |
| 6221 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6222 | |
| 6223 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6224 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6225 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6226 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6227 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6228 | FAIL() << "Did not receive Error 'vkCreateImageView called with " |
| 6229 | "baseMipLevel 10...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6230 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6231 | } |
| 6232 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6233 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6234 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 6235 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6236 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6237 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6238 | "vkCreateImageView: Color image " |
| 6239 | "formats must have ONLY the " |
| 6240 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6241 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6242 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6243 | |
| 6244 | // 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] | 6245 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6246 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6247 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6248 | const int32_t tex_width = 32; |
| 6249 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6250 | |
| 6251 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6252 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6253 | image_create_info.pNext = NULL; |
| 6254 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6255 | image_create_info.format = tex_format; |
| 6256 | image_create_info.extent.width = tex_width; |
| 6257 | image_create_info.extent.height = tex_height; |
| 6258 | image_create_info.extent.depth = 1; |
| 6259 | image_create_info.mipLevels = 1; |
| 6260 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6261 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6262 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6263 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6264 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6265 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6266 | ASSERT_VK_SUCCESS(err); |
| 6267 | |
| 6268 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6269 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6270 | image_view_create_info.image = image; |
| 6271 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6272 | image_view_create_info.format = tex_format; |
| 6273 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 6274 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6275 | // Cause an error by setting an invalid image aspect |
| 6276 | image_view_create_info.subresourceRange.aspectMask = |
| 6277 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6278 | |
| 6279 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6280 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6281 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6282 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6283 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6284 | FAIL() << "Did not receive Error 'VkCreateImageView: Color image " |
| 6285 | "formats must have ...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6286 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6287 | } |
| 6288 | } |
| 6289 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6290 | TEST_F(VkLayerTest, CopyImageTypeMismatch) { |
| 6291 | VkResult err; |
| 6292 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6293 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6294 | m_errorMonitor->SetDesiredFailureMsg( |
| 6295 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6296 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 6297 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6298 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6299 | |
| 6300 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6301 | VkImage srcImage; |
| 6302 | VkImage dstImage; |
| 6303 | VkDeviceMemory srcMem; |
| 6304 | VkDeviceMemory destMem; |
| 6305 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6306 | |
| 6307 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6308 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6309 | image_create_info.pNext = NULL; |
| 6310 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6311 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6312 | image_create_info.extent.width = 32; |
| 6313 | image_create_info.extent.height = 32; |
| 6314 | image_create_info.extent.depth = 1; |
| 6315 | image_create_info.mipLevels = 1; |
| 6316 | image_create_info.arrayLayers = 1; |
| 6317 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6318 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6319 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6320 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6321 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6322 | err = |
| 6323 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6324 | ASSERT_VK_SUCCESS(err); |
| 6325 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6326 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6327 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6328 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6329 | err = |
| 6330 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6331 | ASSERT_VK_SUCCESS(err); |
| 6332 | |
| 6333 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6334 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6335 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6336 | memAlloc.pNext = NULL; |
| 6337 | memAlloc.allocationSize = 0; |
| 6338 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6339 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6340 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6341 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6342 | pass = |
| 6343 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6344 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6345 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6346 | ASSERT_VK_SUCCESS(err); |
| 6347 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6348 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6349 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6350 | pass = |
| 6351 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6352 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6353 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6354 | ASSERT_VK_SUCCESS(err); |
| 6355 | |
| 6356 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6357 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6358 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6359 | ASSERT_VK_SUCCESS(err); |
| 6360 | |
| 6361 | BeginCommandBuffer(); |
| 6362 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6363 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6364 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6365 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6366 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6367 | copyRegion.srcOffset.x = 0; |
| 6368 | copyRegion.srcOffset.y = 0; |
| 6369 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6370 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6371 | copyRegion.dstSubresource.mipLevel = 0; |
| 6372 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6373 | copyRegion.dstSubresource.layerCount = 0; |
| 6374 | copyRegion.dstOffset.x = 0; |
| 6375 | copyRegion.dstOffset.y = 0; |
| 6376 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6377 | copyRegion.extent.width = 1; |
| 6378 | copyRegion.extent.height = 1; |
| 6379 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6380 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6381 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6382 | EndCommandBuffer(); |
| 6383 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6384 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6385 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched " |
| 6386 | "source and dest image types'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6387 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6388 | } |
| 6389 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6390 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6391 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6392 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6393 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6394 | } |
| 6395 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6396 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
| 6397 | // TODO : Create two images with different format sizes and vkCmdCopyImage |
| 6398 | // between them |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6399 | } |
| 6400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6401 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 6402 | VkResult err; |
| 6403 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6404 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6405 | m_errorMonitor->SetDesiredFailureMsg( |
| 6406 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6407 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 6408 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6409 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6410 | |
| 6411 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6412 | VkImage srcImage; |
| 6413 | VkImage dstImage; |
| 6414 | VkDeviceMemory srcMem; |
| 6415 | VkDeviceMemory destMem; |
| 6416 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6417 | |
| 6418 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6419 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6420 | image_create_info.pNext = NULL; |
| 6421 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6422 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6423 | image_create_info.extent.width = 32; |
| 6424 | image_create_info.extent.height = 32; |
| 6425 | image_create_info.extent.depth = 1; |
| 6426 | image_create_info.mipLevels = 1; |
| 6427 | image_create_info.arrayLayers = 1; |
| 6428 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6429 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6430 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6431 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6432 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6433 | err = |
| 6434 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6435 | ASSERT_VK_SUCCESS(err); |
| 6436 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6437 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6438 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6439 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6440 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6441 | err = |
| 6442 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6443 | ASSERT_VK_SUCCESS(err); |
| 6444 | |
| 6445 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6446 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6447 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6448 | memAlloc.pNext = NULL; |
| 6449 | memAlloc.allocationSize = 0; |
| 6450 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6451 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6452 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6453 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6454 | pass = |
| 6455 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6456 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6457 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6458 | ASSERT_VK_SUCCESS(err); |
| 6459 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6460 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6461 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6462 | pass = |
| 6463 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6464 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6465 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6466 | ASSERT_VK_SUCCESS(err); |
| 6467 | |
| 6468 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6469 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6470 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6471 | ASSERT_VK_SUCCESS(err); |
| 6472 | |
| 6473 | BeginCommandBuffer(); |
| 6474 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6475 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6476 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6477 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6478 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6479 | copyRegion.srcOffset.x = 0; |
| 6480 | copyRegion.srcOffset.y = 0; |
| 6481 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6482 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6483 | copyRegion.dstSubresource.mipLevel = 0; |
| 6484 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6485 | copyRegion.dstSubresource.layerCount = 0; |
| 6486 | copyRegion.dstOffset.x = 0; |
| 6487 | copyRegion.dstOffset.y = 0; |
| 6488 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6489 | copyRegion.extent.width = 1; |
| 6490 | copyRegion.extent.height = 1; |
| 6491 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6492 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6493 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6494 | EndCommandBuffer(); |
| 6495 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6496 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6497 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched " |
| 6498 | "source and dest image types'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6499 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6500 | } |
| 6501 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6502 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6503 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6504 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6505 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6506 | } |
| 6507 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6508 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 6509 | VkResult err; |
| 6510 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6511 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6512 | m_errorMonitor->SetDesiredFailureMsg( |
| 6513 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6514 | "vkCmdResolveImage called with source sample count less than 2."); |
| 6515 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6516 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6517 | |
| 6518 | // 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] | 6519 | VkImage srcImage; |
| 6520 | VkImage dstImage; |
| 6521 | VkDeviceMemory srcMem; |
| 6522 | VkDeviceMemory destMem; |
| 6523 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6524 | |
| 6525 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6526 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6527 | image_create_info.pNext = NULL; |
| 6528 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6529 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6530 | image_create_info.extent.width = 32; |
| 6531 | image_create_info.extent.height = 1; |
| 6532 | image_create_info.extent.depth = 1; |
| 6533 | image_create_info.mipLevels = 1; |
| 6534 | image_create_info.arrayLayers = 1; |
| 6535 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6536 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6537 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6538 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6539 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6540 | err = |
| 6541 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6542 | ASSERT_VK_SUCCESS(err); |
| 6543 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6544 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6545 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6546 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6547 | err = |
| 6548 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6549 | ASSERT_VK_SUCCESS(err); |
| 6550 | |
| 6551 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6552 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6553 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6554 | memAlloc.pNext = NULL; |
| 6555 | memAlloc.allocationSize = 0; |
| 6556 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6557 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6558 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6559 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6560 | pass = |
| 6561 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6562 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6563 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6564 | ASSERT_VK_SUCCESS(err); |
| 6565 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6566 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6567 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6568 | pass = |
| 6569 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6570 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6571 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6572 | ASSERT_VK_SUCCESS(err); |
| 6573 | |
| 6574 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6575 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6576 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6577 | ASSERT_VK_SUCCESS(err); |
| 6578 | |
| 6579 | BeginCommandBuffer(); |
| 6580 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6581 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6582 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6583 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6584 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6585 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6586 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6587 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6588 | resolveRegion.srcOffset.x = 0; |
| 6589 | resolveRegion.srcOffset.y = 0; |
| 6590 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6591 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6592 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6593 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6594 | resolveRegion.dstSubresource.layerCount = 0; |
| 6595 | resolveRegion.dstOffset.x = 0; |
| 6596 | resolveRegion.dstOffset.y = 0; |
| 6597 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6598 | resolveRegion.extent.width = 1; |
| 6599 | resolveRegion.extent.height = 1; |
| 6600 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6601 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6602 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6603 | EndCommandBuffer(); |
| 6604 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6605 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6606 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with source " |
| 6607 | "sample count less than 2.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6608 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6609 | } |
| 6610 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6611 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6612 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6613 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6614 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6615 | } |
| 6616 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6617 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 6618 | VkResult err; |
| 6619 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6620 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6621 | m_errorMonitor->SetDesiredFailureMsg( |
| 6622 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6623 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 6624 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6625 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6626 | |
| 6627 | // 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] | 6628 | VkImage srcImage; |
| 6629 | VkImage dstImage; |
| 6630 | VkDeviceMemory srcMem; |
| 6631 | VkDeviceMemory destMem; |
| 6632 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6633 | |
| 6634 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6635 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6636 | image_create_info.pNext = NULL; |
| 6637 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6638 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6639 | image_create_info.extent.width = 32; |
| 6640 | image_create_info.extent.height = 1; |
| 6641 | image_create_info.extent.depth = 1; |
| 6642 | image_create_info.mipLevels = 1; |
| 6643 | image_create_info.arrayLayers = 1; |
| 6644 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6645 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6646 | // Note: Some implementations expect color attachment usage for any |
| 6647 | // multisample surface |
| 6648 | image_create_info.usage = |
| 6649 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6650 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6651 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6652 | err = |
| 6653 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6654 | ASSERT_VK_SUCCESS(err); |
| 6655 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6656 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6657 | // Note: Some implementations expect color attachment usage for any |
| 6658 | // multisample surface |
| 6659 | image_create_info.usage = |
| 6660 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6661 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6662 | err = |
| 6663 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6664 | ASSERT_VK_SUCCESS(err); |
| 6665 | |
| 6666 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6667 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6668 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6669 | memAlloc.pNext = NULL; |
| 6670 | memAlloc.allocationSize = 0; |
| 6671 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6672 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6673 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6674 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6675 | pass = |
| 6676 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6677 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6678 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6679 | ASSERT_VK_SUCCESS(err); |
| 6680 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6681 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6682 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6683 | pass = |
| 6684 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6685 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6686 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6687 | ASSERT_VK_SUCCESS(err); |
| 6688 | |
| 6689 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6690 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6691 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6692 | ASSERT_VK_SUCCESS(err); |
| 6693 | |
| 6694 | BeginCommandBuffer(); |
| 6695 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6696 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6697 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6698 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6699 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6700 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6701 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6702 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6703 | resolveRegion.srcOffset.x = 0; |
| 6704 | resolveRegion.srcOffset.y = 0; |
| 6705 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6706 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6707 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6708 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6709 | resolveRegion.dstSubresource.layerCount = 0; |
| 6710 | resolveRegion.dstOffset.x = 0; |
| 6711 | resolveRegion.dstOffset.y = 0; |
| 6712 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6713 | resolveRegion.extent.width = 1; |
| 6714 | resolveRegion.extent.height = 1; |
| 6715 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6716 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6717 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6718 | EndCommandBuffer(); |
| 6719 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6720 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6721 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with dest " |
| 6722 | "sample count greater than 1.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6723 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6724 | } |
| 6725 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6726 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6727 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6728 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6729 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6730 | } |
| 6731 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6732 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 6733 | VkResult err; |
| 6734 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6735 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6736 | m_errorMonitor->SetDesiredFailureMsg( |
| 6737 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6738 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 6739 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6740 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6741 | |
| 6742 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6743 | VkImage srcImage; |
| 6744 | VkImage dstImage; |
| 6745 | VkDeviceMemory srcMem; |
| 6746 | VkDeviceMemory destMem; |
| 6747 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6748 | |
| 6749 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6750 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6751 | image_create_info.pNext = NULL; |
| 6752 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6753 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6754 | image_create_info.extent.width = 32; |
| 6755 | image_create_info.extent.height = 1; |
| 6756 | image_create_info.extent.depth = 1; |
| 6757 | image_create_info.mipLevels = 1; |
| 6758 | image_create_info.arrayLayers = 1; |
| 6759 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6760 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6761 | // Note: Some implementations expect color attachment usage for any |
| 6762 | // multisample surface |
| 6763 | image_create_info.usage = |
| 6764 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6765 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6766 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6767 | err = |
| 6768 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6769 | ASSERT_VK_SUCCESS(err); |
| 6770 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6771 | // Set format to something other than source image |
| 6772 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 6773 | // Note: Some implementations expect color attachment usage for any |
| 6774 | // multisample surface |
| 6775 | image_create_info.usage = |
| 6776 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6777 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6778 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6779 | err = |
| 6780 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6781 | ASSERT_VK_SUCCESS(err); |
| 6782 | |
| 6783 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6784 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6785 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6786 | memAlloc.pNext = NULL; |
| 6787 | memAlloc.allocationSize = 0; |
| 6788 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6789 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6790 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6791 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6792 | pass = |
| 6793 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6794 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6795 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6796 | ASSERT_VK_SUCCESS(err); |
| 6797 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6798 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6799 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6800 | pass = |
| 6801 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6802 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6803 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6804 | ASSERT_VK_SUCCESS(err); |
| 6805 | |
| 6806 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6807 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6808 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6809 | ASSERT_VK_SUCCESS(err); |
| 6810 | |
| 6811 | BeginCommandBuffer(); |
| 6812 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6813 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6814 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6815 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6816 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6817 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6818 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6819 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6820 | resolveRegion.srcOffset.x = 0; |
| 6821 | resolveRegion.srcOffset.y = 0; |
| 6822 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6823 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6824 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6825 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6826 | resolveRegion.dstSubresource.layerCount = 0; |
| 6827 | resolveRegion.dstOffset.x = 0; |
| 6828 | resolveRegion.dstOffset.y = 0; |
| 6829 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6830 | resolveRegion.extent.width = 1; |
| 6831 | resolveRegion.extent.height = 1; |
| 6832 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6833 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6834 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6835 | EndCommandBuffer(); |
| 6836 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6837 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6838 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with " |
| 6839 | "unmatched source and dest formats.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6840 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6841 | } |
| 6842 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6843 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6844 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6845 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6846 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6847 | } |
| 6848 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6849 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 6850 | VkResult err; |
| 6851 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6852 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6853 | m_errorMonitor->SetDesiredFailureMsg( |
| 6854 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6855 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 6856 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6857 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6858 | |
| 6859 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6860 | VkImage srcImage; |
| 6861 | VkImage dstImage; |
| 6862 | VkDeviceMemory srcMem; |
| 6863 | VkDeviceMemory destMem; |
| 6864 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6865 | |
| 6866 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6867 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6868 | image_create_info.pNext = NULL; |
| 6869 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6870 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6871 | image_create_info.extent.width = 32; |
| 6872 | image_create_info.extent.height = 1; |
| 6873 | image_create_info.extent.depth = 1; |
| 6874 | image_create_info.mipLevels = 1; |
| 6875 | image_create_info.arrayLayers = 1; |
| 6876 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6877 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6878 | // Note: Some implementations expect color attachment usage for any |
| 6879 | // multisample surface |
| 6880 | image_create_info.usage = |
| 6881 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6882 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6883 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6884 | err = |
| 6885 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6886 | ASSERT_VK_SUCCESS(err); |
| 6887 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6888 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6889 | // Note: Some implementations expect color attachment usage for any |
| 6890 | // multisample surface |
| 6891 | image_create_info.usage = |
| 6892 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6893 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6894 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6895 | err = |
| 6896 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6897 | ASSERT_VK_SUCCESS(err); |
| 6898 | |
| 6899 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6900 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6901 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6902 | memAlloc.pNext = NULL; |
| 6903 | memAlloc.allocationSize = 0; |
| 6904 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6905 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6906 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6907 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6908 | pass = |
| 6909 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6910 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6911 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6912 | ASSERT_VK_SUCCESS(err); |
| 6913 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6914 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6915 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6916 | pass = |
| 6917 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6918 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6919 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6920 | ASSERT_VK_SUCCESS(err); |
| 6921 | |
| 6922 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6923 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6924 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6925 | ASSERT_VK_SUCCESS(err); |
| 6926 | |
| 6927 | BeginCommandBuffer(); |
| 6928 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6929 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6930 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6931 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6932 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6933 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6934 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6935 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6936 | resolveRegion.srcOffset.x = 0; |
| 6937 | resolveRegion.srcOffset.y = 0; |
| 6938 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6939 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6940 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6941 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6942 | resolveRegion.dstSubresource.layerCount = 0; |
| 6943 | resolveRegion.dstOffset.x = 0; |
| 6944 | resolveRegion.dstOffset.y = 0; |
| 6945 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6946 | resolveRegion.extent.width = 1; |
| 6947 | resolveRegion.extent.height = 1; |
| 6948 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6949 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6950 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6951 | EndCommandBuffer(); |
| 6952 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6953 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6954 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with " |
| 6955 | "unmatched source and dest image types.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6956 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6957 | } |
| 6958 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6959 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6960 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6961 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6962 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6963 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6964 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6965 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6966 | // 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] | 6967 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 6968 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6969 | // The image format check comes 2nd in validation so we trigger it first, |
| 6970 | // 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] | 6971 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6972 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6973 | m_errorMonitor->SetDesiredFailureMsg( |
| 6974 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6975 | "Combination depth/stencil image formats can have only the "); |
| 6976 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6977 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6978 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6979 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6980 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 6981 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6982 | |
| 6983 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6984 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6985 | ds_pool_ci.pNext = NULL; |
| 6986 | ds_pool_ci.maxSets = 1; |
| 6987 | ds_pool_ci.poolSizeCount = 1; |
| 6988 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6989 | |
| 6990 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6991 | err = |
| 6992 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6993 | ASSERT_VK_SUCCESS(err); |
| 6994 | |
| 6995 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6996 | dsl_binding.binding = 0; |
| 6997 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 6998 | dsl_binding.descriptorCount = 1; |
| 6999 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7000 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7001 | |
| 7002 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7003 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7004 | ds_layout_ci.pNext = NULL; |
| 7005 | ds_layout_ci.bindingCount = 1; |
| 7006 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7007 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7008 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7009 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7010 | ASSERT_VK_SUCCESS(err); |
| 7011 | |
| 7012 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7013 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7014 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7015 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7016 | alloc_info.descriptorPool = ds_pool; |
| 7017 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7018 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7019 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7020 | ASSERT_VK_SUCCESS(err); |
| 7021 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7022 | VkImage image_bad; |
| 7023 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7024 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7025 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7026 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7027 | const int32_t tex_width = 32; |
| 7028 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7029 | |
| 7030 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7031 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7032 | image_create_info.pNext = NULL; |
| 7033 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7034 | image_create_info.format = tex_format_bad; |
| 7035 | image_create_info.extent.width = tex_width; |
| 7036 | image_create_info.extent.height = tex_height; |
| 7037 | image_create_info.extent.depth = 1; |
| 7038 | image_create_info.mipLevels = 1; |
| 7039 | image_create_info.arrayLayers = 1; |
| 7040 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7041 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7042 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 7043 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 7044 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7045 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7046 | err = |
| 7047 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7048 | ASSERT_VK_SUCCESS(err); |
| 7049 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7050 | image_create_info.usage = |
| 7051 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 7052 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 7053 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7054 | ASSERT_VK_SUCCESS(err); |
| 7055 | |
| 7056 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7057 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7058 | image_view_create_info.image = image_bad; |
| 7059 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7060 | image_view_create_info.format = tex_format_bad; |
| 7061 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 7062 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 7063 | image_view_create_info.subresourceRange.layerCount = 1; |
| 7064 | image_view_create_info.subresourceRange.levelCount = 1; |
| 7065 | image_view_create_info.subresourceRange.aspectMask = |
| 7066 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7067 | |
| 7068 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7069 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 7070 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7071 | |
| 7072 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7073 | FAIL() << "Did not receive Error 'Combination depth-stencil image " |
| 7074 | "formats can have only the....'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7075 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7076 | } |
| 7077 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7078 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 7079 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7080 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7081 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7082 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7083 | #endif // IMAGE_TESTS |
| 7084 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7085 | int main(int argc, char **argv) { |
| 7086 | int result; |
| 7087 | |
| 7088 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 7089 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7090 | |
| 7091 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 7092 | |
| 7093 | result = RUN_ALL_TESTS(); |
| 7094 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 7095 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7096 | return result; |
| 7097 | } |