Karl Schultz | 99e9d1d | 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 | 584ccab | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5 | * Copyright (c) 2015-2016 Google, Inc. |
Karl Schultz | 99e9d1d | 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 | 99e9d1d | 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 | d04e8df | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 34 | |
Cody Northrop | 50537d0 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 35 | #ifdef ANDROID |
| 36 | #include "vulkan_wrapper.h" |
| 37 | #else |
David Pinedo | 329ca9e | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 38 | #include <vulkan/vulkan.h> |
Cody Northrop | 50537d0 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 39 | #endif |
Courtney Goeltzenleuchter | 0abdb66 | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 40 | #include "test_common.h" |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 41 | #include "vkrenderframework.h" |
Tobin Ehlis | 56d204a | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 42 | #include "vk_layer_config.h" |
Jon Ashburn | 3510b19 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 43 | #include "icd-spv.h" |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | #define GLM_FORCE_RADIANS |
| 46 | #include "glm/glm.hpp" |
| 47 | #include <glm/gtc/matrix_transform.hpp> |
| 48 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 49 | #define MEM_TRACKER_TESTS 1 |
| 50 | #define OBJ_TRACKER_TESTS 1 |
| 51 | #define DRAW_STATE_TESTS 1 |
| 52 | #define THREADING_TESTS 1 |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 53 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 54 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 55 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 56 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 57 | //-------------------------------------------------------------------------------------- |
| 58 | // Mesh and VertexFormat Data |
| 59 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 60 | struct Vertex { |
| 61 | float posX, posY, posZ, posW; // Position data |
| 62 | float r, g, b, a; // Color |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 63 | }; |
| 64 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 65 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 66 | |
| 67 | typedef enum _BsoFailSelect { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 68 | BsoFailNone = 0x00000000, |
| 69 | BsoFailLineWidth = 0x00000001, |
| 70 | BsoFailDepthBias = 0x00000002, |
| 71 | BsoFailViewport = 0x00000004, |
| 72 | BsoFailScissor = 0x00000008, |
| 73 | BsoFailBlend = 0x00000010, |
| 74 | BsoFailDepthBounds = 0x00000020, |
| 75 | BsoFailStencilReadMask = 0x00000040, |
| 76 | BsoFailStencilWriteMask = 0x00000080, |
| 77 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 78 | } BsoFailSelect; |
| 79 | |
| 80 | struct vktriangle_vs_uniform { |
| 81 | // Must start with MVP |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 82 | float mvp[4][4]; |
| 83 | float position[3][4]; |
| 84 | float color[3][4]; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 85 | }; |
| 86 | |
Mark Lobodzinski | 6bbdff1 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 87 | static const char bindStateVertShaderText[] = |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 88 | "#version 400\n" |
| 89 | "#extension GL_ARB_separate_shader_objects : require\n" |
| 90 | "#extension GL_ARB_shading_language_420pack : require\n" |
| 91 | "vec2 vertices[3];\n" |
| 92 | "out gl_PerVertex {\n" |
| 93 | " vec4 gl_Position;\n" |
| 94 | "};\n" |
| 95 | "void main() {\n" |
| 96 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 97 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 98 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 99 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 100 | "}\n"; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 101 | |
Mark Lobodzinski | 6bbdff1 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 102 | static const char bindStateFragShaderText[] = |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 103 | "#version 400\n" |
| 104 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 105 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 106 | "\n" |
| 107 | "layout(location = 0) out vec4 uFragColor;\n" |
| 108 | "void main(){\n" |
| 109 | " uFragColor = vec4(0,1,0,1);\n" |
| 110 | "}\n"; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 111 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 112 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 113 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 114 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 115 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 116 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 117 | // ******************************************************** |
| 118 | // ErrorMonitor Usage: |
| 119 | // |
| 120 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 121 | // encountered log messages. Passing NULL will match all log messages. |
| 122 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 123 | // |
| 124 | // Call DesiredMsgFound to determine if the desired failure message |
| 125 | // was encountered. |
| 126 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 127 | class ErrorMonitor { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 128 | public: |
| 129 | ErrorMonitor() { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 130 | test_platform_thread_create_mutex(&m_mutex); |
| 131 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 132 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 133 | m_bailout = NULL; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 134 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 135 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 136 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 137 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 138 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 139 | m_desiredMsg.clear(); |
| 140 | m_failureMsg.clear(); |
| 141 | m_otherMsgs.clear(); |
| 142 | m_desiredMsg = msgString; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 143 | m_msgFound = VK_FALSE; |
| 144 | m_msgFlags = msgFlags; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 145 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 146 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 147 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 148 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 149 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 150 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 151 | if (m_bailout != NULL) { |
| 152 | *m_bailout = true; |
| 153 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 154 | string errorString(msgString); |
| 155 | if (msgFlags & m_msgFlags) { |
| 156 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | e8aa35e | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 157 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 158 | m_otherMsgs.push_back(m_failureMsg); |
| 159 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 160 | m_failureMsg = errorString; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 161 | m_msgFound = VK_TRUE; |
| 162 | result = VK_TRUE; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 163 | } else { |
| 164 | m_otherMsgs.push_back(errorString); |
| 165 | } |
| 166 | } |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 167 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 168 | return result; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 169 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 170 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 171 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 172 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 173 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 174 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 175 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 176 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 177 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 178 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 179 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 180 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 181 | cout << "Other error messages logged for this test were:" << endl; |
| 182 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 183 | cout << " " << *iter << endl; |
| 184 | } |
| 185 | } |
| 186 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 187 | private: |
| 188 | VkFlags m_msgFlags; |
| 189 | string m_desiredMsg; |
| 190 | string m_failureMsg; |
| 191 | vector<string> m_otherMsgs; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 192 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 193 | bool *m_bailout; |
| 194 | VkBool32 m_msgFound; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 195 | }; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 196 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 197 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 198 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 199 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 200 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 201 | if (msgFlags & |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 202 | (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 203 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 204 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 205 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 206 | } |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 207 | return false; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 208 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 209 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 210 | class VkLayerTest : public VkRenderFramework { |
| 211 | public: |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 212 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 213 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 214 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 215 | BsoFailSelect failMask); |
| 216 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 217 | VkPipelineObj &pipelineobj, |
| 218 | VkDescriptorSetObj &descriptorSet, |
| 219 | BsoFailSelect failMask); |
| 220 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 221 | VkDescriptorSetObj &descriptorSet, |
| 222 | BsoFailSelect failMask) { |
| 223 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 224 | failMask); |
| 225 | } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 226 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 227 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 228 | VkResult BeginCommandBuffer() { |
| 229 | return BeginCommandBuffer(*m_commandBuffer); |
| 230 | } |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 231 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 232 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 233 | uint32_t firstVertex, uint32_t firstInstance) { |
| 234 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 235 | firstInstance); |
| 236 | } |
| 237 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 238 | uint32_t firstIndex, int32_t vertexOffset, |
| 239 | uint32_t firstInstance) { |
| 240 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 241 | vertexOffset, firstInstance); |
| 242 | } |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 243 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 244 | void QueueCommandBuffer(const VkFence &fence) { |
| 245 | m_commandBuffer->QueueCommandBuffer(fence); |
| 246 | } |
| 247 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 248 | VkDeviceSize offset, uint32_t binding) { |
| 249 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 250 | } |
| 251 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 252 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 253 | } |
| 254 | |
| 255 | protected: |
| 256 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 257 | |
| 258 | virtual void SetUp() { |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 259 | std::vector<const char *> instance_layer_names; |
| 260 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 261 | std::vector<const char *> instance_extension_names; |
| 262 | std::vector<const char *> device_extension_names; |
Tony Barbour | 950ebc0 | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 263 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 264 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | de53c5b | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 265 | /* |
| 266 | * Since CreateDbgMsgCallback is an instance level extension call |
| 267 | * any extension / layer that utilizes that feature also needs |
| 268 | * to be enabled at create instance time. |
| 269 | */ |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 270 | // Use Threading layer first to protect others from |
| 271 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | c6c611a | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 272 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 3e09395 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 273 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 5d96e52 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 274 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | 5b5e7bc | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 275 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 5d96e52 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 276 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 277 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Dustin Graves | 73cfdff | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 278 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | 23b5f8d | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 279 | |
Courtney Goeltzenleuchter | c6c611a | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 280 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 3e09395 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 281 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 5d96e52 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 282 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | 5b5e7bc | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 283 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 5d96e52 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 284 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 285 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Dustin Graves | 73cfdff | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 286 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 287 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 288 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 289 | this->app_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 290 | this->app_info.pApplicationName = "layer_tests"; |
| 291 | this->app_info.applicationVersion = 1; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 292 | this->app_info.pEngineName = "unittest"; |
| 293 | this->app_info.engineVersion = 1; |
Jon Ashburn | d3995c9 | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 294 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 295 | |
Tony Barbour | 0c1bdc6 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 296 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 297 | InitFramework(instance_layer_names, device_layer_names, |
| 298 | instance_extension_names, device_extension_names, |
| 299 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | virtual void TearDown() { |
| 303 | // Clean up resources before we reset |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 304 | ShutdownFramework(); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 305 | delete m_errorMonitor; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 306 | } |
| 307 | }; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 308 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 309 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 310 | VkResult result; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 311 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 312 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 313 | |
| 314 | /* |
| 315 | * For render test all drawing happens in a single render pass |
| 316 | * on a single command buffer. |
| 317 | */ |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 318 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 319 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | return result; |
| 323 | } |
| 324 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 325 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 326 | VkResult result; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 327 | |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 328 | if (renderPass()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 329 | commandBuffer.EndRenderPass(); |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 330 | } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 331 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 332 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 333 | |
| 334 | return result; |
| 335 | } |
| 336 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 337 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 338 | const char *fragShaderText, |
| 339 | BsoFailSelect failMask) { |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 340 | // Create identity matrix |
| 341 | int i; |
| 342 | struct vktriangle_vs_uniform data; |
| 343 | |
| 344 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 345 | glm::mat4 View = glm::mat4(1.0f); |
| 346 | glm::mat4 Model = glm::mat4(1.0f); |
| 347 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 348 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 349 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 350 | |
| 351 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 352 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 353 | static const Vertex tri_data[] = { |
| 354 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 355 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 356 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 357 | }; |
| 358 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 359 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 360 | data.position[i][0] = tri_data[i].posX; |
| 361 | data.position[i][1] = tri_data[i].posY; |
| 362 | data.position[i][2] = tri_data[i].posZ; |
| 363 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 364 | data.color[i][0] = tri_data[i].r; |
| 365 | data.color[i][1] = tri_data[i].g; |
| 366 | data.color[i][2] = tri_data[i].b; |
| 367 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 371 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 372 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 373 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 374 | (const void *)&data); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 375 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 376 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 377 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 378 | this); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 379 | |
| 380 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 381 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 382 | pipelineobj.AddShader(&vs); |
| 383 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 384 | if (failMask & BsoFailLineWidth) { |
| 385 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 3d3e06b | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 386 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 387 | ia_state.sType = |
| 388 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 389 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 390 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 391 | } |
| 392 | if (failMask & BsoFailDepthBias) { |
| 393 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 3d3e06b | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 394 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 395 | rs_state.sType = |
| 396 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 397 | rs_state.depthBiasEnable = VK_TRUE; |
| 398 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 399 | } |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 400 | // Viewport and scissors must stay in synch or other errors will occur than |
| 401 | // the ones we want |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 402 | if (failMask & BsoFailViewport) { |
| 403 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 404 | m_viewports.clear(); |
| 405 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 406 | } |
| 407 | if (failMask & BsoFailScissor) { |
| 408 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 409 | m_scissors.clear(); |
| 410 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 411 | } |
| 412 | if (failMask & BsoFailBlend) { |
| 413 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 3d3e06b | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 414 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 415 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 416 | att_state.blendEnable = VK_TRUE; |
| 417 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 418 | } |
| 419 | if (failMask & BsoFailDepthBounds) { |
| 420 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 421 | } |
| 422 | if (failMask & BsoFailStencilReadMask) { |
| 423 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 424 | } |
| 425 | if (failMask & BsoFailStencilWriteMask) { |
| 426 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 427 | } |
| 428 | if (failMask & BsoFailStencilReference) { |
| 429 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 430 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 431 | |
| 432 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 433 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 434 | constantBuffer); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 435 | |
| 436 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 437 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 438 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 439 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 440 | |
| 441 | // render triangle |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 442 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 443 | |
| 444 | // finalize recording of the command buffer |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 445 | EndCommandBuffer(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 446 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 447 | QueueCommandBuffer(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 448 | } |
| 449 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 450 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 451 | VkPipelineObj &pipelineobj, |
| 452 | VkDescriptorSetObj &descriptorSet, |
| 453 | BsoFailSelect failMask) { |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 454 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 455 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 456 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 457 | } else { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 458 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 459 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 460 | } |
| 461 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 462 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 463 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 464 | // correctly |
| 465 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 466 | // correctly |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 467 | VkStencilOpState stencil = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 468 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 469 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 470 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 471 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 472 | |
| 473 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 474 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 475 | ds_ci.pNext = NULL; |
| 476 | ds_ci.depthTestEnable = VK_FALSE; |
| 477 | ds_ci.depthWriteEnable = VK_TRUE; |
| 478 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 479 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 3d3e06b | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 480 | if (failMask & BsoFailDepthBounds) { |
| 481 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
| 482 | } |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 483 | ds_ci.stencilTestEnable = VK_TRUE; |
| 484 | ds_ci.front = stencil; |
| 485 | ds_ci.back = stencil; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 486 | |
Tobin Ehlis | 40e9f52 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 487 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 488 | pipelineobj.SetViewport(m_viewports); |
| 489 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 490 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 491 | VkResult err = pipelineobj.CreateVKPipeline( |
| 492 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | ccfa96d | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 493 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 494 | commandBuffer->BindPipeline(pipelineobj); |
| 495 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | // ******************************************************************************************************************** |
| 499 | // ******************************************************************************************************************** |
| 500 | // ******************************************************************************************************************** |
| 501 | // ******************************************************************************************************************** |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 502 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 503 | #if 0 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 504 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 505 | { |
| 506 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 507 | VkFenceCreateInfo fenceInfo = {}; |
| 508 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 509 | fenceInfo.pNext = NULL; |
| 510 | fenceInfo.flags = 0; |
| 511 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 512 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 513 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 514 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | e389b88 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 515 | |
| 516 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 517 | vk_testing::Buffer buffer; |
| 518 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 519 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 520 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 521 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 522 | EndCommandBuffer(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 523 | |
| 524 | testFence.init(*m_device, fenceInfo); |
| 525 | |
| 526 | // Bypass framework since it does the waits automatically |
| 527 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 528 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 529 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 530 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 531 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 532 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 98ce7e0 | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 533 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 534 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 535 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 536 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 537 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 538 | |
| 539 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 540 | ASSERT_VK_SUCCESS( err ); |
| 541 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 542 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 543 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 544 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 545 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 546 | FAIL() << "Did not receive Error 'Resetting CB (0xaddress) before it has completed. You must check CB flag before.'"; |
| 547 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 548 | } |
| 549 | } |
| 550 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 551 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 552 | { |
| 553 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 554 | VkFenceCreateInfo fenceInfo = {}; |
| 555 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 556 | fenceInfo.pNext = NULL; |
| 557 | fenceInfo.flags = 0; |
| 558 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 559 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Calling vkBeginCommandBuffer() on active CB"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 560 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 561 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 562 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 563 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 564 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 565 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 566 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 567 | EndCommandBuffer(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 568 | |
| 569 | testFence.init(*m_device, fenceInfo); |
| 570 | |
| 571 | // Bypass framework since it does the waits automatically |
| 572 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 573 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 574 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 575 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 576 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 577 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 98ce7e0 | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 578 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 579 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 580 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 581 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 582 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 583 | |
| 584 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 585 | ASSERT_VK_SUCCESS( err ); |
| 586 | |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 587 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 588 | VkCommandBufferBeginInfo info = {}; |
| 589 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 590 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 591 | info.renderPass = VK_NULL_HANDLE; |
| 592 | info.subpass = 0; |
| 593 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | fdc1cd0 | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 594 | info.occlusionQueryEnable = VK_FALSE; |
| 595 | info.queryFlags = 0; |
| 596 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 597 | |
| 598 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 599 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 600 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 601 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 602 | FAIL() << "Did not receive Error 'Calling vkBeginCommandBuffer() on an active CB (0xaddress) before it has completed'"; |
| 603 | m_errorMonitor->DumpFailureMsgs(); |
| 604 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 605 | } |
| 606 | } |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 607 | #endif |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 608 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 609 | VkResult err; |
| 610 | bool pass; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 611 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 612 | m_errorMonitor->SetDesiredFailureMsg( |
| 613 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 614 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 615 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 616 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 617 | |
| 618 | // Create an image, allocate memory, free it, and then try to bind it |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 619 | VkImage image; |
| 620 | VkDeviceMemory mem; |
| 621 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 622 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 623 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 624 | const int32_t tex_width = 32; |
| 625 | const int32_t tex_height = 32; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 626 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 627 | VkImageCreateInfo image_create_info = {}; |
| 628 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 629 | image_create_info.pNext = NULL; |
| 630 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 631 | image_create_info.format = tex_format; |
| 632 | image_create_info.extent.width = tex_width; |
| 633 | image_create_info.extent.height = tex_height; |
| 634 | image_create_info.extent.depth = 1; |
| 635 | image_create_info.mipLevels = 1; |
| 636 | image_create_info.arrayLayers = 1; |
| 637 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 638 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 639 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 640 | image_create_info.flags = 0; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 641 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 642 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 643 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 644 | mem_alloc.pNext = NULL; |
| 645 | mem_alloc.allocationSize = 0; |
| 646 | // Introduce failure, do NOT set memProps to |
| 647 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 648 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 649 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 650 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 651 | ASSERT_VK_SUCCESS(err); |
| 652 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 653 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 654 | |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 655 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 656 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 657 | pass = |
| 658 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 659 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 660 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 661 | // make sense |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 662 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 49a3b65 | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 663 | return; |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 664 | } |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 665 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 666 | // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 667 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 668 | ASSERT_VK_SUCCESS(err); |
| 669 | |
| 670 | // Try to bind free memory that has been freed |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 671 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 672 | ASSERT_VK_SUCCESS(err); |
| 673 | |
| 674 | // Map memory as if to initialize the image |
| 675 | void *mappedAddress = NULL; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 676 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 677 | &mappedAddress); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 678 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 679 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 680 | FAIL() << "Did not receive Error 'Error received did not match " |
| 681 | "expected error message from vkMapMemory in MemTracker'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 682 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 683 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 684 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 685 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 686 | } |
| 687 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 688 | // TODO : Is this test still valid. Not sure it is with updates to memory |
| 689 | // binding model |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 690 | // Verify and delete the test of fix the check |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 691 | // TEST_F(VkLayerTest, FreeBoundMemory) |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 692 | //{ |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 693 | // VkResult err; |
| 694 | // |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 695 | // m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 696 | // "Freeing memory object while it still has references"); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 697 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 698 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 699 | |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 700 | // // Create an image, allocate memory, free it, and then try to bind it |
| 701 | // VkImage image; |
| 702 | // VkDeviceMemory mem; |
| 703 | // VkMemoryRequirements mem_reqs; |
| 704 | // |
| 705 | // const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 706 | // const int32_t tex_width = 32; |
| 707 | // const int32_t tex_height = 32; |
| 708 | // |
| 709 | // const VkImageCreateInfo image_create_info = { |
| 710 | // .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 711 | // .pNext = NULL, |
| 712 | // .imageType = VK_IMAGE_TYPE_2D, |
| 713 | // .format = tex_format, |
| 714 | // .extent = { tex_width, tex_height, 1 }, |
| 715 | // .mipLevels = 1, |
| 716 | // .arraySize = 1, |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 717 | // .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 718 | // .tiling = VK_IMAGE_TILING_LINEAR, |
| 719 | // .usage = VK_IMAGE_USAGE_SAMPLED_BIT, |
| 720 | // .flags = 0, |
| 721 | // }; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 722 | // VkMemoryAllocateInfo mem_alloc = { |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 723 | // .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 724 | // .pNext = NULL, |
| 725 | // .allocationSize = 0, |
| 726 | // .memoryTypeIndex = 0, |
| 727 | // }; |
| 728 | // |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 729 | // err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 730 | // ASSERT_VK_SUCCESS(err); |
| 731 | // |
| 732 | // err = vkGetImageMemoryRequirements(m_device->device(), |
| 733 | // image, |
| 734 | // &mem_reqs); |
| 735 | // ASSERT_VK_SUCCESS(err); |
| 736 | // |
| 737 | // mem_alloc.allocationSize = mem_reqs.size; |
| 738 | // |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 739 | // err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 740 | // 0); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 741 | // ASSERT_VK_SUCCESS(err); |
| 742 | // |
| 743 | // // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 744 | // err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 745 | // ASSERT_VK_SUCCESS(err); |
| 746 | // |
| 747 | // // Bind memory to Image object |
| 748 | // err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 749 | // ASSERT_VK_SUCCESS(err); |
| 750 | // |
| 751 | // // Introduce validation failure, free memory while still bound to object |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 752 | // vkFreeMemory(m_device->device(), mem, NULL); |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 753 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 754 | // if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 755 | // FAIL() << "Did not receive Warning 'Freeing memory object while it |
| 756 | // still has references'"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 757 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 758 | // } |
| 759 | //} |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 760 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 761 | TEST_F(VkLayerTest, RebindMemory) { |
| 762 | VkResult err; |
| 763 | bool pass; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 764 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 765 | m_errorMonitor->SetDesiredFailureMsg( |
| 766 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 767 | "which has already been bound to mem object"); |
| 768 | |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 769 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 770 | |
| 771 | // Create an image, allocate memory, free it, and then try to bind it |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 772 | VkImage image; |
| 773 | VkDeviceMemory mem1; |
| 774 | VkDeviceMemory mem2; |
| 775 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 776 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 777 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 778 | const int32_t tex_width = 32; |
| 779 | const int32_t tex_height = 32; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 780 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 781 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 782 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 783 | image_create_info.pNext = NULL; |
| 784 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 785 | image_create_info.format = tex_format; |
| 786 | image_create_info.extent.width = tex_width; |
| 787 | image_create_info.extent.height = tex_height; |
| 788 | image_create_info.extent.depth = 1; |
| 789 | image_create_info.mipLevels = 1; |
| 790 | image_create_info.arrayLayers = 1; |
| 791 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 792 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 793 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 794 | image_create_info.flags = 0; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 795 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 796 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 797 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 798 | mem_alloc.pNext = NULL; |
| 799 | mem_alloc.allocationSize = 0; |
| 800 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 801 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 802 | // Introduce failure, do NOT set memProps to |
| 803 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 804 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 805 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 806 | ASSERT_VK_SUCCESS(err); |
| 807 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 808 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 809 | |
| 810 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 811 | pass = |
| 812 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 813 | ASSERT_TRUE(pass); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 814 | |
| 815 | // allocate 2 memory objects |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 816 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 817 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 818 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 819 | ASSERT_VK_SUCCESS(err); |
| 820 | |
| 821 | // Bind first memory object to Image object |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 822 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 823 | ASSERT_VK_SUCCESS(err); |
| 824 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 825 | // Introduce validation failure, try to bind a different memory object to |
| 826 | // the same image object |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 827 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 828 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 829 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 830 | FAIL() << "Did not receive Error when rebinding memory to an object"; |
| 831 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 832 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 833 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 834 | vkDestroyImage(m_device->device(), image, NULL); |
| 835 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 836 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 837 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 838 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 839 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 840 | vk_testing::Fence testFence; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 841 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 842 | m_errorMonitor->SetDesiredFailureMsg( |
| 843 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 844 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 845 | |
| 846 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 847 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 848 | fenceInfo.pNext = NULL; |
| 849 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 850 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 851 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 852 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 853 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 854 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 855 | BeginCommandBuffer(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 856 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 857 | m_stencil_clear_color, NULL); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 858 | EndCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 859 | |
| 860 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 861 | |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 862 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 863 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 864 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 865 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 866 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 98ce7e0 | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 867 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 868 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 869 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 870 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 871 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 872 | |
| 873 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 874 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 875 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 876 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 877 | FAIL() << "Did not receive Error 'VkQueueSubmit with fence in " |
| 878 | "SIGNALED_STATE'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 879 | m_errorMonitor->DumpFailureMsgs(); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 880 | } |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 881 | } |
| 882 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 883 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 884 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 885 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 886 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 887 | fenceInfo.pNext = NULL; |
| 888 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 889 | // TODO: verify that this matches layer |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 890 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 891 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 892 | "submitted to VkResetFences in UNSIGNALED STATE"); |
| 893 | |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 894 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 895 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | a499234 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 896 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 897 | vkResetFences(m_device->device(), 1, fences); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 898 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 899 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 900 | FAIL() << "Did not receive Error 'VkResetFences with fence in " |
| 901 | "UNSIGNALED_STATE'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 902 | m_errorMonitor->DumpFailureMsgs(); |
| 903 | } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 904 | } |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 905 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 906 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 907 | #if 0 |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 908 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 909 | { |
| 910 | // Initiate Draw w/o a PSO bound |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 911 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 912 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 913 | "Invalid usage flag for image "); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 914 | |
| 915 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 916 | VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 917 | BeginCommandBuffer(); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 918 | |
| 919 | const VkExtent3D e3d = { |
| 920 | .width = 128, |
| 921 | .height = 128, |
| 922 | .depth = 1, |
| 923 | }; |
| 924 | const VkImageCreateInfo ici = { |
| 925 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 926 | .pNext = NULL, |
| 927 | .imageType = VK_IMAGE_TYPE_2D, |
| 928 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 929 | .extent = e3d, |
| 930 | .mipLevels = 1, |
| 931 | .arraySize = 1, |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 932 | .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 933 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | c3b8eea | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 934 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 935 | .flags = 0, |
| 936 | }; |
| 937 | |
| 938 | VkImage dsi; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 939 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 940 | VkDepthStencilView dsv; |
| 941 | const VkDepthStencilViewCreateInfo dsvci = { |
| 942 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 943 | .pNext = NULL, |
| 944 | .image = dsi, |
| 945 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 946 | .baseArrayLayer = 0, |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 947 | .arraySize = 1, |
| 948 | .flags = 0, |
| 949 | }; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 950 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 951 | |
| 952 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 953 | FAIL() << "Error received was not 'Invalid usage flag for image...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 954 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 955 | } |
| 956 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 957 | #endif // 0 |
| 958 | #endif // MEM_TRACKER_TESTS |
| 959 | |
Tobin Ehlis | 40e9f52 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 960 | #if OBJ_TRACKER_TESTS |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 961 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 962 | VkResult err; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 963 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 964 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 965 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 966 | |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 967 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 968 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 969 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 970 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 971 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 972 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 973 | |
| 974 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 975 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 976 | ds_pool_ci.pNext = NULL; |
| 977 | ds_pool_ci.maxSets = 1; |
| 978 | ds_pool_ci.poolSizeCount = 1; |
| 979 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 980 | |
| 981 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 982 | err = |
| 983 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 984 | ASSERT_VK_SUCCESS(err); |
| 985 | |
| 986 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 987 | dsl_binding.binding = 0; |
| 988 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 989 | dsl_binding.descriptorCount = 1; |
| 990 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 991 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 992 | |
| 993 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 994 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 995 | ds_layout_ci.pNext = NULL; |
| 996 | ds_layout_ci.bindingCount = 1; |
| 997 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 998 | |
| 999 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1000 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1001 | &ds_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1002 | ASSERT_VK_SUCCESS(err); |
| 1003 | |
| 1004 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1005 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1006 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1007 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1008 | alloc_info.descriptorPool = ds_pool; |
| 1009 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1010 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1011 | &descriptorSet); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1012 | ASSERT_VK_SUCCESS(err); |
| 1013 | |
| 1014 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1015 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1016 | pipeline_layout_ci.pNext = NULL; |
| 1017 | pipeline_layout_ci.setLayoutCount = 1; |
| 1018 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1019 | |
| 1020 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1021 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1022 | &pipeline_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1023 | ASSERT_VK_SUCCESS(err); |
| 1024 | |
Mark Young | cbd7c6b | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 1025 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1026 | |
| 1027 | BeginCommandBuffer(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1028 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1029 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1030 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1031 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1032 | FAIL() |
| 1033 | << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be'" |
| 1034 | << endl; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1035 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1036 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1037 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1038 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1039 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1040 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1041 | } |
| 1042 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1043 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 1044 | VkResult err; |
| 1045 | bool pass; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1046 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1047 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1048 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1049 | |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1050 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1051 | |
| 1052 | // Create an image, allocate memory, free it, and then try to bind it |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1053 | VkImage image; |
| 1054 | VkDeviceMemory mem; |
| 1055 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1056 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1057 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1058 | const int32_t tex_width = 32; |
| 1059 | const int32_t tex_height = 32; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1060 | |
| 1061 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1062 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1063 | image_create_info.pNext = NULL; |
| 1064 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1065 | image_create_info.format = tex_format; |
| 1066 | image_create_info.extent.width = tex_width; |
| 1067 | image_create_info.extent.height = tex_height; |
| 1068 | image_create_info.extent.depth = 1; |
| 1069 | image_create_info.mipLevels = 1; |
| 1070 | image_create_info.arrayLayers = 1; |
| 1071 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1072 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1073 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1074 | image_create_info.flags = 0; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1075 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1076 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1077 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1078 | mem_alloc.pNext = NULL; |
| 1079 | mem_alloc.allocationSize = 0; |
| 1080 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1081 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1082 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1083 | ASSERT_VK_SUCCESS(err); |
| 1084 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1085 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1086 | |
| 1087 | mem_alloc.allocationSize = mem_reqs.size; |
| 1088 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1089 | pass = |
| 1090 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1091 | ASSERT_TRUE(pass); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1092 | |
| 1093 | // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1094 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1095 | ASSERT_VK_SUCCESS(err); |
| 1096 | |
| 1097 | // Introduce validation failure, free memory before binding |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1098 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1099 | |
| 1100 | // Try to bind free memory that has been freed |
| 1101 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1102 | // This may very well return an error. |
| 1103 | (void)err; |
| 1104 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1105 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1106 | FAIL() << "Did not receive Error 'Invalid VkDeviceMemory Object " |
| 1107 | "0x<handle>'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1108 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1109 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1110 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1111 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1112 | } |
| 1113 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1114 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1115 | VkResult err; |
| 1116 | bool pass; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1117 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1118 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1119 | "Invalid VkImage Object "); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1120 | |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1121 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1122 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1123 | // Create an image object, allocate memory, destroy the object and then try |
| 1124 | // to bind it |
| 1125 | VkImage image; |
| 1126 | VkDeviceMemory mem; |
| 1127 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1128 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1129 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1130 | const int32_t tex_width = 32; |
| 1131 | const int32_t tex_height = 32; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1132 | |
| 1133 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1134 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1135 | image_create_info.pNext = NULL; |
| 1136 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1137 | image_create_info.format = tex_format; |
| 1138 | image_create_info.extent.width = tex_width; |
| 1139 | image_create_info.extent.height = tex_height; |
| 1140 | image_create_info.extent.depth = 1; |
| 1141 | image_create_info.mipLevels = 1; |
| 1142 | image_create_info.arrayLayers = 1; |
| 1143 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1144 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1145 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1146 | image_create_info.flags = 0; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1147 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1148 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1149 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1150 | mem_alloc.pNext = NULL; |
| 1151 | mem_alloc.allocationSize = 0; |
| 1152 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1153 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1154 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1155 | ASSERT_VK_SUCCESS(err); |
| 1156 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1157 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1158 | |
| 1159 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1160 | pass = |
| 1161 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1162 | ASSERT_TRUE(pass); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1163 | |
| 1164 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1165 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1166 | ASSERT_VK_SUCCESS(err); |
| 1167 | |
| 1168 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1169 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1170 | ASSERT_VK_SUCCESS(err); |
| 1171 | |
| 1172 | // Now Try to bind memory to this destroyed object |
| 1173 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1174 | // This may very well return an error. |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1175 | (void)err; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1176 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1177 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1178 | FAIL() << "Did not receive Error 'Invalid VkImage Object 0x<handle>'"; |
| 1179 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1180 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1181 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1182 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1183 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1184 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1185 | #endif // OBJ_TRACKER_TESTS |
| 1186 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1187 | #if DRAW_STATE_TESTS |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1188 | TEST_F(VkLayerTest, LineWidthStateNotBound) { |
| 1189 | m_errorMonitor->SetDesiredFailureMsg( |
| 1190 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1191 | "Dynamic line width state not set for this command buffer"); |
| 1192 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1193 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line " |
| 1194 | "width state object is not bound beforehand"); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1195 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1196 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1197 | BsoFailLineWidth); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1198 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1199 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1200 | FAIL() << "Did not receive Error 'Dynamic line width state not set for " |
| 1201 | "this command buffer'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1202 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1203 | } |
| 1204 | } |
| 1205 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1206 | TEST_F(VkLayerTest, DepthBiasStateNotBound) { |
| 1207 | m_errorMonitor->SetDesiredFailureMsg( |
| 1208 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1209 | "Dynamic depth bias state not set for this command buffer"); |
| 1210 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1211 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth " |
| 1212 | "bias state object is not bound beforehand"); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1213 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1214 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1215 | BsoFailDepthBias); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1216 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1217 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1218 | FAIL() << "Did not receive Error 'Dynamic depth bias state not set for " |
| 1219 | "this command buffer'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1220 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1221 | } |
| 1222 | } |
| 1223 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1224 | // Disable these two tests until we can sort out how to track multiple layer |
| 1225 | // errors |
| 1226 | TEST_F(VkLayerTest, ViewportStateNotBound) { |
| 1227 | m_errorMonitor->SetDesiredFailureMsg( |
| 1228 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1229 | "Dynamic viewport state not set for this command buffer"); |
| 1230 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1231 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport " |
| 1232 | "state object is not bound beforehand"); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1233 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1234 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1235 | BsoFailViewport); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1236 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1237 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | 3d3e06b | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 1238 | FAIL() << "Did not receive Error 'Dynamic scissor state not set for " |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1239 | "this command buffer'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1240 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1241 | } |
| 1242 | } |
| 1243 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1244 | TEST_F(VkLayerTest, ScissorStateNotBound) { |
| 1245 | m_errorMonitor->SetDesiredFailureMsg( |
| 1246 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1247 | "Dynamic scissor state not set for this command buffer"); |
| 1248 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1249 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport " |
| 1250 | "state object is not bound beforehand"); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1251 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1252 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1253 | BsoFailScissor); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1254 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1255 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | 3d3e06b | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 1256 | FAIL() << "Did not receive Error ' Expected: 'Dynamic scissor state " |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1257 | "not set for this command buffer'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1258 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1259 | } |
| 1260 | } |
| 1261 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1262 | TEST_F(VkLayerTest, BlendStateNotBound) { |
| 1263 | m_errorMonitor->SetDesiredFailureMsg( |
| 1264 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 3d3e06b | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 1265 | "Dynamic blend constants state not set for this command buffer"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1266 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1267 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend " |
| 1268 | "state object is not bound beforehand"); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1269 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1270 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1271 | BsoFailBlend); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1272 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1273 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | 3d3e06b | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 1274 | FAIL() |
| 1275 | << "Did not receive Error 'Dynamic blend constants state not set " |
| 1276 | "for this command buffer'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1277 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1278 | } |
| 1279 | } |
| 1280 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1281 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) { |
| 1282 | m_errorMonitor->SetDesiredFailureMsg( |
| 1283 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1284 | "Dynamic depth bounds state not set for this command buffer"); |
| 1285 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1286 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth " |
| 1287 | "bounds state object is not bound beforehand"); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1288 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1289 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1290 | BsoFailDepthBounds); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1291 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1292 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1293 | FAIL() << "Did not receive Error 'Dynamic depth bounds state not set " |
| 1294 | "for this command buffer'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1295 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1296 | } |
| 1297 | } |
| 1298 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1299 | TEST_F(VkLayerTest, StencilReadMaskNotSet) { |
| 1300 | m_errorMonitor->SetDesiredFailureMsg( |
| 1301 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1302 | "Dynamic stencil read mask state not set for this command buffer"); |
| 1303 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1304 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1305 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1306 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1307 | "read mask is not set beforehand"); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1308 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1309 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1310 | BsoFailStencilReadMask); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1311 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1312 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1313 | FAIL() << "Did not receive Error 'Dynamic stencil read mask state not " |
| 1314 | "set for this command buffer'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1315 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1316 | } |
| 1317 | } |
| 1318 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1319 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) { |
| 1320 | m_errorMonitor->SetDesiredFailureMsg( |
| 1321 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1322 | "Dynamic stencil write mask state not set for this command buffer"); |
| 1323 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1324 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1325 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1326 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1327 | "write mask is not set beforehand"); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1328 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1329 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1330 | BsoFailStencilWriteMask); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1331 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1332 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1333 | FAIL() << "Did not receive Error 'Dynamic stencil write mask state not " |
| 1334 | "set for this command buffer'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1335 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1336 | } |
| 1337 | } |
| 1338 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1339 | TEST_F(VkLayerTest, StencilReferenceNotSet) { |
| 1340 | m_errorMonitor->SetDesiredFailureMsg( |
| 1341 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1342 | "Dynamic stencil reference state not set for this command buffer"); |
| 1343 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1344 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1345 | "reference is not set beforehand"); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1346 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1347 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1348 | BsoFailStencilReference); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1349 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1350 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1351 | FAIL() << "Did not receive Error 'Dynamic stencil reference state not " |
| 1352 | "set for this command buffer'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1353 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1354 | } |
| 1355 | } |
| 1356 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1357 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1358 | vk_testing::Fence testFence; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1359 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1360 | m_errorMonitor->SetDesiredFailureMsg( |
| 1361 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1362 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 1363 | "been submitted"); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1364 | |
| 1365 | VkFenceCreateInfo fenceInfo = {}; |
| 1366 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1367 | fenceInfo.pNext = NULL; |
| 1368 | fenceInfo.flags = 0; |
| 1369 | |
| 1370 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1371 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1372 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1373 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1374 | // We luck out b/c by default the framework creates CB w/ the |
| 1375 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1376 | BeginCommandBuffer(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1377 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 1378 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1379 | EndCommandBuffer(); |
| 1380 | |
| 1381 | testFence.init(*m_device, fenceInfo); |
| 1382 | |
| 1383 | // Bypass framework since it does the waits automatically |
| 1384 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1385 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1386 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1387 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1388 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1389 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 98ce7e0 | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1390 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1391 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1392 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1393 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1394 | submit_info.pSignalSemaphores = NULL; |
| 1395 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1396 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 1397 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1398 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1399 | // Cause validation error by re-submitting cmd buffer that should only be |
| 1400 | // submitted once |
| 1401 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1402 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1403 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1404 | FAIL() << "Did not receive Error 'CB (0xaddress) was created w/ " |
| 1405 | "VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1406 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1407 | } |
| 1408 | } |
| 1409 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1410 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1411 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1412 | VkResult err; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1413 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1414 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1415 | "Unable to allocate 1 descriptors of " |
| 1416 | "type " |
| 1417 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1418 | |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1419 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1420 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1421 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1422 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 1423 | // descriptor from it |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1424 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1425 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1426 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1427 | |
| 1428 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1429 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1430 | ds_pool_ci.pNext = NULL; |
| 1431 | ds_pool_ci.flags = 0; |
| 1432 | ds_pool_ci.maxSets = 1; |
| 1433 | ds_pool_ci.poolSizeCount = 1; |
| 1434 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1435 | |
| 1436 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1437 | err = |
| 1438 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1439 | ASSERT_VK_SUCCESS(err); |
| 1440 | |
| 1441 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1442 | dsl_binding.binding = 0; |
| 1443 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1444 | dsl_binding.descriptorCount = 1; |
| 1445 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1446 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1447 | |
| 1448 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1449 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1450 | ds_layout_ci.pNext = NULL; |
| 1451 | ds_layout_ci.bindingCount = 1; |
| 1452 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1453 | |
| 1454 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1455 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1456 | &ds_layout); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1457 | ASSERT_VK_SUCCESS(err); |
| 1458 | |
| 1459 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1460 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1461 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1462 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1463 | alloc_info.descriptorPool = ds_pool; |
| 1464 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1465 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1466 | &descriptorSet); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1467 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1468 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1469 | FAIL() << "Did not receive Error 'Unable to allocate 1 descriptors of " |
| 1470 | "type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1471 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1472 | } |
| 1473 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1474 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1475 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1476 | } |
| 1477 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1478 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 1479 | VkResult err; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1480 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1481 | m_errorMonitor->SetDesiredFailureMsg( |
| 1482 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1483 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 1484 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1485 | |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1486 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1487 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1488 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1489 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1490 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1491 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1492 | |
| 1493 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1494 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1495 | ds_pool_ci.pNext = NULL; |
| 1496 | ds_pool_ci.maxSets = 1; |
| 1497 | ds_pool_ci.poolSizeCount = 1; |
| 1498 | ds_pool_ci.flags = 0; |
| 1499 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1500 | // app can only call vkResetDescriptorPool on this pool.; |
| 1501 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1502 | |
| 1503 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1504 | err = |
| 1505 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1506 | ASSERT_VK_SUCCESS(err); |
| 1507 | |
| 1508 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1509 | dsl_binding.binding = 0; |
| 1510 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1511 | dsl_binding.descriptorCount = 1; |
| 1512 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1513 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1514 | |
| 1515 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1516 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1517 | ds_layout_ci.pNext = NULL; |
| 1518 | ds_layout_ci.bindingCount = 1; |
| 1519 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1520 | |
| 1521 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1522 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1523 | &ds_layout); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1524 | ASSERT_VK_SUCCESS(err); |
| 1525 | |
| 1526 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1527 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1528 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1529 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1530 | alloc_info.descriptorPool = ds_pool; |
| 1531 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1532 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1533 | &descriptorSet); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1534 | ASSERT_VK_SUCCESS(err); |
| 1535 | |
| 1536 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1537 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1538 | FAIL() << "Did not receive Error 'It is invalid to call " |
| 1539 | "vkFreeDescriptorSets() with a pool created with...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1540 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1541 | } |
| 1542 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1543 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1544 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1545 | } |
| 1546 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1547 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
| 1548 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 1549 | // catch this case |
| 1550 | // The DS check for this is after driver has been called to validate DS |
| 1551 | // internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1552 | // Attempt to clear DS Pool with bad object |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1553 | /* |
| 1554 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1555 | "Unable to find pool node for pool 0xbaad6001 specified in |
| 1556 | vkResetDescriptorPool() call"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1557 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1558 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1559 | vkResetDescriptorPool(device(), badPool); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1560 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1561 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1562 | FAIL() << "Did not receive Error 'Unable to find pool node for pool |
| 1563 | 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1564 | m_errorMonitor->DumpFailureMsgs(); |
| 1565 | }*/ |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1566 | } |
| 1567 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1568 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
| 1569 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 1570 | // catch this case |
| 1571 | // The DS check for this is after driver has been called to validate DS |
| 1572 | // internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1573 | // Create a valid cmd buffer |
| 1574 | // call vkCmdBindDescriptorSets w/ false DS |
| 1575 | } |
| 1576 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1577 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
| 1578 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 1579 | // catch this case |
| 1580 | // The DS check for this is after driver has been called to validate DS |
| 1581 | // internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1582 | } |
| 1583 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1584 | TEST_F(VkLayerTest, InvalidPipeline) { |
| 1585 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 1586 | // catch this case |
| 1587 | // The DS check for this is after driver has been called to validate DS |
| 1588 | // internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1589 | // Create a valid cmd buffer |
| 1590 | // call vkCmdBindPipeline w/ false Pipeline |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1591 | // |
| 1592 | // m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1593 | // "Attempt to bind Pipeline "); |
| 1594 | // |
| 1595 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1596 | // VkCommandBufferObj commandBuffer(m_device); |
| 1597 | // BeginCommandBuffer(); |
| 1598 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 1599 | // vkCmdBindPipeline(commandBuffer.GetBufferHandle(), |
| 1600 | // VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
| 1601 | // |
| 1602 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 1603 | // FAIL() << "Did not receive Error 'Attempt to bind Pipeline |
| 1604 | // 0xbaadb1be that doesn't exist!'"; |
| 1605 | // m_errorMonitor->DumpFailureMsgs(); |
| 1606 | // } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1607 | } |
| 1608 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1609 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 1610 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 1611 | // CommandBuffer |
| 1612 | VkResult err; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1613 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1614 | // TODO: verify that this matches layer |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 1615 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1616 | " bound but it was never updated. "); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1617 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1618 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1619 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1620 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1621 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1622 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1623 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1624 | |
| 1625 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1626 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1627 | ds_pool_ci.pNext = NULL; |
| 1628 | ds_pool_ci.maxSets = 1; |
| 1629 | ds_pool_ci.poolSizeCount = 1; |
| 1630 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1631 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1632 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1633 | err = |
| 1634 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1635 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1636 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1637 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1638 | dsl_binding.binding = 0; |
| 1639 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1640 | dsl_binding.descriptorCount = 1; |
| 1641 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1642 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1643 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1644 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1645 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1646 | ds_layout_ci.pNext = NULL; |
| 1647 | ds_layout_ci.bindingCount = 1; |
| 1648 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1649 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1650 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1651 | &ds_layout); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1652 | ASSERT_VK_SUCCESS(err); |
| 1653 | |
| 1654 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1655 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1656 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1657 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1658 | alloc_info.descriptorPool = ds_pool; |
| 1659 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1660 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1661 | &descriptorSet); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1662 | ASSERT_VK_SUCCESS(err); |
| 1663 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1664 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1665 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1666 | pipeline_layout_ci.pNext = NULL; |
| 1667 | pipeline_layout_ci.setLayoutCount = 1; |
| 1668 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1669 | |
| 1670 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1671 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1672 | &pipeline_layout); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1673 | ASSERT_VK_SUCCESS(err); |
| 1674 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1675 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 1676 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1677 | // TODO - We shouldn't need a fragment shader but add it to be able to run |
| 1678 | // on more devices |
| 1679 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 1680 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1681 | |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1682 | VkPipelineObj pipe(m_device); |
| 1683 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1684 | pipe.AddShader(&fs); |
Mark Young | 0292df5 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 1685 | pipe.AddColorAttachment(); |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1686 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1687 | |
| 1688 | BeginCommandBuffer(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1689 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1690 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1691 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1692 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1693 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1694 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1695 | if (!m_errorMonitor->DesiredMsgFound()) { |
Eric Engestrom | 9bdcb23 | 2016-04-02 22:08:10 +0100 | [diff] [blame] | 1696 | FAIL() << "Did not receive Warning 'DS <blah> bound but it was never " |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1697 | "updated. You may want to either update it or not bind it.'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1698 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1699 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1700 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1701 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1702 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1703 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1704 | } |
| 1705 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1706 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1707 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1708 | VkResult err; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1709 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1710 | m_errorMonitor->SetDesiredFailureMsg( |
| 1711 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1712 | "Attempt to update descriptor with invalid bufferView "); |
| 1713 | |
| 1714 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1715 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1716 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1717 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1718 | |
| 1719 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1720 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1721 | ds_pool_ci.pNext = NULL; |
| 1722 | ds_pool_ci.maxSets = 1; |
| 1723 | ds_pool_ci.poolSizeCount = 1; |
| 1724 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1725 | |
| 1726 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1727 | err = |
| 1728 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1729 | ASSERT_VK_SUCCESS(err); |
| 1730 | |
| 1731 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1732 | dsl_binding.binding = 0; |
| 1733 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1734 | dsl_binding.descriptorCount = 1; |
| 1735 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1736 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1737 | |
| 1738 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1739 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1740 | ds_layout_ci.pNext = NULL; |
| 1741 | ds_layout_ci.bindingCount = 1; |
| 1742 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1743 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1744 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1745 | &ds_layout); |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1746 | ASSERT_VK_SUCCESS(err); |
| 1747 | |
| 1748 | VkDescriptorSet descriptorSet; |
| 1749 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1750 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1751 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1752 | alloc_info.descriptorPool = ds_pool; |
| 1753 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1754 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1755 | &descriptorSet); |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1756 | ASSERT_VK_SUCCESS(err); |
| 1757 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1758 | VkBufferView view = |
| 1759 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1760 | VkWriteDescriptorSet descriptor_write; |
| 1761 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1762 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1763 | descriptor_write.dstSet = descriptorSet; |
| 1764 | descriptor_write.dstBinding = 0; |
| 1765 | descriptor_write.descriptorCount = 1; |
| 1766 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1767 | descriptor_write.pTexelBufferView = &view; |
| 1768 | |
| 1769 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1770 | |
| 1771 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1772 | FAIL() << "Did not receive Error 'Attempt to update descriptor with " |
| 1773 | "invalid bufferView'"; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1774 | m_errorMonitor->DumpFailureMsgs(); |
| 1775 | } |
| 1776 | |
| 1777 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1778 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1779 | } |
| 1780 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1781 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 1782 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 1783 | // cases: |
Tobin Ehlis | ea97596 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1784 | // 1. No dynamicOffset supplied |
| 1785 | // 2. Too many dynamicOffsets supplied |
| 1786 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1787 | VkResult err; |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1788 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1789 | " requires 1 dynamicOffsets, but only " |
| 1790 | "0 dynamicOffsets are left in " |
| 1791 | "pDynamicOffsets "); |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1792 | |
| 1793 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1794 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1795 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1796 | |
| 1797 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1798 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1799 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1800 | |
| 1801 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1802 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1803 | ds_pool_ci.pNext = NULL; |
| 1804 | ds_pool_ci.maxSets = 1; |
| 1805 | ds_pool_ci.poolSizeCount = 1; |
| 1806 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1807 | |
| 1808 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1809 | err = |
| 1810 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1811 | ASSERT_VK_SUCCESS(err); |
| 1812 | |
| 1813 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1814 | dsl_binding.binding = 0; |
| 1815 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1816 | dsl_binding.descriptorCount = 1; |
| 1817 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1818 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1819 | |
| 1820 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1821 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1822 | ds_layout_ci.pNext = NULL; |
| 1823 | ds_layout_ci.bindingCount = 1; |
| 1824 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1825 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1826 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1827 | &ds_layout); |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1828 | ASSERT_VK_SUCCESS(err); |
| 1829 | |
| 1830 | VkDescriptorSet descriptorSet; |
| 1831 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1832 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1833 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1834 | alloc_info.descriptorPool = ds_pool; |
| 1835 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1836 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1837 | &descriptorSet); |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1838 | ASSERT_VK_SUCCESS(err); |
| 1839 | |
| 1840 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1841 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1842 | pipeline_layout_ci.pNext = NULL; |
| 1843 | pipeline_layout_ci.setLayoutCount = 1; |
| 1844 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1845 | |
| 1846 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1847 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1848 | &pipeline_layout); |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1849 | ASSERT_VK_SUCCESS(err); |
| 1850 | |
| 1851 | // Create a buffer to update the descriptor with |
| 1852 | uint32_t qfi = 0; |
| 1853 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1854 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1855 | buffCI.size = 1024; |
| 1856 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1857 | buffCI.queueFamilyIndexCount = 1; |
| 1858 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1859 | |
| 1860 | VkBuffer dyub; |
| 1861 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 1862 | ASSERT_VK_SUCCESS(err); |
| 1863 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 1864 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1865 | buffInfo.buffer = dyub; |
| 1866 | buffInfo.offset = 0; |
| 1867 | buffInfo.range = 1024; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1868 | |
| 1869 | VkWriteDescriptorSet descriptor_write; |
| 1870 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1871 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1872 | descriptor_write.dstSet = descriptorSet; |
| 1873 | descriptor_write.dstBinding = 0; |
| 1874 | descriptor_write.descriptorCount = 1; |
| 1875 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1876 | descriptor_write.pBufferInfo = &buffInfo; |
| 1877 | |
| 1878 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1879 | |
| 1880 | BeginCommandBuffer(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1881 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1882 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1883 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | ea97596 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1884 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1885 | FAIL() << "Error received was not 'descriptorSet #0 (0x<ADDR>) " |
| 1886 | "requires 1 dynamicOffsets, but only 0 dynamicOffsets are " |
| 1887 | "left in pDynamicOffsets array...'"; |
Tobin Ehlis | ea97596 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1888 | m_errorMonitor->DumpFailureMsgs(); |
| 1889 | } |
| 1890 | uint32_t pDynOff[2] = {512, 756}; |
| 1891 | // Now cause error b/c too many dynOffsets in array for # of dyn descriptors |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1892 | m_errorMonitor->SetDesiredFailureMsg( |
| 1893 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | ea97596 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1894 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1895 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1896 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1897 | 1, &descriptorSet, 2, pDynOff); |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1898 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1899 | FAIL() << "Error received was not 'Attempting to bind 1 descriptorSets " |
| 1900 | "with 1 dynamic descriptors, but dynamicOffsetCount is 0...'"; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1901 | m_errorMonitor->DumpFailureMsgs(); |
| 1902 | } |
Tobin Ehlis | ea97596 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1903 | // Finally cause error due to dynamicOffset being too big |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1904 | m_errorMonitor->SetDesiredFailureMsg( |
| 1905 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | ea97596 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1906 | " from its update, this oversteps its buffer ("); |
| 1907 | // Create PSO to be used for draw-time errors below |
| 1908 | char const *vsSource = |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1909 | "#version 400\n" |
Tobin Ehlis | ea97596 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1910 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 1911 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 1912 | "\n" |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1913 | "out gl_PerVertex { \n" |
| 1914 | " vec4 gl_Position;\n" |
| 1915 | "};\n" |
Tobin Ehlis | ea97596 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1916 | "void main(){\n" |
| 1917 | " gl_Position = vec4(1);\n" |
| 1918 | "}\n"; |
| 1919 | char const *fsSource = |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1920 | "#version 400\n" |
Tobin Ehlis | ea97596 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1921 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 1922 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 1923 | "\n" |
| 1924 | "layout(location=0) out vec4 x;\n" |
| 1925 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 1926 | "void main(){\n" |
| 1927 | " x = vec4(bar.y);\n" |
| 1928 | "}\n"; |
| 1929 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1930 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 1931 | VkPipelineObj pipe(m_device); |
| 1932 | pipe.AddShader(&vs); |
| 1933 | pipe.AddShader(&fs); |
| 1934 | pipe.AddColorAttachment(); |
| 1935 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 1936 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1937 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1938 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1939 | // This update should succeed, but offset size of 512 will overstep buffer |
| 1940 | // /w range 1024 & size 1024 |
| 1941 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1942 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1943 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | ea97596 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1944 | Draw(1, 0, 0, 0); |
| 1945 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1946 | FAIL() << "Error received was not 'VkDescriptorSet (0x<ADDR>) bound as " |
| 1947 | "set #0 has dynamic offset 512. Combined with offet 0 and " |
| 1948 | "range 1024 from its update, this oversteps...'"; |
Tobin Ehlis | ea97596 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1949 | m_errorMonitor->DumpFailureMsgs(); |
| 1950 | } |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1951 | |
| 1952 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1953 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1954 | } |
| 1955 | |
Tobin Ehlis | b330233 | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 1956 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 1957 | // Hit push constant error cases: |
| 1958 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 1959 | // 2. Incorrectly set push constant size to 0 |
| 1960 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 1961 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 1962 | VkResult err; |
| 1963 | m_errorMonitor->SetDesiredFailureMsg( |
| 1964 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1965 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 1966 | |
| 1967 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1968 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1969 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1970 | |
| 1971 | VkPushConstantRange pc_range = {}; |
| 1972 | pc_range.size = 0xFFFFFFFFu; |
| 1973 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 1974 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1975 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1976 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 1977 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 1978 | |
| 1979 | VkPipelineLayout pipeline_layout; |
| 1980 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1981 | &pipeline_layout); |
| 1982 | |
| 1983 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1984 | FAIL() << "Error received was not 'vkCreatePipelineLayout() call has " |
| 1985 | "push constants with offset 0...'"; |
| 1986 | m_errorMonitor->DumpFailureMsgs(); |
| 1987 | } |
| 1988 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 1989 | pc_range.size = 0; |
| 1990 | m_errorMonitor->SetDesiredFailureMsg( |
| 1991 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1992 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 1993 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1994 | &pipeline_layout); |
| 1995 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1996 | FAIL() << "Error received was not 'vkCreatePipelineLayout() call has " |
| 1997 | "push constant index 0 with size 0...'"; |
| 1998 | m_errorMonitor->DumpFailureMsgs(); |
| 1999 | } |
| 2000 | pc_range.size = 1; |
| 2001 | m_errorMonitor->SetDesiredFailureMsg( |
| 2002 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2003 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 2004 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2005 | &pipeline_layout); |
| 2006 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2007 | FAIL() << "Error received was not 'vkCreatePipelineLayout() call has " |
| 2008 | "push constant index 0 with size 0...'"; |
| 2009 | m_errorMonitor->DumpFailureMsgs(); |
| 2010 | } |
| 2011 | // Cause error due to bad size in vkCmdPushConstants() call |
| 2012 | m_errorMonitor->SetDesiredFailureMsg( |
| 2013 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2014 | "vkCmdPushConstants() call has push constants with offset "); |
| 2015 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 2016 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 2017 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2018 | &pipeline_layout); |
| 2019 | ASSERT_VK_SUCCESS(err); |
| 2020 | BeginCommandBuffer(); |
| 2021 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 2022 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
| 2023 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2024 | FAIL() << "Error received was not 'vkCmdPushConstants() call has push " |
| 2025 | "constants with offset 0...'"; |
| 2026 | m_errorMonitor->DumpFailureMsgs(); |
| 2027 | } |
| 2028 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2029 | } |
| 2030 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2031 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2032 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2033 | VkResult err; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2034 | |
| 2035 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2036 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2037 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2038 | |
| 2039 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 2040 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2041 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2042 | ds_type_count[0].descriptorCount = 10; |
| 2043 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 2044 | ds_type_count[1].descriptorCount = 2; |
| 2045 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 2046 | ds_type_count[2].descriptorCount = 2; |
| 2047 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2048 | ds_type_count[3].descriptorCount = 5; |
| 2049 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 2050 | // type |
| 2051 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 2052 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 2053 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2054 | |
| 2055 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2056 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2057 | ds_pool_ci.pNext = NULL; |
| 2058 | ds_pool_ci.maxSets = 5; |
| 2059 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 2060 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2061 | |
| 2062 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2063 | err = |
| 2064 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2065 | ASSERT_VK_SUCCESS(err); |
| 2066 | |
| 2067 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 2068 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2069 | dsl_binding[0].binding = 0; |
| 2070 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2071 | dsl_binding[0].descriptorCount = 5; |
| 2072 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 2073 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2074 | |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2075 | // Create layout identical to set0 layout but w/ different stageFlags |
| 2076 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2077 | dsl_fs_stage_only.binding = 0; |
| 2078 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2079 | dsl_fs_stage_only.descriptorCount = 5; |
| 2080 | dsl_fs_stage_only.stageFlags = |
| 2081 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 2082 | // bind time |
| 2083 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2084 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2085 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2086 | ds_layout_ci.pNext = NULL; |
| 2087 | ds_layout_ci.bindingCount = 1; |
| 2088 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2089 | static const uint32_t NUM_LAYOUTS = 4; |
| 2090 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2091 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2092 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 2093 | // layout for error case |
| 2094 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2095 | &ds_layout[0]); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2096 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | adb6135 | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2097 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2098 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2099 | &ds_layout_fs_only); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2100 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2101 | dsl_binding[0].binding = 0; |
| 2102 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2103 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | d87d28b | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2104 | dsl_binding[1].binding = 1; |
| 2105 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 2106 | dsl_binding[1].descriptorCount = 2; |
| 2107 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 2108 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | adb6135 | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2109 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2110 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2111 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2112 | &ds_layout[1]); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2113 | ASSERT_VK_SUCCESS(err); |
| 2114 | dsl_binding[0].binding = 0; |
| 2115 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2116 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2117 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2118 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2119 | &ds_layout[2]); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2120 | ASSERT_VK_SUCCESS(err); |
| 2121 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2122 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2123 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2124 | &ds_layout[3]); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2125 | ASSERT_VK_SUCCESS(err); |
| 2126 | |
| 2127 | static const uint32_t NUM_SETS = 4; |
| 2128 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 2129 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2130 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2131 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2132 | alloc_info.descriptorPool = ds_pool; |
| 2133 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2134 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2135 | descriptorSet); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2136 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2137 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2138 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2139 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2140 | err = |
| 2141 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2142 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2143 | |
| 2144 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2145 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2146 | pipeline_layout_ci.pNext = NULL; |
| 2147 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 2148 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2149 | |
| 2150 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2151 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2152 | &pipeline_layout); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2153 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2154 | // Create pipelineLayout with only one setLayout |
| 2155 | pipeline_layout_ci.setLayoutCount = 1; |
| 2156 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2157 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2158 | &single_pipe_layout); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2159 | ASSERT_VK_SUCCESS(err); |
| 2160 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 2161 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 2162 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2163 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2164 | &pipe_layout_one_desc); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2165 | ASSERT_VK_SUCCESS(err); |
| 2166 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 2167 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 2168 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2169 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2170 | &pipe_layout_five_samp); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2171 | ASSERT_VK_SUCCESS(err); |
| 2172 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 2173 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 2174 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2175 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2176 | &pipe_layout_fs_only); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2177 | ASSERT_VK_SUCCESS(err); |
| 2178 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 2179 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 2180 | pl_bad_s0[0] = ds_layout_fs_only; |
| 2181 | pl_bad_s0[1] = ds_layout[1]; |
| 2182 | pipeline_layout_ci.setLayoutCount = 2; |
| 2183 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 2184 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2185 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2186 | &pipe_layout_bad_set0); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2187 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2188 | |
| 2189 | // Create a buffer to update the descriptor with |
| 2190 | uint32_t qfi = 0; |
| 2191 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2192 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2193 | buffCI.size = 1024; |
| 2194 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 2195 | buffCI.queueFamilyIndexCount = 1; |
| 2196 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2197 | |
| 2198 | VkBuffer dyub; |
| 2199 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 2200 | ASSERT_VK_SUCCESS(err); |
| 2201 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 2202 | static const uint32_t NUM_BUFFS = 5; |
| 2203 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2204 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2205 | buffInfo[i].buffer = dyub; |
| 2206 | buffInfo[i].offset = 0; |
| 2207 | buffInfo[i].range = 1024; |
| 2208 | } |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2209 | VkImage image; |
| 2210 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2211 | const int32_t tex_width = 32; |
| 2212 | const int32_t tex_height = 32; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2213 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2214 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2215 | image_create_info.pNext = NULL; |
| 2216 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2217 | image_create_info.format = tex_format; |
| 2218 | image_create_info.extent.width = tex_width; |
| 2219 | image_create_info.extent.height = tex_height; |
| 2220 | image_create_info.extent.depth = 1; |
| 2221 | image_create_info.mipLevels = 1; |
| 2222 | image_create_info.arrayLayers = 1; |
| 2223 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2224 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2225 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2226 | image_create_info.flags = 0; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2227 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 2228 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2229 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2230 | VkMemoryRequirements memReqs; |
| 2231 | VkDeviceMemory imageMem; |
| 2232 | bool pass; |
Mike Stroyan | d87d28b | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2233 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2234 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2235 | memAlloc.pNext = NULL; |
| 2236 | memAlloc.allocationSize = 0; |
| 2237 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | d87d28b | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2238 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 2239 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2240 | pass = |
| 2241 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | d87d28b | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2242 | ASSERT_TRUE(pass); |
| 2243 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 2244 | ASSERT_VK_SUCCESS(err); |
| 2245 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 2246 | ASSERT_VK_SUCCESS(err); |
| 2247 | |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2248 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2249 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2250 | image_view_create_info.image = image; |
| 2251 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2252 | image_view_create_info.format = tex_format; |
| 2253 | image_view_create_info.subresourceRange.layerCount = 1; |
| 2254 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 2255 | image_view_create_info.subresourceRange.levelCount = 1; |
| 2256 | image_view_create_info.subresourceRange.aspectMask = |
| 2257 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2258 | |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2259 | VkImageView view; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2260 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 2261 | &view); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2262 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2280f52 | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2263 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2264 | imageInfo[0].imageView = view; |
| 2265 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2266 | imageInfo[1].imageView = view; |
| 2267 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 2280f52 | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2268 | imageInfo[2].imageView = view; |
| 2269 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2270 | imageInfo[3].imageView = view; |
| 2271 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2272 | |
| 2273 | static const uint32_t NUM_SET_UPDATES = 3; |
| 2274 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 2275 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2276 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 2277 | descriptor_write[0].dstBinding = 0; |
| 2278 | descriptor_write[0].descriptorCount = 5; |
| 2279 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2280 | descriptor_write[0].pBufferInfo = buffInfo; |
| 2281 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2282 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 2283 | descriptor_write[1].dstBinding = 0; |
| 2284 | descriptor_write[1].descriptorCount = 2; |
| 2285 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 2286 | descriptor_write[1].pImageInfo = imageInfo; |
| 2287 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2288 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 2289 | descriptor_write[2].dstBinding = 1; |
| 2290 | descriptor_write[2].descriptorCount = 2; |
| 2291 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 2280f52 | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2292 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2293 | |
| 2294 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2295 | |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2296 | // Create PSO to be used for draw-time errors below |
| 2297 | char const *vsSource = |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2298 | "#version 400\n" |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2299 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 2300 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 2301 | "\n" |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2302 | "out gl_PerVertex {\n" |
| 2303 | " vec4 gl_Position;\n" |
| 2304 | "};\n" |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2305 | "void main(){\n" |
| 2306 | " gl_Position = vec4(1);\n" |
| 2307 | "}\n"; |
| 2308 | char const *fsSource = |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2309 | "#version 400\n" |
Tobin Ehlis | d17c28c | 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" |
| 2313 | "layout(location=0) out vec4 x;\n" |
| 2314 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 2315 | "void main(){\n" |
| 2316 | " x = vec4(bar.y);\n" |
| 2317 | "}\n"; |
| 2318 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2319 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2320 | VkPipelineObj pipe(m_device); |
| 2321 | pipe.AddShader(&vs); |
| 2322 | pipe.AddShader(&fs); |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2323 | pipe.AddColorAttachment(); |
| 2324 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2325 | |
| 2326 | BeginCommandBuffer(); |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2327 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2328 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2329 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2330 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 2331 | // of PSO |
| 2332 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 2333 | // cmd_pipeline.c |
| 2334 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 2335 | // cmd_bind_graphics_pipeline() |
| 2336 | // TODO : Want to cause various binding incompatibility issues here to test |
| 2337 | // DrawState |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2338 | // First cause various verify_layout_compatibility() fails |
| 2339 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2340 | // verify_set_layout_compatibility fail cases: |
| 2341 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2342 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2343 | " due to: invalid VkPipelineLayout "); |
| 2344 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2345 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2346 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 2347 | &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2348 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2349 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2350 | "descriptorSets with invalid VkPipelineLayout."; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2351 | m_errorMonitor->DumpFailureMsgs(); |
| 2352 | } |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2353 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2354 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2355 | " attempting to bind set to index 1"); |
| 2356 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2357 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 2358 | 0, 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2359 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2360 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2361 | "descriptorSet to index 1 when pipelineLayout only has index " |
| 2362 | "0."; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2363 | m_errorMonitor->DumpFailureMsgs(); |
| 2364 | } |
| 2365 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2366 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 2367 | // descriptors |
| 2368 | m_errorMonitor->SetDesiredFailureMsg( |
| 2369 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2370 | ", but corresponding set being bound has 5 descriptors."); |
| 2371 | vkCmdBindDescriptorSets( |
| 2372 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2373 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2374 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2375 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2376 | "descriptorSet w/ 5 descriptors to pipelineLayout with only " |
| 2377 | "2 descriptors."; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2378 | m_errorMonitor->DumpFailureMsgs(); |
| 2379 | } |
| 2380 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 2381 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2382 | m_errorMonitor->SetDesiredFailureMsg( |
| 2383 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2384 | " descriptor from pipelineLayout is type 'VK_DESCRIPTOR_TYPE_SAMPLER'"); |
| 2385 | vkCmdBindDescriptorSets( |
| 2386 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2387 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2388 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2389 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2390 | "UNIFORM_BUFFER descriptorSet to pipelineLayout with " |
| 2391 | "overlapping SAMPLER type."; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2392 | m_errorMonitor->DumpFailureMsgs(); |
| 2393 | } |
| 2394 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 2395 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2396 | m_errorMonitor->SetDesiredFailureMsg( |
| 2397 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2398 | " descriptor from pipelineLayout has stageFlags "); |
| 2399 | vkCmdBindDescriptorSets( |
| 2400 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2401 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2402 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2403 | FAIL() << "Did not receive correct error msg when attempting to bind " |
| 2404 | "UNIFORM_BUFFER descriptorSet with ALL stageFlags to " |
| 2405 | "pipelineLayout with FS-only stageFlags."; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2406 | m_errorMonitor->DumpFailureMsgs(); |
| 2407 | } |
| 2408 | // Cause INFO messages due to disturbing previously bound Sets |
| 2409 | // First bind sets 0 & 1 |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2410 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2411 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2412 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2413 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2414 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2415 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2416 | " previously bound as set #0 was disturbed "); |
| 2417 | vkCmdBindDescriptorSets( |
| 2418 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2419 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2420 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2421 | FAIL() << "Did not receive correct info msg when binding Set1 w/ " |
| 2422 | "pipelineLayout that should disturb Set0."; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2423 | m_errorMonitor->DumpFailureMsgs(); |
| 2424 | } |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2425 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2426 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2427 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2428 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2429 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2430 | " newly bound as set #0 so set #1 and " |
| 2431 | "any subsequent sets were disturbed "); |
| 2432 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2433 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2434 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2435 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2436 | FAIL() << "Did not receive correct info msg when re-binding Set0 w/ " |
| 2437 | "pipelineLayout that should disturb Set1."; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2438 | m_errorMonitor->DumpFailureMsgs(); |
| 2439 | } |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2440 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2441 | // 1. Error due to not binding required set (we actually use same code as |
| 2442 | // above to disturb set0) |
| 2443 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2444 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2445 | 2, &descriptorSet[0], 0, NULL); |
| 2446 | vkCmdBindDescriptorSets( |
| 2447 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2448 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 2449 | m_errorMonitor->SetDesiredFailureMsg( |
| 2450 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2451 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2452 | Draw(1, 0, 0, 0); |
| 2453 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2454 | FAIL() << "Did not receive correct error msg when attempting draw " |
| 2455 | "requiring Set0 but Set0 is not bound."; |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2456 | m_errorMonitor->DumpFailureMsgs(); |
| 2457 | } |
Tobin Ehlis | 2280f52 | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2458 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2459 | // 2. Error due to bound set not being compatible with PSO's |
| 2460 | // VkPipelineLayout (diff stageFlags in this case) |
| 2461 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2462 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2463 | 2, &descriptorSet[0], 0, NULL); |
| 2464 | m_errorMonitor->SetDesiredFailureMsg( |
| 2465 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2466 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2467 | Draw(1, 0, 0, 0); |
| 2468 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2469 | FAIL() << "Did not receive correct error msg when attempted draw where " |
| 2470 | "bound Set0 layout is not compatible PSO Set0 layout."; |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2471 | m_errorMonitor->DumpFailureMsgs(); |
| 2472 | } |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2473 | // Remaining clean-up |
| 2474 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2475 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2476 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 2477 | } |
| 2478 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
| 2479 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, descriptorSet); |
| 2480 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2481 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2482 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2483 | } |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2484 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2485 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2486 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2487 | m_errorMonitor->SetDesiredFailureMsg( |
| 2488 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2489 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2490 | |
| 2491 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2492 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2493 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2494 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2495 | |
| 2496 | if (!m_errorMonitor->DesiredMsgFound()) { |
Eric Engestrom | 9bdcb23 | 2016-04-02 22:08:10 +0100 | [diff] [blame] | 2497 | FAIL() << "Did not receive Error 'You must call vkBeginCommandBuffer() " |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2498 | "before this call to vkEndCommandBuffer()'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2499 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2500 | } |
| 2501 | } |
| 2502 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2503 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 2504 | VkResult err; |
| 2505 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2506 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2507 | m_errorMonitor->SetDesiredFailureMsg( |
| 2508 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | b51cb78 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 2509 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2510 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2511 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2512 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2513 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2514 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2515 | cmd.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2516 | cmd.commandPool = m_commandPool; |
| 2517 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2518 | cmd.commandBufferCount = 1; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2519 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2520 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2521 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2522 | |
| 2523 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2524 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2525 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2526 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2527 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2528 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 2529 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2530 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2531 | |
| 2532 | // The error should be caught by validation of the BeginCommandBuffer call |
| 2533 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 2534 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2535 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2536 | FAIL() << "Did not receive Error 'vkBeginCommandBuffer(): Secondary " |
| 2537 | "Command Buffers (0x<ADDR>) must specify a valid renderpass " |
| 2538 | "parameter.'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2539 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2540 | } |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2541 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2542 | } |
| 2543 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2544 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2545 | // Cause error due to Begin while recording CB |
| 2546 | // Then cause 2 errors for attempting to reset CB w/o having |
| 2547 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 2548 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2549 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2550 | "Cannot call Begin on CB"); |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2551 | |
| 2552 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2553 | |
| 2554 | // Calls AllocateCommandBuffers |
| 2555 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 2556 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2557 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 2558 | // (fake) data |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2559 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2560 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2561 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2562 | cmd_buf_info.pNext = NULL; |
| 2563 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2564 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2565 | |
| 2566 | // Begin CB to transition to recording state |
| 2567 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2568 | // Can't re-begin. This should trigger error |
| 2569 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2570 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2571 | FAIL() << "Did not receive Error 'Cannot call Begin on CB (0x<ADDR>) " |
| 2572 | "in the RECORDING state...'"; |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2573 | m_errorMonitor->DumpFailureMsgs(); |
| 2574 | } |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2575 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2576 | "Attempt to reset command buffer "); |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2577 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 2578 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 2579 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
| 2580 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2581 | FAIL() << "Did not receive Error 'Attempt to reset command buffer " |
| 2582 | "(0x<ADDR>) created from command pool...'"; |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2583 | m_errorMonitor->DumpFailureMsgs(); |
| 2584 | } |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2585 | m_errorMonitor->SetDesiredFailureMsg( |
| 2586 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2587 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2588 | // Transition CB to RECORDED state |
| 2589 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 2590 | // Now attempting to Begin will implicitly reset, which triggers error |
| 2591 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2592 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2593 | FAIL() << "Did not receive Error 'Call to vkBeginCommandBuffer() on " |
| 2594 | "command buffer (0x<ADDR>) attempts to implicitly reset...'"; |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2595 | m_errorMonitor->DumpFailureMsgs(); |
| 2596 | } |
| 2597 | } |
| 2598 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2599 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2600 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2601 | VkResult err; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2602 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2603 | m_errorMonitor->SetDesiredFailureMsg( |
| 2604 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2605 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 2606 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2607 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2608 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2609 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2610 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2611 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2612 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2613 | |
| 2614 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2615 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2616 | ds_pool_ci.pNext = NULL; |
| 2617 | ds_pool_ci.maxSets = 1; |
| 2618 | ds_pool_ci.poolSizeCount = 1; |
| 2619 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2620 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2621 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2622 | err = |
| 2623 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2624 | ASSERT_VK_SUCCESS(err); |
| 2625 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2626 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2627 | dsl_binding.binding = 0; |
| 2628 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2629 | dsl_binding.descriptorCount = 1; |
| 2630 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2631 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2632 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2633 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2634 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2635 | ds_layout_ci.pNext = NULL; |
| 2636 | ds_layout_ci.bindingCount = 1; |
| 2637 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2638 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2639 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2640 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2641 | &ds_layout); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2642 | ASSERT_VK_SUCCESS(err); |
| 2643 | |
| 2644 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2645 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2646 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2647 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2648 | alloc_info.descriptorPool = ds_pool; |
| 2649 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2650 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2651 | &descriptorSet); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2652 | ASSERT_VK_SUCCESS(err); |
| 2653 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2654 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2655 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2656 | pipeline_layout_ci.setLayoutCount = 1; |
| 2657 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2658 | |
| 2659 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2660 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2661 | &pipeline_layout); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2662 | ASSERT_VK_SUCCESS(err); |
| 2663 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2664 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2665 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2666 | |
| 2667 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2668 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2669 | vp_state_ci.scissorCount = 1; |
| 2670 | vp_state_ci.pScissors = ≻ |
| 2671 | vp_state_ci.viewportCount = 1; |
| 2672 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2673 | |
Karl Schultz | fc86ab7 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2674 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 2675 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 2676 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 2677 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 2678 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 2679 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 2680 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 2681 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 2682 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2683 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2684 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2685 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | fc86ab7 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2686 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2687 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2688 | gp_ci.layout = pipeline_layout; |
| 2689 | gp_ci.renderPass = renderPass(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2690 | |
| 2691 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2692 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2693 | pc_ci.initialDataSize = 0; |
| 2694 | pc_ci.pInitialData = 0; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2695 | |
| 2696 | VkPipeline pipeline; |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2697 | VkPipelineCache pipelineCache; |
| 2698 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2699 | err = |
| 2700 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2701 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2702 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2703 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2704 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2705 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2706 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: " |
| 2707 | "Vtx Shader required'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2708 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2709 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2710 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2711 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2712 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2713 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2714 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2715 | } |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2716 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 2717 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 2718 | { |
| 2719 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2720 | VkResult err; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2721 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2722 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2723 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 2724 | primitive "); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2725 | |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2726 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2727 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2728 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2729 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2730 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2731 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2732 | |
| 2733 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2734 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2735 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2736 | ds_pool_ci.poolSizeCount = 1; |
| 2737 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2738 | |
| 2739 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2740 | err = vkCreateDescriptorPool(m_device->device(), |
| 2741 | VK_DESCRIPTOR_POOL_USAGE_NON_FREE, 1, &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2742 | ASSERT_VK_SUCCESS(err); |
| 2743 | |
| 2744 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2745 | dsl_binding.binding = 0; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2746 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2747 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2748 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2749 | dsl_binding.pImmutableSamplers = NULL; |
| 2750 | |
| 2751 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2752 | ds_layout_ci.sType = |
| 2753 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2754 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2755 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | adb6135 | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2756 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2757 | |
| 2758 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2759 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2760 | &ds_layout); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2761 | ASSERT_VK_SUCCESS(err); |
| 2762 | |
| 2763 | VkDescriptorSet descriptorSet; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2764 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 2765 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2766 | ASSERT_VK_SUCCESS(err); |
| 2767 | |
| 2768 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2769 | pipeline_layout_ci.sType = |
| 2770 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2771 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2772 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2773 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2774 | |
| 2775 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2776 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2777 | &pipeline_layout); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2778 | ASSERT_VK_SUCCESS(err); |
| 2779 | |
| 2780 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 2781 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 2782 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2783 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 2784 | this); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2785 | // Just using VS txt for Tess shaders as we don't care about functionality |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2786 | VkShaderObj |
| 2787 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 2788 | this); |
| 2789 | VkShaderObj |
| 2790 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 2791 | this); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2792 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2793 | shaderStages[0].sType = |
| 2794 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2795 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2796 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2797 | shaderStages[1].sType = |
| 2798 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2799 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2800 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2801 | shaderStages[2].sType = |
| 2802 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2803 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2804 | shaderStages[2].shader = te.handle(); |
| 2805 | |
| 2806 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2807 | iaCI.sType = |
| 2808 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 99ba2bb | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2809 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2810 | |
| 2811 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 2812 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 2813 | tsCI.patchControlPoints = 0; // This will cause an error |
| 2814 | |
| 2815 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2816 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2817 | gp_ci.pNext = NULL; |
| 2818 | gp_ci.stageCount = 3; |
| 2819 | gp_ci.pStages = shaderStages; |
| 2820 | gp_ci.pVertexInputState = NULL; |
| 2821 | gp_ci.pInputAssemblyState = &iaCI; |
| 2822 | gp_ci.pTessellationState = &tsCI; |
| 2823 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2824 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2825 | gp_ci.pMultisampleState = NULL; |
| 2826 | gp_ci.pDepthStencilState = NULL; |
| 2827 | gp_ci.pColorBlendState = NULL; |
| 2828 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2829 | gp_ci.layout = pipeline_layout; |
| 2830 | gp_ci.renderPass = renderPass(); |
| 2831 | |
| 2832 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2833 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2834 | pc_ci.pNext = NULL; |
| 2835 | pc_ci.initialSize = 0; |
| 2836 | pc_ci.initialData = 0; |
| 2837 | pc_ci.maxSize = 0; |
| 2838 | |
| 2839 | VkPipeline pipeline; |
| 2840 | VkPipelineCache pipelineCache; |
| 2841 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2842 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 2843 | &pipelineCache); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2844 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2845 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2846 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2847 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2848 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2849 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: |
Chris Forbes | e8aa35e | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 2850 | VK_PRIMITIVE_TOPOLOGY_PATCHLIST primitive...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2851 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2852 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2853 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2854 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2855 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2856 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2857 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2858 | } |
| 2859 | */ |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2860 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2861 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2862 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2863 | VkResult err; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2864 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2865 | m_errorMonitor->SetDesiredFailureMsg( |
| 2866 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2867 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2868 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2869 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2870 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2871 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2872 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2873 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2874 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2875 | |
| 2876 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2877 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2878 | ds_pool_ci.maxSets = 1; |
| 2879 | ds_pool_ci.poolSizeCount = 1; |
| 2880 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2881 | |
| 2882 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2883 | err = |
| 2884 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2885 | ASSERT_VK_SUCCESS(err); |
| 2886 | |
| 2887 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2888 | dsl_binding.binding = 0; |
| 2889 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2890 | dsl_binding.descriptorCount = 1; |
| 2891 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2892 | |
| 2893 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2894 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2895 | ds_layout_ci.bindingCount = 1; |
| 2896 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2897 | |
| 2898 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2899 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2900 | &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2901 | ASSERT_VK_SUCCESS(err); |
| 2902 | |
| 2903 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2904 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2905 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2906 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2907 | alloc_info.descriptorPool = ds_pool; |
| 2908 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2909 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2910 | &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2911 | ASSERT_VK_SUCCESS(err); |
| 2912 | |
| 2913 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2914 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2915 | pipeline_layout_ci.setLayoutCount = 1; |
| 2916 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2917 | |
| 2918 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2919 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2920 | &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2921 | ASSERT_VK_SUCCESS(err); |
| 2922 | |
| 2923 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2924 | |
| 2925 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2926 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2927 | vp_state_ci.scissorCount = 0; |
| 2928 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2929 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2930 | |
Karl Schultz | fc86ab7 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2931 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 2932 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 2933 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 2934 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 2935 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 2936 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 2937 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 2938 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 2939 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2940 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2941 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2942 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2943 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 2944 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2945 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 2946 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 2947 | this); // TODO - We shouldn't need a fragment shader |
| 2948 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2949 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2950 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2951 | |
| 2952 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2953 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2954 | gp_ci.stageCount = 2; |
| 2955 | gp_ci.pStages = shaderStages; |
| 2956 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | fc86ab7 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2957 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2958 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2959 | gp_ci.layout = pipeline_layout; |
| 2960 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2961 | |
| 2962 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2963 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2964 | |
| 2965 | VkPipeline pipeline; |
| 2966 | VkPipelineCache pipelineCache; |
| 2967 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2968 | err = |
| 2969 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2970 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2971 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2972 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2973 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2974 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2975 | FAIL() << "Did not receive Error 'Gfx Pipeline viewport count (1) must " |
| 2976 | "match scissor count (0).'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2977 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2978 | } |
| 2979 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2980 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2981 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2982 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2983 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2984 | } |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2985 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 2986 | // state |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2987 | // for the counts even if the data is going to be set dynamically. |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2988 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2989 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2990 | VkResult err; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2991 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2992 | m_errorMonitor->SetDesiredFailureMsg( |
| 2993 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2994 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2995 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2996 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2997 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2998 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2999 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3000 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3001 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3002 | |
| 3003 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3004 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3005 | ds_pool_ci.maxSets = 1; |
| 3006 | ds_pool_ci.poolSizeCount = 1; |
| 3007 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3008 | |
| 3009 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3010 | err = |
| 3011 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3012 | ASSERT_VK_SUCCESS(err); |
| 3013 | |
| 3014 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3015 | dsl_binding.binding = 0; |
| 3016 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3017 | dsl_binding.descriptorCount = 1; |
| 3018 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3019 | |
| 3020 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3021 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3022 | ds_layout_ci.bindingCount = 1; |
| 3023 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3024 | |
| 3025 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3026 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3027 | &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3028 | ASSERT_VK_SUCCESS(err); |
| 3029 | |
| 3030 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3031 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3032 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3033 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3034 | alloc_info.descriptorPool = ds_pool; |
| 3035 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3036 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3037 | &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3038 | ASSERT_VK_SUCCESS(err); |
| 3039 | |
| 3040 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3041 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3042 | pipeline_layout_ci.setLayoutCount = 1; |
| 3043 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3044 | |
| 3045 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3046 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3047 | &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3048 | ASSERT_VK_SUCCESS(err); |
| 3049 | |
| 3050 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 3051 | // Set scissor as dynamic to avoid second error |
| 3052 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3053 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3054 | dyn_state_ci.dynamicStateCount = 1; |
| 3055 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3056 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3057 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3058 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3059 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3060 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3061 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3062 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3063 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 3064 | this); // TODO - We shouldn't need a fragment shader |
| 3065 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3066 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3067 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3068 | |
Karl Schultz | fc86ab7 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3069 | |
| 3070 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 3071 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3072 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 3073 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 3074 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 3075 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 3076 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 3077 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 3078 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3079 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3080 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3081 | gp_ci.stageCount = 2; |
| 3082 | gp_ci.pStages = shaderStages; |
Karl Schultz | fc86ab7 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3083 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3084 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 3085 | // should cause validation error |
| 3086 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3087 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3088 | gp_ci.layout = pipeline_layout; |
| 3089 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3090 | |
| 3091 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3092 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3093 | |
| 3094 | VkPipeline pipeline; |
| 3095 | VkPipelineCache pipelineCache; |
| 3096 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3097 | err = |
| 3098 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3099 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3100 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3101 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3102 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3103 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3104 | FAIL() << "Did not receive Error 'Gfx Pipeline pViewportState is null. " |
| 3105 | "Even if...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3106 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3107 | } |
| 3108 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3109 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3110 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3111 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3112 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3113 | } |
| 3114 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3115 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 3116 | // count |
| 3117 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 3118 | VkResult err; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3119 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3120 | m_errorMonitor->SetDesiredFailureMsg( |
| 3121 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3122 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 3123 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3124 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3125 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3126 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3127 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3128 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3129 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3130 | |
| 3131 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3132 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3133 | ds_pool_ci.maxSets = 1; |
| 3134 | ds_pool_ci.poolSizeCount = 1; |
| 3135 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3136 | |
| 3137 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3138 | err = |
| 3139 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3140 | ASSERT_VK_SUCCESS(err); |
| 3141 | |
| 3142 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3143 | dsl_binding.binding = 0; |
| 3144 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3145 | dsl_binding.descriptorCount = 1; |
| 3146 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3147 | |
| 3148 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3149 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3150 | ds_layout_ci.bindingCount = 1; |
| 3151 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3152 | |
| 3153 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3154 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3155 | &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3156 | ASSERT_VK_SUCCESS(err); |
| 3157 | |
| 3158 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3159 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3160 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3161 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3162 | alloc_info.descriptorPool = ds_pool; |
| 3163 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3164 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3165 | &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3166 | ASSERT_VK_SUCCESS(err); |
| 3167 | |
| 3168 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3169 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3170 | pipeline_layout_ci.setLayoutCount = 1; |
| 3171 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3172 | |
| 3173 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3174 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3175 | &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3176 | ASSERT_VK_SUCCESS(err); |
| 3177 | |
| 3178 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3179 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3180 | vp_state_ci.viewportCount = 1; |
| 3181 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 3182 | vp_state_ci.scissorCount = 1; |
| 3183 | vp_state_ci.pScissors = |
| 3184 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3185 | |
| 3186 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 3187 | // Set scissor as dynamic to avoid that error |
| 3188 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3189 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3190 | dyn_state_ci.dynamicStateCount = 1; |
| 3191 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3192 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3193 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3194 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3195 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3196 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3197 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3198 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3199 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 3200 | this); // TODO - We shouldn't need a fragment shader |
| 3201 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3202 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3203 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3204 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3205 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 3206 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 3207 | vi_ci.pNext = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3208 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3209 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3210 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3211 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 3212 | |
| 3213 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 3214 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 3215 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 3216 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3217 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3218 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3219 | rs_ci.pNext = nullptr; |
| 3220 | |
Mark Young | 0292df5 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3221 | VkPipelineColorBlendAttachmentState att = {}; |
| 3222 | att.blendEnable = VK_FALSE; |
| 3223 | att.colorWriteMask = 0xf; |
| 3224 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3225 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 3226 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 3227 | cb_ci.pNext = nullptr; |
Mark Young | 0292df5 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3228 | cb_ci.attachmentCount = 1; |
| 3229 | cb_ci.pAttachments = &att; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3230 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3231 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3232 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3233 | gp_ci.stageCount = 2; |
| 3234 | gp_ci.pStages = shaderStages; |
| 3235 | gp_ci.pVertexInputState = &vi_ci; |
| 3236 | gp_ci.pInputAssemblyState = &ia_ci; |
| 3237 | gp_ci.pViewportState = &vp_state_ci; |
| 3238 | gp_ci.pRasterizationState = &rs_ci; |
| 3239 | gp_ci.pColorBlendState = &cb_ci; |
| 3240 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3241 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3242 | gp_ci.layout = pipeline_layout; |
| 3243 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3244 | |
| 3245 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3246 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3247 | |
| 3248 | VkPipeline pipeline; |
| 3249 | VkPipelineCache pipelineCache; |
| 3250 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3251 | err = |
| 3252 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3253 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3254 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3255 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3256 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3257 | if (!m_errorMonitor->DesiredMsgFound()) { |
Eric Engestrom | 9bdcb23 | 2016-04-02 22:08:10 +0100 | [diff] [blame] | 3258 | FAIL() << "Did not receive Error 'Gfx Pipeline viewportCount is 1, but " |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3259 | "pViewports is NULL...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3260 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3261 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3262 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3263 | // Now hit second fail case where we set scissor w/ different count than PSO |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3264 | // First need to successfully create the PSO from above by setting |
| 3265 | // pViewports |
| 3266 | m_errorMonitor->SetDesiredFailureMsg( |
| 3267 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3268 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 3269 | "scissorCount is 1. These counts must match."); |
| 3270 | |
| 3271 | VkViewport vp = {}; // Just need dummy vp to point to |
| 3272 | vp_state_ci.pViewports = &vp; |
| 3273 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3274 | &gp_ci, NULL, &pipeline); |
| 3275 | ASSERT_VK_SUCCESS(err); |
| 3276 | BeginCommandBuffer(); |
| 3277 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3278 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 3279 | VkRect2D scissors[2] = {}; // don't care about data |
| 3280 | // Count of 2 doesn't match PSO count of 1 |
| 3281 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 3282 | Draw(1, 0, 0, 0); |
| 3283 | |
| 3284 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3285 | FAIL() << "Did not receive Error 'Dynamic scissorCount from " |
| 3286 | "vkCmdSetScissor() is 2, but PSO scissorCount is 1...'"; |
| 3287 | m_errorMonitor->DumpFailureMsgs(); |
| 3288 | } |
| 3289 | |
| 3290 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3291 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3292 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3293 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3294 | } |
| 3295 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 3296 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 3297 | // viewportCount |
| 3298 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 3299 | VkResult err; |
| 3300 | |
| 3301 | m_errorMonitor->SetDesiredFailureMsg( |
| 3302 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3303 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 3304 | |
| 3305 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3306 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3307 | |
| 3308 | VkDescriptorPoolSize ds_type_count = {}; |
| 3309 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3310 | ds_type_count.descriptorCount = 1; |
| 3311 | |
| 3312 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3313 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3314 | ds_pool_ci.maxSets = 1; |
| 3315 | ds_pool_ci.poolSizeCount = 1; |
| 3316 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 3317 | |
| 3318 | VkDescriptorPool ds_pool; |
| 3319 | err = |
| 3320 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 3321 | ASSERT_VK_SUCCESS(err); |
| 3322 | |
| 3323 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3324 | dsl_binding.binding = 0; |
| 3325 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3326 | dsl_binding.descriptorCount = 1; |
| 3327 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3328 | |
| 3329 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3330 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3331 | ds_layout_ci.bindingCount = 1; |
| 3332 | ds_layout_ci.pBindings = &dsl_binding; |
| 3333 | |
| 3334 | VkDescriptorSetLayout ds_layout; |
| 3335 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3336 | &ds_layout); |
| 3337 | ASSERT_VK_SUCCESS(err); |
| 3338 | |
| 3339 | VkDescriptorSet descriptorSet; |
| 3340 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 3341 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 3342 | alloc_info.descriptorSetCount = 1; |
| 3343 | alloc_info.descriptorPool = ds_pool; |
| 3344 | alloc_info.pSetLayouts = &ds_layout; |
| 3345 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3346 | &descriptorSet); |
| 3347 | ASSERT_VK_SUCCESS(err); |
| 3348 | |
| 3349 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3350 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3351 | pipeline_layout_ci.setLayoutCount = 1; |
| 3352 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3353 | |
| 3354 | VkPipelineLayout pipeline_layout; |
| 3355 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3356 | &pipeline_layout); |
| 3357 | ASSERT_VK_SUCCESS(err); |
| 3358 | |
| 3359 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 3360 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3361 | vp_state_ci.scissorCount = 1; |
| 3362 | vp_state_ci.pScissors = |
| 3363 | NULL; // Null scissor w/ count of 1 should cause error |
| 3364 | vp_state_ci.viewportCount = 1; |
| 3365 | vp_state_ci.pViewports = |
| 3366 | NULL; // vp is dynamic (below) so this won't cause error |
| 3367 | |
| 3368 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 3369 | // Set scissor as dynamic to avoid that error |
| 3370 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 3371 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3372 | dyn_state_ci.dynamicStateCount = 1; |
| 3373 | dyn_state_ci.pDynamicStates = &vp_state; |
| 3374 | |
| 3375 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 3376 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 3377 | |
| 3378 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3379 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3380 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3381 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 3382 | this); // TODO - We shouldn't need a fragment shader |
| 3383 | // but add it to be able to run on more devices |
| 3384 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3385 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 3386 | |
| 3387 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 3388 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 3389 | vi_ci.pNext = nullptr; |
| 3390 | vi_ci.vertexBindingDescriptionCount = 0; |
| 3391 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 3392 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 3393 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 3394 | |
| 3395 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 3396 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 3397 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 3398 | |
| 3399 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 3400 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3401 | rs_ci.pNext = nullptr; |
| 3402 | |
Mark Young | 0292df5 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3403 | VkPipelineColorBlendAttachmentState att = {}; |
| 3404 | att.blendEnable = VK_FALSE; |
| 3405 | att.colorWriteMask = 0xf; |
| 3406 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3407 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 3408 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 3409 | cb_ci.pNext = nullptr; |
Mark Young | 0292df5 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3410 | cb_ci.attachmentCount = 1; |
| 3411 | cb_ci.pAttachments = &att; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3412 | |
| 3413 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 3414 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3415 | gp_ci.stageCount = 2; |
| 3416 | gp_ci.pStages = shaderStages; |
| 3417 | gp_ci.pVertexInputState = &vi_ci; |
| 3418 | gp_ci.pInputAssemblyState = &ia_ci; |
| 3419 | gp_ci.pViewportState = &vp_state_ci; |
| 3420 | gp_ci.pRasterizationState = &rs_ci; |
| 3421 | gp_ci.pColorBlendState = &cb_ci; |
| 3422 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3423 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3424 | gp_ci.layout = pipeline_layout; |
| 3425 | gp_ci.renderPass = renderPass(); |
| 3426 | |
| 3427 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 3428 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3429 | |
| 3430 | VkPipeline pipeline; |
| 3431 | VkPipelineCache pipelineCache; |
| 3432 | |
| 3433 | err = |
| 3434 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 3435 | ASSERT_VK_SUCCESS(err); |
| 3436 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3437 | &gp_ci, NULL, &pipeline); |
| 3438 | |
| 3439 | if (!m_errorMonitor->DesiredMsgFound()) { |
Eric Engestrom | 9bdcb23 | 2016-04-02 22:08:10 +0100 | [diff] [blame] | 3440 | FAIL() << "Did not receive Error 'Gfx Pipeline scissorCount is 1, but " |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3441 | "pScissors is NULL...'"; |
| 3442 | m_errorMonitor->DumpFailureMsgs(); |
| 3443 | } |
| 3444 | |
| 3445 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 3446 | // First need to successfully create the PSO from above by setting |
| 3447 | // pViewports |
| 3448 | m_errorMonitor->SetDesiredFailureMsg( |
| 3449 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3450 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 3451 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3452 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3453 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 3454 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3455 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3456 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3457 | ASSERT_VK_SUCCESS(err); |
| 3458 | BeginCommandBuffer(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3459 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3460 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3461 | VkViewport viewports[2] = {}; // don't care about data |
| 3462 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | f251652 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 3463 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3464 | Draw(1, 0, 0, 0); |
| 3465 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3466 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3467 | FAIL() << "Did not receive Error 'Dynamic viewportCount from " |
| 3468 | "vkCmdSetViewport() is 2, but PSO viewportCount is 1...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3469 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3470 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3471 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3472 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3473 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3474 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3475 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3476 | } |
| 3477 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3478 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3479 | // Bind a NULL RenderPass |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3480 | m_errorMonitor->SetDesiredFailureMsg( |
| 3481 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3482 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3483 | |
| 3484 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3485 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3486 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3487 | BeginCommandBuffer(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3488 | // Don't care about RenderPass handle b/c error should be flagged before |
| 3489 | // that |
| 3490 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 3491 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3492 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3493 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3494 | FAIL() << "Did not receive Error 'You cannot use a NULL RenderPass " |
| 3495 | "object in vkCmdBeginRenderPass()'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3496 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3497 | } |
| 3498 | } |
| 3499 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3500 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3501 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3502 | m_errorMonitor->SetDesiredFailureMsg( |
| 3503 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3504 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3505 | |
| 3506 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3507 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3508 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3509 | BeginCommandBuffer(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3510 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 3511 | // proper error |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3512 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3513 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 3514 | rp_begin.pNext = NULL; |
| 3515 | rp_begin.renderPass = renderPass(); |
| 3516 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3517 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3518 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 3519 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3520 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3521 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3522 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3523 | "inside an active render pass...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3524 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3525 | } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3526 | } |
| 3527 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3528 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3529 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3530 | m_errorMonitor->SetDesiredFailureMsg( |
| 3531 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3532 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3533 | |
| 3534 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3535 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3536 | |
| 3537 | // Renderpass is started here |
| 3538 | BeginCommandBuffer(); |
| 3539 | |
| 3540 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3541 | vk_testing::Buffer dstBuffer; |
| 3542 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3543 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3544 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3545 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3546 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3547 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3548 | "inside an active render pass...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3549 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3550 | } |
| 3551 | } |
| 3552 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3553 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3554 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3555 | m_errorMonitor->SetDesiredFailureMsg( |
| 3556 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3557 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3558 | |
| 3559 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3560 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3561 | |
| 3562 | // Renderpass is started here |
| 3563 | BeginCommandBuffer(); |
| 3564 | |
| 3565 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3566 | vk_testing::Buffer dstBuffer; |
| 3567 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3568 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3569 | VkDeviceSize dstOffset = 0; |
| 3570 | VkDeviceSize dataSize = 1024; |
| 3571 | const uint32_t *pData = NULL; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3572 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3573 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 3574 | dstOffset, dataSize, pData); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3575 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3576 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3577 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3578 | "inside an active render pass...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3579 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3580 | } |
| 3581 | } |
| 3582 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3583 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3584 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3585 | m_errorMonitor->SetDesiredFailureMsg( |
| 3586 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3587 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3588 | |
| 3589 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3590 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3591 | |
| 3592 | // Renderpass is started here |
| 3593 | BeginCommandBuffer(); |
| 3594 | |
Michael Lentine | 584ccab | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 3595 | VkClearColorValue clear_color; |
| 3596 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3597 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 3598 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3599 | const int32_t tex_width = 32; |
| 3600 | const int32_t tex_height = 32; |
| 3601 | VkImageCreateInfo image_create_info = {}; |
| 3602 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3603 | image_create_info.pNext = NULL; |
| 3604 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3605 | image_create_info.format = tex_format; |
| 3606 | image_create_info.extent.width = tex_width; |
| 3607 | image_create_info.extent.height = tex_height; |
| 3608 | image_create_info.extent.depth = 1; |
| 3609 | image_create_info.mipLevels = 1; |
| 3610 | image_create_info.arrayLayers = 1; |
| 3611 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3612 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3613 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3614 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3615 | vk_testing::Image dstImage; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3616 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 3617 | reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3618 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3619 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 3620 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3621 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3622 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 3623 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3624 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3625 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3626 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3627 | "inside an active render pass...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3628 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3629 | } |
| 3630 | } |
| 3631 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3632 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3633 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3634 | m_errorMonitor->SetDesiredFailureMsg( |
| 3635 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3636 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3637 | |
| 3638 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3639 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3640 | |
| 3641 | // Renderpass is started here |
| 3642 | BeginCommandBuffer(); |
| 3643 | |
| 3644 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | 4bf3f20 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 3645 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3646 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 3647 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3648 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3649 | image_create_info.extent.width = 64; |
| 3650 | image_create_info.extent.height = 64; |
| 3651 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3652 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3653 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3654 | vk_testing::Image dstImage; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3655 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 3656 | reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3657 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3658 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 3659 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3660 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3661 | vkCmdClearDepthStencilImage( |
| 3662 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 3663 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 3664 | &range); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3665 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3666 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3667 | FAIL() << "Did not receive Error 'It is invalid to issue this call " |
| 3668 | "inside an active render pass...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3669 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3670 | } |
| 3671 | } |
| 3672 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3673 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3674 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3675 | VkResult err; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3676 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3677 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3678 | "vkCmdClearAttachments: This call " |
| 3679 | "must be issued inside an active " |
| 3680 | "render pass"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3681 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3682 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3683 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3684 | |
| 3685 | // Start no RenderPass |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3686 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3687 | ASSERT_VK_SUCCESS(err); |
| 3688 | |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3689 | VkClearAttachment color_attachment; |
| 3690 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3691 | color_attachment.clearValue.color.float32[0] = 0; |
| 3692 | color_attachment.clearValue.color.float32[1] = 0; |
| 3693 | color_attachment.clearValue.color.float32[2] = 0; |
| 3694 | color_attachment.clearValue.color.float32[3] = 0; |
| 3695 | color_attachment.colorAttachment = 0; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3696 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 3697 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 3698 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3699 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3700 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3701 | FAIL() << "Did not receive Error 'vkCmdClearAttachments: This call " |
| 3702 | "must be issued inside an active render pass.'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3703 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3704 | } |
| 3705 | } |
| 3706 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3707 | TEST_F(VkLayerTest, InvalidDynamicStateObject) { |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3708 | // Create a valid cmd buffer |
| 3709 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3710 | // TODO : Simple check for bad object should be added to ObjectTracker to |
| 3711 | // catch this case |
| 3712 | // The DS check for this is after driver has been called to validate DS |
| 3713 | // internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3714 | } |
Tobin Ehlis | 201b1ba | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 3715 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3716 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3717 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3718 | VkResult err; |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3719 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3720 | m_errorMonitor->SetDesiredFailureMsg( |
| 3721 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3722 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 3723 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3724 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3725 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3726 | uint32_t qfi = 0; |
| 3727 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3728 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3729 | buffCI.size = 1024; |
| 3730 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 3731 | buffCI.queueFamilyIndexCount = 1; |
| 3732 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3733 | |
| 3734 | VkBuffer ib; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3735 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3736 | ASSERT_VK_SUCCESS(err); |
| 3737 | |
| 3738 | BeginCommandBuffer(); |
| 3739 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3740 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3741 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3742 | // Should error before calling to driver so don't care about actual data |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3743 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 3744 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3745 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3746 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3747 | FAIL() << "Did not receive Error 'vkCmdBindIndexBuffer() offset (0x7) " |
| 3748 | "does not fall on ...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3749 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3750 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3751 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3752 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3753 | } |
| 3754 | |
Mark Lobodzinski | e25c754 | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3755 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 3756 | // Create an out-of-range queueFamilyIndex |
| 3757 | m_errorMonitor->SetDesiredFailureMsg( |
| 3758 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 3e09395 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 3759 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | e25c754 | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3760 | |
| 3761 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3762 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3763 | VkBufferCreateInfo buffCI = {}; |
| 3764 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3765 | buffCI.size = 1024; |
| 3766 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 3767 | buffCI.queueFamilyIndexCount = 1; |
| 3768 | // Introduce failure by specifying invalid queue_family_index |
| 3769 | uint32_t qfi = 777; |
| 3770 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 3e09395 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 3771 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | e25c754 | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3772 | |
| 3773 | VkBuffer ib; |
| 3774 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 3775 | |
| 3776 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | 3e09395 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 3777 | FAIL() << "Did not receive Error 'queueFamilyIndex %d, must have " |
| 3778 | "been given when the device was created.'"; |
Mark Lobodzinski | e25c754 | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3779 | m_errorMonitor->DumpFailureMsgs(); |
| 3780 | } |
| 3781 | } |
| 3782 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3783 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 3784 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 3785 | // secondary) |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3786 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3787 | m_errorMonitor->SetDesiredFailureMsg( |
| 3788 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3789 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3790 | |
| 3791 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3792 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3793 | |
| 3794 | BeginCommandBuffer(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3795 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3796 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 3797 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3798 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3799 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3800 | FAIL() << "Did not receive Error 'vkCmdExecuteCommands() called w/ " |
| 3801 | "Primary Cmd Buffer '"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3802 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3803 | } |
| 3804 | } |
| 3805 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3806 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3807 | // Create DS w/ layout of one type and attempt Update w/ mis-matched type |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3808 | VkResult err; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3809 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3810 | m_errorMonitor->SetDesiredFailureMsg( |
| 3811 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Write descriptor update has descriptor " |
| 3812 | "type VK_DESCRIPTOR_TYPE_SAMPLER that " |
| 3813 | "does not match "); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3814 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3815 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3816 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3817 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3818 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3819 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3820 | |
| 3821 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3822 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3823 | ds_pool_ci.pNext = NULL; |
| 3824 | ds_pool_ci.maxSets = 1; |
| 3825 | ds_pool_ci.poolSizeCount = 1; |
| 3826 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3827 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3828 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3829 | err = |
| 3830 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3831 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3832 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3833 | dsl_binding.binding = 0; |
| 3834 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3835 | dsl_binding.descriptorCount = 1; |
| 3836 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3837 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3838 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3839 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3840 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3841 | ds_layout_ci.pNext = NULL; |
| 3842 | ds_layout_ci.bindingCount = 1; |
| 3843 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3844 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3845 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3846 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3847 | &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3848 | ASSERT_VK_SUCCESS(err); |
| 3849 | |
| 3850 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3851 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3852 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3853 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3854 | alloc_info.descriptorPool = ds_pool; |
| 3855 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3856 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3857 | &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3858 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3859 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3860 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3861 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3862 | sampler_ci.pNext = NULL; |
| 3863 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3864 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3865 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3866 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3867 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3868 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3869 | sampler_ci.mipLodBias = 1.0; |
| 3870 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3871 | sampler_ci.maxAnisotropy = 1; |
| 3872 | sampler_ci.compareEnable = VK_FALSE; |
| 3873 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3874 | sampler_ci.minLod = 1.0; |
| 3875 | sampler_ci.maxLod = 1.0; |
| 3876 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3877 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3878 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3879 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3880 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3881 | ASSERT_VK_SUCCESS(err); |
| 3882 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3883 | VkDescriptorImageInfo info = {}; |
| 3884 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3885 | |
| 3886 | VkWriteDescriptorSet descriptor_write; |
| 3887 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3888 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3889 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3890 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3891 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3892 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3893 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3894 | |
| 3895 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3896 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3897 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3898 | FAIL() << "Did not receive Error 'Write descriptor update has " |
| 3899 | "descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not " |
| 3900 | "match...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3901 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3902 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3903 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3904 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3905 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3906 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3907 | } |
| 3908 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3909 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3910 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3911 | VkResult err; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3912 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3913 | m_errorMonitor->SetDesiredFailureMsg( |
| 3914 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Descriptor update type of " |
| 3915 | "VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET " |
| 3916 | "is out of bounds for matching binding"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3917 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3918 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3919 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3920 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3921 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3922 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3923 | |
| 3924 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3925 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3926 | ds_pool_ci.pNext = NULL; |
| 3927 | ds_pool_ci.maxSets = 1; |
| 3928 | ds_pool_ci.poolSizeCount = 1; |
| 3929 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3930 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3931 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3932 | err = |
| 3933 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3934 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3935 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3936 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3937 | dsl_binding.binding = 0; |
| 3938 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3939 | dsl_binding.descriptorCount = 1; |
| 3940 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3941 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3942 | |
| 3943 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3944 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3945 | ds_layout_ci.pNext = NULL; |
| 3946 | ds_layout_ci.bindingCount = 1; |
| 3947 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3948 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3949 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3950 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3951 | &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3952 | ASSERT_VK_SUCCESS(err); |
| 3953 | |
| 3954 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3955 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3956 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3957 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3958 | alloc_info.descriptorPool = ds_pool; |
| 3959 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3960 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3961 | &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3962 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3963 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3964 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3965 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3966 | sampler_ci.pNext = NULL; |
| 3967 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3968 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3969 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3970 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3971 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3972 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3973 | sampler_ci.mipLodBias = 1.0; |
| 3974 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3975 | sampler_ci.maxAnisotropy = 1; |
| 3976 | sampler_ci.compareEnable = VK_FALSE; |
| 3977 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3978 | sampler_ci.minLod = 1.0; |
| 3979 | sampler_ci.maxLod = 1.0; |
| 3980 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3981 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3982 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3983 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3984 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3985 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3986 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3987 | VkDescriptorImageInfo info = {}; |
| 3988 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3989 | |
| 3990 | VkWriteDescriptorSet descriptor_write; |
| 3991 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3992 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3993 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3994 | descriptor_write.dstArrayElement = |
| 3995 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3996 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3997 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3998 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3999 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4000 | |
| 4001 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4002 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4003 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4004 | FAIL() << "Did not receive Error 'Descriptor update type of " |
| 4005 | "VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for " |
| 4006 | "matching binding...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4007 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4008 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4009 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4010 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4011 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4012 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4013 | } |
| 4014 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4015 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 4016 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 4017 | // index 2 |
| 4018 | VkResult err; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4019 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4020 | m_errorMonitor->SetDesiredFailureMsg( |
| 4021 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4022 | " does not have binding to match update binding "); |
| 4023 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4024 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4025 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4026 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4027 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4028 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4029 | |
| 4030 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4031 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4032 | ds_pool_ci.pNext = NULL; |
| 4033 | ds_pool_ci.maxSets = 1; |
| 4034 | ds_pool_ci.poolSizeCount = 1; |
| 4035 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4036 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4037 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4038 | err = |
| 4039 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4040 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4041 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4042 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4043 | dsl_binding.binding = 0; |
| 4044 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4045 | dsl_binding.descriptorCount = 1; |
| 4046 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4047 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4048 | |
| 4049 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4050 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4051 | ds_layout_ci.pNext = NULL; |
| 4052 | ds_layout_ci.bindingCount = 1; |
| 4053 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4054 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4055 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4056 | &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4057 | ASSERT_VK_SUCCESS(err); |
| 4058 | |
| 4059 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4060 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4061 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4062 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4063 | alloc_info.descriptorPool = ds_pool; |
| 4064 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4065 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4066 | &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4067 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4068 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4069 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4070 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4071 | sampler_ci.pNext = NULL; |
| 4072 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4073 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4074 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4075 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4076 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4077 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4078 | sampler_ci.mipLodBias = 1.0; |
| 4079 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4080 | sampler_ci.maxAnisotropy = 1; |
| 4081 | sampler_ci.compareEnable = VK_FALSE; |
| 4082 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4083 | sampler_ci.minLod = 1.0; |
| 4084 | sampler_ci.maxLod = 1.0; |
| 4085 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4086 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4087 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4088 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4089 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4090 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4091 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4092 | VkDescriptorImageInfo info = {}; |
| 4093 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4094 | |
| 4095 | VkWriteDescriptorSet descriptor_write; |
| 4096 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4097 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4098 | descriptor_write.dstSet = descriptorSet; |
| 4099 | descriptor_write.dstBinding = 2; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4100 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4101 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4102 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4103 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4104 | |
| 4105 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4106 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4107 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4108 | FAIL() << "Did not receive Error 'Descriptor Set <blah> does not have " |
| 4109 | "binding to match update binding '"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4110 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4111 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4112 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4113 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4114 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4115 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4116 | } |
| 4117 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4118 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 4119 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 4120 | // types |
| 4121 | VkResult err; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4122 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4123 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4124 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4125 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4126 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4127 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4128 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4129 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4130 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4131 | |
| 4132 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4133 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4134 | ds_pool_ci.pNext = NULL; |
| 4135 | ds_pool_ci.maxSets = 1; |
| 4136 | ds_pool_ci.poolSizeCount = 1; |
| 4137 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4138 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4139 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4140 | err = |
| 4141 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4142 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4143 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4144 | dsl_binding.binding = 0; |
| 4145 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4146 | dsl_binding.descriptorCount = 1; |
| 4147 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4148 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4149 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4150 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4151 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4152 | ds_layout_ci.pNext = NULL; |
| 4153 | ds_layout_ci.bindingCount = 1; |
| 4154 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4155 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4156 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4157 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4158 | &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4159 | ASSERT_VK_SUCCESS(err); |
| 4160 | |
| 4161 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4162 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4163 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4164 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4165 | alloc_info.descriptorPool = ds_pool; |
| 4166 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4167 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4168 | &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4169 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4170 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4171 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4172 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4173 | sampler_ci.pNext = NULL; |
| 4174 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4175 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4176 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4177 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4178 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4179 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4180 | sampler_ci.mipLodBias = 1.0; |
| 4181 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4182 | sampler_ci.maxAnisotropy = 1; |
| 4183 | sampler_ci.compareEnable = VK_FALSE; |
| 4184 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4185 | sampler_ci.minLod = 1.0; |
| 4186 | sampler_ci.maxLod = 1.0; |
| 4187 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4188 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4189 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4190 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4191 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4192 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4193 | VkDescriptorImageInfo info = {}; |
| 4194 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4195 | |
| 4196 | VkWriteDescriptorSet descriptor_write; |
| 4197 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4198 | descriptor_write.sType = |
| 4199 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4200 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4201 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4202 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4203 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 4204 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 4205 | |
| 4206 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4207 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4208 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4209 | FAIL() << "Did not receive Error 'Unexpected UPDATE struct of type '"; |
| 4210 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4211 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4212 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4213 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4214 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4215 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4216 | } |
| 4217 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4218 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4219 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4220 | VkResult err; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4221 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4222 | m_errorMonitor->SetDesiredFailureMsg( |
| 4223 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4224 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 4225 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4226 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4227 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 4228 | // code |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4229 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4230 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4231 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4232 | |
| 4233 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4234 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4235 | ds_pool_ci.pNext = NULL; |
| 4236 | ds_pool_ci.maxSets = 1; |
| 4237 | ds_pool_ci.poolSizeCount = 1; |
| 4238 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4239 | |
| 4240 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4241 | err = |
| 4242 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4243 | ASSERT_VK_SUCCESS(err); |
| 4244 | |
| 4245 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4246 | dsl_binding.binding = 0; |
| 4247 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4248 | dsl_binding.descriptorCount = 1; |
| 4249 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4250 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4251 | |
| 4252 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4253 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4254 | ds_layout_ci.pNext = NULL; |
| 4255 | ds_layout_ci.bindingCount = 1; |
| 4256 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4257 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4258 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4259 | &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4260 | ASSERT_VK_SUCCESS(err); |
| 4261 | |
| 4262 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4263 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4264 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4265 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4266 | alloc_info.descriptorPool = ds_pool; |
| 4267 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4268 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4269 | &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4270 | ASSERT_VK_SUCCESS(err); |
| 4271 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4272 | VkSampler sampler = |
| 4273 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4274 | |
| 4275 | VkDescriptorImageInfo descriptor_info; |
| 4276 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 4277 | descriptor_info.sampler = sampler; |
| 4278 | |
| 4279 | VkWriteDescriptorSet descriptor_write; |
| 4280 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4281 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4282 | descriptor_write.dstSet = descriptorSet; |
| 4283 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4284 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4285 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4286 | descriptor_write.pImageInfo = &descriptor_info; |
| 4287 | |
| 4288 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4289 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4290 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4291 | FAIL() << "Did not receive Error 'Attempt to update descriptor with " |
| 4292 | "invalid sampler...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4293 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4294 | } |
| 4295 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4296 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4297 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4298 | } |
| 4299 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4300 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 4301 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 4302 | // imageView |
| 4303 | VkResult err; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4304 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4305 | m_errorMonitor->SetDesiredFailureMsg( |
| 4306 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4307 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 4308 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4309 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4310 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4311 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4312 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4313 | |
| 4314 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4315 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4316 | ds_pool_ci.pNext = NULL; |
| 4317 | ds_pool_ci.maxSets = 1; |
| 4318 | ds_pool_ci.poolSizeCount = 1; |
| 4319 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4320 | |
| 4321 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4322 | err = |
| 4323 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4324 | ASSERT_VK_SUCCESS(err); |
| 4325 | |
| 4326 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4327 | dsl_binding.binding = 0; |
| 4328 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4329 | dsl_binding.descriptorCount = 1; |
| 4330 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4331 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4332 | |
| 4333 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4334 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4335 | ds_layout_ci.pNext = NULL; |
| 4336 | ds_layout_ci.bindingCount = 1; |
| 4337 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4338 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4339 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4340 | &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4341 | ASSERT_VK_SUCCESS(err); |
| 4342 | |
| 4343 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4344 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4345 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4346 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4347 | alloc_info.descriptorPool = ds_pool; |
| 4348 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4349 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4350 | &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4351 | ASSERT_VK_SUCCESS(err); |
| 4352 | |
| 4353 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4354 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4355 | sampler_ci.pNext = NULL; |
| 4356 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4357 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4358 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4359 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4360 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4361 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4362 | sampler_ci.mipLodBias = 1.0; |
| 4363 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4364 | sampler_ci.maxAnisotropy = 1; |
| 4365 | sampler_ci.compareEnable = VK_FALSE; |
| 4366 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4367 | sampler_ci.minLod = 1.0; |
| 4368 | sampler_ci.maxLod = 1.0; |
| 4369 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4370 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4371 | |
| 4372 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4373 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4374 | ASSERT_VK_SUCCESS(err); |
| 4375 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4376 | VkImageView view = |
| 4377 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4378 | |
| 4379 | VkDescriptorImageInfo descriptor_info; |
| 4380 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 4381 | descriptor_info.sampler = sampler; |
| 4382 | descriptor_info.imageView = view; |
| 4383 | |
| 4384 | VkWriteDescriptorSet descriptor_write; |
| 4385 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4386 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4387 | descriptor_write.dstSet = descriptorSet; |
| 4388 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4389 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4390 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4391 | descriptor_write.pImageInfo = &descriptor_info; |
| 4392 | |
| 4393 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4394 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4395 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4396 | FAIL() << "Did not receive Error 'Attempt to update descriptor with " |
| 4397 | "invalid imageView...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4398 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4399 | } |
| 4400 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4401 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4402 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4403 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4404 | } |
| 4405 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4406 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 4407 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 4408 | // into the other |
| 4409 | VkResult err; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4410 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4411 | m_errorMonitor->SetDesiredFailureMsg( |
| 4412 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Copy descriptor update index 0, update " |
| 4413 | "count #1, has src update descriptor " |
| 4414 | "type VK_DESCRIPTOR_TYPE_SAMPLER "); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4415 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4416 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4417 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4418 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4419 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4420 | ds_type_count[0].descriptorCount = 1; |
| 4421 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4422 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4423 | |
| 4424 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4425 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4426 | ds_pool_ci.pNext = NULL; |
| 4427 | ds_pool_ci.maxSets = 1; |
| 4428 | ds_pool_ci.poolSizeCount = 2; |
| 4429 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4430 | |
| 4431 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4432 | err = |
| 4433 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4434 | ASSERT_VK_SUCCESS(err); |
| 4435 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4436 | dsl_binding[0].binding = 0; |
| 4437 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4438 | dsl_binding[0].descriptorCount = 1; |
| 4439 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4440 | dsl_binding[0].pImmutableSamplers = NULL; |
| 4441 | dsl_binding[1].binding = 1; |
| 4442 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4443 | dsl_binding[1].descriptorCount = 1; |
| 4444 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 4445 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4446 | |
| 4447 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4448 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4449 | ds_layout_ci.pNext = NULL; |
| 4450 | ds_layout_ci.bindingCount = 2; |
| 4451 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4452 | |
| 4453 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4454 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4455 | &ds_layout); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4456 | ASSERT_VK_SUCCESS(err); |
| 4457 | |
| 4458 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4459 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4460 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4461 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4462 | alloc_info.descriptorPool = ds_pool; |
| 4463 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4464 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4465 | &descriptorSet); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4466 | ASSERT_VK_SUCCESS(err); |
| 4467 | |
| 4468 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4469 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4470 | sampler_ci.pNext = NULL; |
| 4471 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4472 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4473 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4474 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4475 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4476 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4477 | sampler_ci.mipLodBias = 1.0; |
| 4478 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4479 | sampler_ci.maxAnisotropy = 1; |
| 4480 | sampler_ci.compareEnable = VK_FALSE; |
| 4481 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4482 | sampler_ci.minLod = 1.0; |
| 4483 | sampler_ci.maxLod = 1.0; |
| 4484 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4485 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4486 | |
| 4487 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4488 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4489 | ASSERT_VK_SUCCESS(err); |
| 4490 | |
| 4491 | VkDescriptorImageInfo info = {}; |
| 4492 | info.sampler = sampler; |
| 4493 | |
| 4494 | VkWriteDescriptorSet descriptor_write; |
| 4495 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 4496 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4497 | descriptor_write.dstSet = descriptorSet; |
| 4498 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4499 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4500 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4501 | descriptor_write.pImageInfo = &info; |
| 4502 | // This write update should succeed |
| 4503 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4504 | // Now perform a copy update that fails due to type mismatch |
| 4505 | VkCopyDescriptorSet copy_ds_update; |
| 4506 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4507 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4508 | copy_ds_update.srcSet = descriptorSet; |
| 4509 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4510 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4511 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4512 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4513 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4514 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4515 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4516 | FAIL() << "Did not receive Error 'Copy descriptor update index 0, " |
| 4517 | "update count #1, has src update descriptor " |
| 4518 | "type_DESCRIPTOR_TYPE_SAMPLER'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4519 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4520 | } |
| 4521 | // Now perform a copy update that fails due to binding out of bounds |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4522 | m_errorMonitor->SetDesiredFailureMsg( |
| 4523 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4524 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4525 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4526 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4527 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4528 | copy_ds_update.srcBinding = |
| 4529 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4530 | copy_ds_update.dstSet = descriptorSet; |
| 4531 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4532 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4533 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4534 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4535 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4536 | FAIL() << "Did not receive Error 'Copy descriptor update 0 has " |
| 4537 | "srcBinding 3 which is out of bounds...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4538 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4539 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4540 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4541 | // Now perform a copy update that fails due to binding out of bounds |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4542 | m_errorMonitor->SetDesiredFailureMsg( |
| 4543 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4544 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 4545 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4546 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4547 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4548 | copy_ds_update.srcSet = descriptorSet; |
| 4549 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4550 | copy_ds_update.dstSet = descriptorSet; |
| 4551 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4552 | copy_ds_update.descriptorCount = |
| 4553 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4554 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4555 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4556 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4557 | FAIL() << "Did not receive Error 'Copy descriptor src update is out of " |
| 4558 | "bounds for matching binding 1...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4559 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4560 | } |
| 4561 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4562 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4563 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4564 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4565 | } |
| 4566 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4567 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 4568 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 4569 | // sampleCount |
| 4570 | VkResult err; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4571 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4572 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4573 | "Num samples mismatch! "); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4574 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4575 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4576 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4577 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4578 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4579 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4580 | |
| 4581 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4582 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4583 | ds_pool_ci.pNext = NULL; |
| 4584 | ds_pool_ci.maxSets = 1; |
| 4585 | ds_pool_ci.poolSizeCount = 1; |
| 4586 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4587 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4588 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4589 | err = |
| 4590 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4591 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4592 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4593 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4594 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4595 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4596 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4597 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4598 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4599 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4600 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4601 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4602 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4603 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | adb6135 | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4604 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4605 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4606 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4607 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4608 | &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4609 | ASSERT_VK_SUCCESS(err); |
| 4610 | |
| 4611 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4612 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4613 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4614 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4615 | alloc_info.descriptorPool = ds_pool; |
| 4616 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4617 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4618 | &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4619 | ASSERT_VK_SUCCESS(err); |
| 4620 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4621 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4622 | pipe_ms_state_ci.sType = |
| 4623 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4624 | pipe_ms_state_ci.pNext = NULL; |
| 4625 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 4626 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4627 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4628 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4629 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4630 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4631 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4632 | pipeline_layout_ci.pNext = NULL; |
| 4633 | pipeline_layout_ci.setLayoutCount = 1; |
| 4634 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4635 | |
| 4636 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4637 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4638 | &pipeline_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4639 | ASSERT_VK_SUCCESS(err); |
| 4640 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4641 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4642 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4643 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4644 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4645 | this); // TODO - We shouldn't need a fragment shader |
| 4646 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4647 | VkPipelineObj pipe(m_device); |
| 4648 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4649 | pipe.AddShader(&fs); |
Mark Young | 0292df5 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4650 | pipe.AddColorAttachment(); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4651 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4652 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4653 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4654 | BeginCommandBuffer(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4655 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4656 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4657 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4658 | if (!m_errorMonitor->DesiredMsgFound()) { |
Eric Engestrom | 9bdcb23 | 2016-04-02 22:08:10 +0100 | [diff] [blame] | 4659 | FAIL() << "Did not receive Error 'Num samples mismatch!...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4660 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4661 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4662 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4663 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4664 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4665 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4666 | } |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4667 | |
Mark Young | 0292df5 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4668 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 4669 | // Create Pipeline where the number of blend attachments doesn't match the |
| 4670 | // number of color attachments. In this case, we don't add any color |
| 4671 | // blend attachments even though we have a color attachment. |
| 4672 | VkResult err; |
| 4673 | |
| 4674 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4675 | "Mismatch between blend state attachment"); |
| 4676 | |
| 4677 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4678 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4679 | VkDescriptorPoolSize ds_type_count = {}; |
| 4680 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4681 | ds_type_count.descriptorCount = 1; |
| 4682 | |
| 4683 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4684 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4685 | ds_pool_ci.pNext = NULL; |
| 4686 | ds_pool_ci.maxSets = 1; |
| 4687 | ds_pool_ci.poolSizeCount = 1; |
| 4688 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4689 | |
| 4690 | VkDescriptorPool ds_pool; |
| 4691 | err = |
| 4692 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4693 | ASSERT_VK_SUCCESS(err); |
| 4694 | |
| 4695 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4696 | dsl_binding.binding = 0; |
| 4697 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4698 | dsl_binding.descriptorCount = 1; |
| 4699 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4700 | dsl_binding.pImmutableSamplers = NULL; |
| 4701 | |
| 4702 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4703 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4704 | ds_layout_ci.pNext = NULL; |
| 4705 | ds_layout_ci.bindingCount = 1; |
| 4706 | ds_layout_ci.pBindings = &dsl_binding; |
| 4707 | |
| 4708 | VkDescriptorSetLayout ds_layout; |
| 4709 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4710 | &ds_layout); |
| 4711 | ASSERT_VK_SUCCESS(err); |
| 4712 | |
| 4713 | VkDescriptorSet descriptorSet; |
| 4714 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4715 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4716 | alloc_info.descriptorSetCount = 1; |
| 4717 | alloc_info.descriptorPool = ds_pool; |
| 4718 | alloc_info.pSetLayouts = &ds_layout; |
| 4719 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4720 | &descriptorSet); |
| 4721 | ASSERT_VK_SUCCESS(err); |
| 4722 | |
| 4723 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4724 | pipe_ms_state_ci.sType = |
| 4725 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4726 | pipe_ms_state_ci.pNext = NULL; |
| 4727 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 4728 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4729 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4730 | pipe_ms_state_ci.pSampleMask = NULL; |
| 4731 | |
| 4732 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4733 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4734 | pipeline_layout_ci.pNext = NULL; |
| 4735 | pipeline_layout_ci.setLayoutCount = 1; |
| 4736 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4737 | |
| 4738 | VkPipelineLayout pipeline_layout; |
| 4739 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4740 | &pipeline_layout); |
| 4741 | ASSERT_VK_SUCCESS(err); |
| 4742 | |
| 4743 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4744 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4745 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4746 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4747 | this); // TODO - We shouldn't need a fragment shader |
| 4748 | // but add it to be able to run on more devices |
| 4749 | VkPipelineObj pipe(m_device); |
| 4750 | pipe.AddShader(&vs); |
| 4751 | pipe.AddShader(&fs); |
| 4752 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4753 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4754 | |
| 4755 | BeginCommandBuffer(); |
| 4756 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4757 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4758 | |
| 4759 | if (!m_errorMonitor->DesiredMsgFound()) { |
Eric Engestrom | 9bdcb23 | 2016-04-02 22:08:10 +0100 | [diff] [blame] | 4760 | FAIL() << "Did not receive Error 'Mismatch between blend state attachment...'"; |
Mark Young | 0292df5 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4761 | m_errorMonitor->DumpFailureMsgs(); |
| 4762 | } |
| 4763 | |
| 4764 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4765 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4766 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4767 | } |
| 4768 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4769 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 4770 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 4771 | // to issuing a Draw |
| 4772 | VkResult err; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4773 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4774 | // TODO: verify that this matches layer |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4775 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | c7dea5e | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 4776 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4777 | "vkCmdClearAttachments() issued on CB object "); |
| 4778 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4779 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4780 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4781 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4782 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4783 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4784 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4785 | |
| 4786 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4787 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4788 | ds_pool_ci.pNext = NULL; |
| 4789 | ds_pool_ci.maxSets = 1; |
| 4790 | ds_pool_ci.poolSizeCount = 1; |
| 4791 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4792 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4793 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4794 | err = |
| 4795 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4796 | ASSERT_VK_SUCCESS(err); |
| 4797 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4798 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4799 | dsl_binding.binding = 0; |
| 4800 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4801 | dsl_binding.descriptorCount = 1; |
| 4802 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4803 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4804 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4805 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4806 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4807 | ds_layout_ci.pNext = NULL; |
| 4808 | ds_layout_ci.bindingCount = 1; |
| 4809 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4810 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4811 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4812 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4813 | &ds_layout); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4814 | ASSERT_VK_SUCCESS(err); |
| 4815 | |
| 4816 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4817 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4818 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4819 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4820 | alloc_info.descriptorPool = ds_pool; |
| 4821 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4822 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4823 | &descriptorSet); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4824 | ASSERT_VK_SUCCESS(err); |
| 4825 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4826 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4827 | pipe_ms_state_ci.sType = |
| 4828 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4829 | pipe_ms_state_ci.pNext = NULL; |
| 4830 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 4831 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4832 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4833 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4834 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4835 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4836 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4837 | pipeline_layout_ci.pNext = NULL; |
| 4838 | pipeline_layout_ci.setLayoutCount = 1; |
| 4839 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4840 | |
| 4841 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4842 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4843 | &pipeline_layout); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4844 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4845 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4846 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4847 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4848 | // TODO - We shouldn't need a fragment shader but add it to be able to run |
| 4849 | // on more devices |
| 4850 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4851 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4852 | |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4853 | VkPipelineObj pipe(m_device); |
| 4854 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4855 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4856 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4857 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4858 | |
| 4859 | BeginCommandBuffer(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4860 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4861 | // Main thing we care about for this test is that the VkImage obj we're |
| 4862 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4863 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4864 | VkClearAttachment color_attachment; |
| 4865 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4866 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 4867 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 4868 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 4869 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 4870 | color_attachment.colorAttachment = 0; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4871 | VkClearRect clear_rect = { |
| 4872 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4873 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4874 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 4875 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4876 | |
| 4877 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4878 | FAIL() << "Did not receive Error 'vkCommandClearAttachments() issued " |
| 4879 | "on CB object...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4880 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4881 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4882 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4883 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4884 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4885 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4886 | } |
| 4887 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4888 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 4889 | VkResult err; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4890 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4891 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4892 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 74e8469 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 4893 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4894 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4895 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4896 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4897 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4898 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4899 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4900 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4901 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4902 | |
| 4903 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4904 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4905 | ds_pool_ci.pNext = NULL; |
| 4906 | ds_pool_ci.maxSets = 1; |
| 4907 | ds_pool_ci.poolSizeCount = 1; |
| 4908 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4909 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4910 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4911 | err = |
| 4912 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4913 | ASSERT_VK_SUCCESS(err); |
| 4914 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4915 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4916 | dsl_binding.binding = 0; |
| 4917 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4918 | dsl_binding.descriptorCount = 1; |
| 4919 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4920 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4921 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4922 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4923 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4924 | ds_layout_ci.pNext = NULL; |
| 4925 | ds_layout_ci.bindingCount = 1; |
| 4926 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4927 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4928 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4929 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4930 | &ds_layout); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4931 | ASSERT_VK_SUCCESS(err); |
| 4932 | |
| 4933 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4934 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4935 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4936 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4937 | alloc_info.descriptorPool = ds_pool; |
| 4938 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4939 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4940 | &descriptorSet); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4941 | ASSERT_VK_SUCCESS(err); |
| 4942 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4943 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4944 | pipe_ms_state_ci.sType = |
| 4945 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4946 | pipe_ms_state_ci.pNext = NULL; |
| 4947 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 4948 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4949 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4950 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4951 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4952 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4953 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4954 | pipeline_layout_ci.pNext = NULL; |
| 4955 | pipeline_layout_ci.setLayoutCount = 1; |
| 4956 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4957 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4958 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4959 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4960 | &pipeline_layout); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4961 | ASSERT_VK_SUCCESS(err); |
| 4962 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4963 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4964 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4965 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4966 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4967 | this); // TODO - We shouldn't need a fragment shader |
| 4968 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4969 | VkPipelineObj pipe(m_device); |
| 4970 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4971 | pipe.AddShader(&fs); |
Mark Young | 0292df5 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4972 | pipe.AddColorAttachment(); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4973 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4974 | pipe.SetViewport(m_viewports); |
| 4975 | pipe.SetScissor(m_scissors); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4976 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4977 | |
| 4978 | BeginCommandBuffer(); |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4979 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4980 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | d28acef | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4981 | // Don't care about actual data, just need to get to draw to flag error |
| 4982 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4983 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 4984 | (const void *)&vbo_data); |
Tobin Ehlis | d28acef | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4985 | BindVertexBuffer(&vbo, (VkDeviceSize)0, 1); // VBO idx 1, but no VBO in PSO |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 4986 | Draw(1, 0, 0, 0); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4987 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4988 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4989 | FAIL() << "Did not receive Error 'Vtx Buffer Index 0 was bound, but no " |
| 4990 | "vtx buffers are attached to PSO.'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4991 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4992 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4993 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4994 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4995 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4996 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4997 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4998 | #endif // DRAW_STATE_TESTS |
| 4999 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 5000 | #if THREADING_TESTS |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5001 | #if GTEST_IS_THREADSAFE |
| 5002 | struct thread_data_struct { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5003 | VkCommandBuffer commandBuffer; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5004 | VkEvent event; |
| 5005 | bool bailout; |
| 5006 | }; |
| 5007 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5008 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 5009 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5010 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5011 | for (int i = 0; i < 10000; i++) { |
| 5012 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 5013 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5014 | if (data->bailout) { |
| 5015 | break; |
| 5016 | } |
| 5017 | } |
| 5018 | return NULL; |
| 5019 | } |
| 5020 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5021 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 5022 | test_platform_thread thread; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5023 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5024 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5025 | "THREADING ERROR"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5026 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5027 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5028 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5029 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5030 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5031 | // Calls AllocateCommandBuffers |
| 5032 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 5033 | |
| 5034 | // Avoid creating RenderPass |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5035 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5036 | |
| 5037 | VkEventCreateInfo event_info; |
| 5038 | VkEvent event; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5039 | VkResult err; |
| 5040 | |
| 5041 | memset(&event_info, 0, sizeof(event_info)); |
| 5042 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 5043 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5044 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5045 | ASSERT_VK_SUCCESS(err); |
| 5046 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5047 | err = vkResetEvent(device(), event); |
| 5048 | ASSERT_VK_SUCCESS(err); |
| 5049 | |
| 5050 | struct thread_data_struct data; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5051 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5052 | data.event = event; |
| 5053 | data.bailout = false; |
| 5054 | m_errorMonitor->SetBailout(&data.bailout); |
| 5055 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 5056 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5057 | // Add many entries to command buffer from this thread at the same time. |
| 5058 | AddToCommandBuffer(&data); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 5059 | |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 5060 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5061 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5062 | |
Mike Stroyan | 450b057 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 5063 | m_errorMonitor->SetBailout(NULL); |
| 5064 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5065 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5066 | FAIL() << "Did not receive Error 'THREADING ERROR' from using one " |
| 5067 | "VkCommandBufferObj in two threads"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5068 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5069 | } |
| 5070 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5071 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 5072 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5073 | #endif // GTEST_IS_THREADSAFE |
| 5074 | #endif // THREADING_TESTS |
| 5075 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5076 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5077 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5078 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5079 | "Shader is not SPIR-V"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5080 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5081 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5082 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5083 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5084 | VkShaderModule module; |
| 5085 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 5086 | struct icd_spv_header spv; |
| 5087 | |
| 5088 | spv.magic = ICD_SPV_MAGIC; |
| 5089 | spv.version = ICD_SPV_VERSION; |
| 5090 | spv.gen_magic = 0; |
| 5091 | |
| 5092 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 5093 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5094 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5095 | moduleCreateInfo.codeSize = 4; |
| 5096 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5097 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5098 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5099 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5100 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 5101 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5102 | } |
| 5103 | } |
| 5104 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5105 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5106 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5107 | "Shader is not SPIR-V"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5108 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5109 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5110 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5111 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5112 | VkShaderModule module; |
| 5113 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 5114 | struct icd_spv_header spv; |
| 5115 | |
| 5116 | spv.magic = ~ICD_SPV_MAGIC; |
| 5117 | spv.version = ICD_SPV_VERSION; |
| 5118 | spv.gen_magic = 0; |
| 5119 | |
| 5120 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 5121 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5122 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5123 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 5124 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5125 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5126 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5127 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5128 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 5129 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5130 | } |
| 5131 | } |
| 5132 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5133 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5134 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5135 | "Shader is not SPIR-V"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5136 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5137 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5138 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5139 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5140 | VkShaderModule module; |
| 5141 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 5142 | struct icd_spv_header spv; |
| 5143 | |
| 5144 | spv.magic = ICD_SPV_MAGIC; |
| 5145 | spv.version = ~ICD_SPV_VERSION; |
| 5146 | spv.gen_magic = 0; |
| 5147 | |
| 5148 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 5149 | moduleCreateInfo.pNext = NULL; |
| 5150 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5151 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5152 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 5153 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5154 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5155 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5156 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5157 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 5158 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 5159 | } |
| 5160 | } |
| 5161 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5162 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5163 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5164 | "not consumed by fragment shader"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5165 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5166 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5167 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5168 | |
| 5169 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5170 | "#version 450\n" |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5171 | "\n" |
| 5172 | "layout(location=0) out float x;\n" |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5173 | "out gl_PerVertex {\n" |
| 5174 | " vec4 gl_Position;\n" |
| 5175 | "};\n" |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5176 | "void main(){\n" |
| 5177 | " gl_Position = vec4(1);\n" |
| 5178 | " x = 0;\n" |
| 5179 | "}\n"; |
| 5180 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5181 | "#version 450\n" |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5182 | "\n" |
| 5183 | "layout(location=0) out vec4 color;\n" |
| 5184 | "void main(){\n" |
| 5185 | " color = vec4(1);\n" |
| 5186 | "}\n"; |
| 5187 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5188 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5189 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5190 | |
| 5191 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5192 | pipe.AddColorAttachment(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5193 | pipe.AddShader(&vs); |
| 5194 | pipe.AddShader(&fs); |
| 5195 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5196 | VkDescriptorSetObj descriptorSet(m_device); |
| 5197 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5198 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5199 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5200 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5201 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5202 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5203 | FAIL() << "Did not receive Warning 'not consumed by fragment shader'"; |
| 5204 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5205 | } |
| 5206 | } |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 5207 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5208 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5209 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5210 | "not written by vertex shader"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5211 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5212 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5213 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5214 | |
| 5215 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5216 | "#version 450\n" |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5217 | "\n" |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5218 | "out gl_PerVertex {\n" |
| 5219 | " vec4 gl_Position;\n" |
| 5220 | "};\n" |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5221 | "void main(){\n" |
| 5222 | " gl_Position = vec4(1);\n" |
| 5223 | "}\n"; |
| 5224 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5225 | "#version 450\n" |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5226 | "\n" |
| 5227 | "layout(location=0) in float x;\n" |
| 5228 | "layout(location=0) out vec4 color;\n" |
| 5229 | "void main(){\n" |
| 5230 | " color = vec4(x);\n" |
| 5231 | "}\n"; |
| 5232 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5233 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5234 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5235 | |
| 5236 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5237 | pipe.AddColorAttachment(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5238 | pipe.AddShader(&vs); |
| 5239 | pipe.AddShader(&fs); |
| 5240 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5241 | VkDescriptorSetObj descriptorSet(m_device); |
| 5242 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5243 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5244 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5245 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5246 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5247 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5248 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 5249 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 5250 | } |
| 5251 | } |
| 5252 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5253 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | 780820a | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5254 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5255 | "not written by vertex shader"); |
Chris Forbes | 780820a | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5256 | |
| 5257 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5258 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5259 | |
| 5260 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5261 | "#version 450\n" |
Chris Forbes | 780820a | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5262 | "\n" |
| 5263 | "out gl_PerVertex {\n" |
| 5264 | " vec4 gl_Position;\n" |
| 5265 | "};\n" |
| 5266 | "void main(){\n" |
| 5267 | " gl_Position = vec4(1);\n" |
| 5268 | "}\n"; |
| 5269 | char const *fsSource = |
| 5270 | "#version 450\n" |
Chris Forbes | 780820a | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5271 | "\n" |
| 5272 | "in block { layout(location=0) float x; } ins;\n" |
| 5273 | "layout(location=0) out vec4 color;\n" |
| 5274 | "void main(){\n" |
| 5275 | " color = vec4(ins.x);\n" |
| 5276 | "}\n"; |
| 5277 | |
| 5278 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5279 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5280 | |
| 5281 | VkPipelineObj pipe(m_device); |
| 5282 | pipe.AddColorAttachment(); |
| 5283 | pipe.AddShader(&vs); |
| 5284 | pipe.AddShader(&fs); |
| 5285 | |
| 5286 | VkDescriptorSetObj descriptorSet(m_device); |
| 5287 | descriptorSet.AppendDummy(); |
| 5288 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5289 | |
| 5290 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5291 | |
| 5292 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5293 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 5294 | m_errorMonitor->DumpFailureMsgs(); |
| 5295 | } |
| 5296 | } |
| 5297 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5298 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | f14d10d | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5299 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | 12c72a4 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5300 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5301 | "output arr[2] of float32' vs 'ptr to " |
| 5302 | "input arr[3] of float32'"); |
Chris Forbes | f14d10d | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5303 | |
| 5304 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5305 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5306 | |
| 5307 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5308 | "#version 450\n" |
Chris Forbes | f14d10d | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5309 | "\n" |
| 5310 | "layout(location=0) out float x[2];\n" |
| 5311 | "out gl_PerVertex {\n" |
| 5312 | " vec4 gl_Position;\n" |
| 5313 | "};\n" |
| 5314 | "void main(){\n" |
| 5315 | " x[0] = 0; x[1] = 0;\n" |
| 5316 | " gl_Position = vec4(1);\n" |
| 5317 | "}\n"; |
| 5318 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5319 | "#version 450\n" |
Chris Forbes | f14d10d | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5320 | "\n" |
| 5321 | "layout(location=0) in float x[3];\n" |
| 5322 | "layout(location=0) out vec4 color;\n" |
| 5323 | "void main(){\n" |
| 5324 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 5325 | "}\n"; |
| 5326 | |
| 5327 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5328 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5329 | |
| 5330 | VkPipelineObj pipe(m_device); |
| 5331 | pipe.AddColorAttachment(); |
| 5332 | pipe.AddShader(&vs); |
| 5333 | pipe.AddShader(&fs); |
| 5334 | |
| 5335 | VkDescriptorSetObj descriptorSet(m_device); |
| 5336 | descriptorSet.AppendDummy(); |
| 5337 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5338 | |
| 5339 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5340 | |
| 5341 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5342 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 12c72a4 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5343 | FAIL() << "Did not receive Error 'Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5344 | "output arr[2] of float32' vs 'ptr to input arr[3] of " |
| 5345 | "float32''"; |
Chris Forbes | f14d10d | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 5346 | } |
| 5347 | } |
| 5348 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5349 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5350 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5351 | "Type mismatch on location 0"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5352 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5353 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5354 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5355 | |
| 5356 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5357 | "#version 450\n" |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5358 | "\n" |
| 5359 | "layout(location=0) out int x;\n" |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5360 | "out gl_PerVertex {\n" |
| 5361 | " vec4 gl_Position;\n" |
| 5362 | "};\n" |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5363 | "void main(){\n" |
| 5364 | " x = 0;\n" |
| 5365 | " gl_Position = vec4(1);\n" |
| 5366 | "}\n"; |
| 5367 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5368 | "#version 450\n" |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5369 | "\n" |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5370 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5371 | "layout(location=0) out vec4 color;\n" |
| 5372 | "void main(){\n" |
| 5373 | " color = vec4(x);\n" |
| 5374 | "}\n"; |
| 5375 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5376 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5377 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5378 | |
| 5379 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5380 | pipe.AddColorAttachment(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5381 | pipe.AddShader(&vs); |
| 5382 | pipe.AddShader(&fs); |
| 5383 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5384 | VkDescriptorSetObj descriptorSet(m_device); |
| 5385 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5386 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5387 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5388 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5389 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5390 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5391 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 5392 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5393 | } |
| 5394 | } |
| 5395 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5396 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | 780820a | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5397 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5398 | "Type mismatch on location 0"); |
Chris Forbes | 780820a | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5399 | |
| 5400 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5401 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5402 | |
| 5403 | char const *vsSource = |
| 5404 | "#version 450\n" |
Chris Forbes | 780820a | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5405 | "\n" |
| 5406 | "out block { layout(location=0) int x; } outs;\n" |
| 5407 | "out gl_PerVertex {\n" |
| 5408 | " vec4 gl_Position;\n" |
| 5409 | "};\n" |
| 5410 | "void main(){\n" |
| 5411 | " outs.x = 0;\n" |
| 5412 | " gl_Position = vec4(1);\n" |
| 5413 | "}\n"; |
| 5414 | char const *fsSource = |
| 5415 | "#version 450\n" |
Chris Forbes | 780820a | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5416 | "\n" |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5417 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | 780820a | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5418 | "layout(location=0) out vec4 color;\n" |
| 5419 | "void main(){\n" |
| 5420 | " color = vec4(ins.x);\n" |
| 5421 | "}\n"; |
| 5422 | |
| 5423 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5424 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5425 | |
| 5426 | VkPipelineObj pipe(m_device); |
| 5427 | pipe.AddColorAttachment(); |
| 5428 | pipe.AddShader(&vs); |
| 5429 | pipe.AddShader(&fs); |
| 5430 | |
| 5431 | VkDescriptorSetObj descriptorSet(m_device); |
| 5432 | descriptorSet.AppendDummy(); |
| 5433 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5434 | |
| 5435 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5436 | |
| 5437 | if (!m_errorMonitor->DesiredMsgFound()) { |
Chris Forbes | 780820a | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5438 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 12c72a4 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5439 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 5440 | } |
| 5441 | } |
| 5442 | |
| 5443 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 5444 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5445 | "location 0.0 which is not written by vertex shader"); |
| 5446 | |
| 5447 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5448 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5449 | |
| 5450 | char const *vsSource = |
| 5451 | "#version 450\n" |
Chris Forbes | 12c72a4 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5452 | "\n" |
| 5453 | "out block { layout(location=1) float x; } outs;\n" |
| 5454 | "out gl_PerVertex {\n" |
| 5455 | " vec4 gl_Position;\n" |
| 5456 | "};\n" |
| 5457 | "void main(){\n" |
| 5458 | " outs.x = 0;\n" |
| 5459 | " gl_Position = vec4(1);\n" |
| 5460 | "}\n"; |
| 5461 | char const *fsSource = |
| 5462 | "#version 450\n" |
Chris Forbes | 12c72a4 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5463 | "\n" |
| 5464 | "in block { layout(location=0) float x; } ins;\n" |
| 5465 | "layout(location=0) out vec4 color;\n" |
| 5466 | "void main(){\n" |
| 5467 | " color = vec4(ins.x);\n" |
| 5468 | "}\n"; |
| 5469 | |
| 5470 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5471 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5472 | |
| 5473 | VkPipelineObj pipe(m_device); |
| 5474 | pipe.AddColorAttachment(); |
| 5475 | pipe.AddShader(&vs); |
| 5476 | pipe.AddShader(&fs); |
| 5477 | |
| 5478 | VkDescriptorSetObj descriptorSet(m_device); |
| 5479 | descriptorSet.AppendDummy(); |
| 5480 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5481 | |
| 5482 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5483 | |
| 5484 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5485 | m_errorMonitor->DumpFailureMsgs(); |
| 5486 | FAIL() << "Did not receive Error 'location 0.0 which is not written by vertex shader'"; |
| 5487 | } |
| 5488 | } |
| 5489 | |
| 5490 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 5491 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5492 | "location 0.1 which is not written by vertex shader"); |
| 5493 | |
| 5494 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5495 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5496 | |
| 5497 | char const *vsSource = |
| 5498 | "#version 450\n" |
Chris Forbes | 12c72a4 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5499 | "\n" |
| 5500 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 5501 | "out gl_PerVertex {\n" |
| 5502 | " vec4 gl_Position;\n" |
| 5503 | "};\n" |
| 5504 | "void main(){\n" |
| 5505 | " outs.x = 0;\n" |
| 5506 | " gl_Position = vec4(1);\n" |
| 5507 | "}\n"; |
| 5508 | char const *fsSource = |
| 5509 | "#version 450\n" |
Chris Forbes | 12c72a4 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5510 | "\n" |
| 5511 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 5512 | "layout(location=0) out vec4 color;\n" |
| 5513 | "void main(){\n" |
| 5514 | " color = vec4(ins.x);\n" |
| 5515 | "}\n"; |
| 5516 | |
| 5517 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5518 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5519 | |
| 5520 | VkPipelineObj pipe(m_device); |
| 5521 | pipe.AddColorAttachment(); |
| 5522 | pipe.AddShader(&vs); |
| 5523 | pipe.AddShader(&fs); |
| 5524 | |
| 5525 | VkDescriptorSetObj descriptorSet(m_device); |
| 5526 | descriptorSet.AppendDummy(); |
| 5527 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5528 | |
| 5529 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5530 | |
| 5531 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5532 | m_errorMonitor->DumpFailureMsgs(); |
| 5533 | FAIL() << "Did not receive Error 'location 0.1 which is not written by vertex shader'"; |
Chris Forbes | 780820a | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5534 | } |
| 5535 | } |
| 5536 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5537 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5538 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5539 | "location 0 not consumed by VS"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5540 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5541 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5542 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5543 | |
| 5544 | VkVertexInputBindingDescription input_binding; |
| 5545 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5546 | |
| 5547 | VkVertexInputAttributeDescription input_attrib; |
| 5548 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5549 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5550 | |
| 5551 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5552 | "#version 450\n" |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5553 | "\n" |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5554 | "out gl_PerVertex {\n" |
| 5555 | " vec4 gl_Position;\n" |
| 5556 | "};\n" |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5557 | "void main(){\n" |
| 5558 | " gl_Position = vec4(1);\n" |
| 5559 | "}\n"; |
| 5560 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5561 | "#version 450\n" |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5562 | "\n" |
| 5563 | "layout(location=0) out vec4 color;\n" |
| 5564 | "void main(){\n" |
| 5565 | " color = vec4(1);\n" |
| 5566 | "}\n"; |
| 5567 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5568 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5569 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5570 | |
| 5571 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5572 | pipe.AddColorAttachment(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5573 | pipe.AddShader(&vs); |
| 5574 | pipe.AddShader(&fs); |
| 5575 | |
| 5576 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5577 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5578 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5579 | VkDescriptorSetObj descriptorSet(m_device); |
| 5580 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5581 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5582 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5583 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5584 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5585 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5586 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 5587 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5588 | } |
| 5589 | } |
| 5590 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5591 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5592 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5593 | "location 0 not consumed by VS"); |
Chris Forbes | 5e42b88 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5594 | |
| 5595 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5596 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5597 | |
| 5598 | VkVertexInputBindingDescription input_binding; |
| 5599 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5600 | |
| 5601 | VkVertexInputAttributeDescription input_attrib; |
| 5602 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5603 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5604 | |
| 5605 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5606 | "#version 450\n" |
Chris Forbes | 5e42b88 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5607 | "\n" |
| 5608 | "layout(location=1) in float x;\n" |
| 5609 | "out gl_PerVertex {\n" |
| 5610 | " vec4 gl_Position;\n" |
| 5611 | "};\n" |
| 5612 | "void main(){\n" |
| 5613 | " gl_Position = vec4(x);\n" |
| 5614 | "}\n"; |
| 5615 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5616 | "#version 450\n" |
Chris Forbes | 5e42b88 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5617 | "\n" |
| 5618 | "layout(location=0) out vec4 color;\n" |
| 5619 | "void main(){\n" |
| 5620 | " color = vec4(1);\n" |
| 5621 | "}\n"; |
| 5622 | |
| 5623 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5624 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5625 | |
| 5626 | VkPipelineObj pipe(m_device); |
| 5627 | pipe.AddColorAttachment(); |
| 5628 | pipe.AddShader(&vs); |
| 5629 | pipe.AddShader(&fs); |
| 5630 | |
| 5631 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5632 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5633 | |
| 5634 | VkDescriptorSetObj descriptorSet(m_device); |
| 5635 | descriptorSet.AppendDummy(); |
| 5636 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5637 | |
| 5638 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5639 | |
| 5640 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5641 | m_errorMonitor->DumpFailureMsgs(); |
| 5642 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 5643 | } |
| 5644 | } |
| 5645 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5646 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 5647 | m_errorMonitor->SetDesiredFailureMsg( |
| 5648 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5649 | "VS consumes input at location 0 but not provided"); |
| 5650 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5651 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5652 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5653 | |
| 5654 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5655 | "#version 450\n" |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5656 | "\n" |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5657 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5658 | "out gl_PerVertex {\n" |
| 5659 | " vec4 gl_Position;\n" |
| 5660 | "};\n" |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5661 | "void main(){\n" |
| 5662 | " gl_Position = x;\n" |
| 5663 | "}\n"; |
| 5664 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5665 | "#version 450\n" |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5666 | "\n" |
| 5667 | "layout(location=0) out vec4 color;\n" |
| 5668 | "void main(){\n" |
| 5669 | " color = vec4(1);\n" |
| 5670 | "}\n"; |
| 5671 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5672 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5673 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5674 | |
| 5675 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5676 | pipe.AddColorAttachment(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5677 | pipe.AddShader(&vs); |
| 5678 | pipe.AddShader(&fs); |
| 5679 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5680 | VkDescriptorSetObj descriptorSet(m_device); |
| 5681 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5682 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5683 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5684 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5685 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5686 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5687 | FAIL() << "Did not receive Error 'VS consumes input at location 0 but " |
| 5688 | "not provided'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5689 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5690 | } |
| 5691 | } |
| 5692 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5693 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 5694 | m_errorMonitor->SetDesiredFailureMsg( |
| 5695 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5696 | "location 0 does not match VS input type"); |
| 5697 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5698 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5699 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5700 | |
| 5701 | VkVertexInputBindingDescription input_binding; |
| 5702 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5703 | |
| 5704 | VkVertexInputAttributeDescription input_attrib; |
| 5705 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5706 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5707 | |
| 5708 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5709 | "#version 450\n" |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5710 | "\n" |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5711 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5712 | "out gl_PerVertex {\n" |
| 5713 | " vec4 gl_Position;\n" |
| 5714 | "};\n" |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5715 | "void main(){\n" |
| 5716 | " gl_Position = vec4(x);\n" |
| 5717 | "}\n"; |
| 5718 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5719 | "#version 450\n" |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5720 | "\n" |
| 5721 | "layout(location=0) out vec4 color;\n" |
| 5722 | "void main(){\n" |
| 5723 | " color = vec4(1);\n" |
| 5724 | "}\n"; |
| 5725 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5726 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5727 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5728 | |
| 5729 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5730 | pipe.AddColorAttachment(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5731 | pipe.AddShader(&vs); |
| 5732 | pipe.AddShader(&fs); |
| 5733 | |
| 5734 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5735 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5736 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5737 | VkDescriptorSetObj descriptorSet(m_device); |
| 5738 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5739 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5740 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5741 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5742 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5743 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5744 | FAIL() << "Did not receive Error 'location 0 does not match VS input " |
| 5745 | "type'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5746 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5747 | } |
| 5748 | } |
| 5749 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5750 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5751 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 5752 | |
| 5753 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5754 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5755 | |
| 5756 | VkVertexInputBindingDescription input_binding; |
| 5757 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5758 | |
| 5759 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5760 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5761 | |
| 5762 | for (int i = 0; i < 2; i++) { |
| 5763 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5764 | input_attribs[i].location = i; |
| 5765 | } |
| 5766 | |
| 5767 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5768 | "#version 450\n" |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5769 | "\n" |
| 5770 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5771 | "out gl_PerVertex {\n" |
| 5772 | " vec4 gl_Position;\n" |
| 5773 | "};\n" |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5774 | "void main(){\n" |
| 5775 | " gl_Position = x[0] + x[1];\n" |
| 5776 | "}\n"; |
| 5777 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5778 | "#version 450\n" |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5779 | "\n" |
| 5780 | "layout(location=0) out vec4 color;\n" |
| 5781 | "void main(){\n" |
| 5782 | " color = vec4(1);\n" |
| 5783 | "}\n"; |
| 5784 | |
| 5785 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5786 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5787 | |
| 5788 | VkPipelineObj pipe(m_device); |
| 5789 | pipe.AddColorAttachment(); |
| 5790 | pipe.AddShader(&vs); |
| 5791 | pipe.AddShader(&fs); |
| 5792 | |
| 5793 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5794 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5795 | |
| 5796 | VkDescriptorSetObj descriptorSet(m_device); |
| 5797 | descriptorSet.AppendDummy(); |
| 5798 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5799 | |
| 5800 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5801 | |
| 5802 | /* expect success */ |
| 5803 | if (m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5804 | FAIL() << "Expected to succeed but: " |
| 5805 | << m_errorMonitor->GetFailureMsg(); |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5806 | m_errorMonitor->DumpFailureMsgs(); |
| 5807 | } |
| 5808 | } |
| 5809 | |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5810 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 5811 | { |
| 5812 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 5813 | |
| 5814 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5815 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5816 | |
| 5817 | VkVertexInputBindingDescription input_binding; |
| 5818 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5819 | |
| 5820 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5821 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5822 | |
| 5823 | for (int i = 0; i < 2; i++) { |
| 5824 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5825 | input_attribs[i].location = i; |
| 5826 | } |
| 5827 | |
| 5828 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5829 | "#version 450\n" |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5830 | "\n" |
| 5831 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5832 | "out gl_PerVertex {\n" |
| 5833 | " vec4 gl_Position;\n" |
| 5834 | "};\n" |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5835 | "void main(){\n" |
| 5836 | " gl_Position = x[0] + x[1];\n" |
| 5837 | "}\n"; |
| 5838 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5839 | "#version 450\n" |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5840 | "\n" |
| 5841 | "layout(location=0) out vec4 color;\n" |
| 5842 | "void main(){\n" |
| 5843 | " color = vec4(1);\n" |
| 5844 | "}\n"; |
| 5845 | |
| 5846 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5847 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5848 | |
| 5849 | VkPipelineObj pipe(m_device); |
| 5850 | pipe.AddColorAttachment(); |
| 5851 | pipe.AddShader(&vs); |
| 5852 | pipe.AddShader(&fs); |
| 5853 | |
| 5854 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5855 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5856 | |
| 5857 | VkDescriptorSetObj descriptorSet(m_device); |
| 5858 | descriptorSet.AppendDummy(); |
| 5859 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5860 | |
| 5861 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5862 | |
| 5863 | if (m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5864 | FAIL() << "Expected to succeed but: " << |
| 5865 | m_errorMonitor->GetFailureMsg(); |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5866 | m_errorMonitor->DumpFailureMsgs(); |
| 5867 | } |
| 5868 | } |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5869 | |
Chris Forbes | f778216 | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5870 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 5871 | { |
| 5872 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 5873 | |
| 5874 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5875 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5876 | |
| 5877 | char const *vsSource = |
| 5878 | "#version 450\n" |
| 5879 | "out gl_PerVertex {\n" |
| 5880 | " vec4 gl_Position;\n" |
| 5881 | "};\n" |
| 5882 | "void main(){\n" |
| 5883 | " gl_Position = vec4(0);\n" |
| 5884 | "}\n"; |
| 5885 | char const *fsSource = |
| 5886 | "#version 450\n" |
| 5887 | "\n" |
| 5888 | "layout(location=0) out vec4 color;\n" |
| 5889 | "void main(){\n" |
| 5890 | " color = vec4(1);\n" |
| 5891 | "}\n"; |
| 5892 | |
| 5893 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5894 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5895 | |
| 5896 | VkPipelineObj pipe(m_device); |
| 5897 | pipe.AddColorAttachment(); |
| 5898 | pipe.AddShader(&vs); |
| 5899 | pipe.AddShader(&fs); |
| 5900 | |
| 5901 | VkDescriptorSetObj descriptorSet(m_device); |
| 5902 | descriptorSet.AppendDummy(); |
| 5903 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5904 | |
| 5905 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5906 | |
| 5907 | if (m_errorMonitor->DesiredMsgFound()) { |
| 5908 | FAIL() << "Expected to succeed but: " << |
| 5909 | m_errorMonitor->GetFailureMsg(); |
| 5910 | m_errorMonitor->DumpFailureMsgs(); |
| 5911 | } |
| 5912 | } |
| 5913 | |
| 5914 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 5915 | { |
| 5916 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 5917 | |
| 5918 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5919 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5920 | |
Chris Forbes | 0ce57ea | 2016-04-04 19:26:42 +1200 | [diff] [blame^] | 5921 | if (!m_device->phy().features().tessellationShader) { |
| 5922 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 5923 | return; |
| 5924 | } |
| 5925 | |
Chris Forbes | f778216 | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5926 | char const *vsSource = |
| 5927 | "#version 450\n" |
| 5928 | "void main(){}\n"; |
| 5929 | char const *tcsSource = |
| 5930 | "#version 450\n" |
| 5931 | "layout(location=0) out int x[];\n" |
| 5932 | "layout(vertices=3) out;\n" |
| 5933 | "void main(){\n" |
| 5934 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 5935 | " gl_TessLevelInner[0] = 1;\n" |
| 5936 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 5937 | "}\n"; |
| 5938 | char const *tesSource = |
| 5939 | "#version 450\n" |
| 5940 | "layout(triangles, equal_spacing, cw) in;\n" |
| 5941 | "layout(location=0) in int x[];\n" |
| 5942 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 5943 | "void main(){\n" |
| 5944 | " gl_Position.xyz = gl_TessCoord;\n" |
| 5945 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 5946 | "}\n"; |
| 5947 | char const *fsSource = |
| 5948 | "#version 450\n" |
| 5949 | "layout(location=0) out vec4 color;\n" |
| 5950 | "void main(){\n" |
| 5951 | " color = vec4(1);\n" |
| 5952 | "}\n"; |
| 5953 | |
| 5954 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5955 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 5956 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 5957 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5958 | |
| 5959 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 5960 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 5961 | nullptr, |
| 5962 | 0, |
| 5963 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 5964 | VK_FALSE}; |
| 5965 | |
Chris Forbes | 8c13a2e | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 5966 | VkPipelineTessellationStateCreateInfo tsci{ |
| 5967 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 5968 | nullptr, |
| 5969 | 0, |
| 5970 | 3}; |
| 5971 | |
Chris Forbes | f778216 | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5972 | VkPipelineObj pipe(m_device); |
| 5973 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | 8c13a2e | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 5974 | pipe.SetTessellation(&tsci); |
Chris Forbes | f778216 | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5975 | pipe.AddColorAttachment(); |
| 5976 | pipe.AddShader(&vs); |
| 5977 | pipe.AddShader(&tcs); |
| 5978 | pipe.AddShader(&tes); |
| 5979 | pipe.AddShader(&fs); |
| 5980 | |
| 5981 | VkDescriptorSetObj descriptorSet(m_device); |
| 5982 | descriptorSet.AppendDummy(); |
| 5983 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5984 | |
| 5985 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5986 | |
| 5987 | if (m_errorMonitor->DesiredMsgFound()) { |
| 5988 | m_errorMonitor->DumpFailureMsgs(); |
| 5989 | FAIL() << "Expected to succeed but: " << |
| 5990 | m_errorMonitor->GetFailureMsg(); |
| 5991 | } |
| 5992 | } |
| 5993 | |
Chris Forbes | f706c50 | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 5994 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 5995 | { |
| 5996 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5997 | "is per-vertex in tessellation control shader stage " |
| 5998 | "but per-patch in tessellation evaluation shader stage"); |
| 5999 | |
| 6000 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6001 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6002 | |
Chris Forbes | 0ce57ea | 2016-04-04 19:26:42 +1200 | [diff] [blame^] | 6003 | if (!m_device->phy().features().tessellationShader) { |
| 6004 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 6005 | return; |
| 6006 | } |
| 6007 | |
Chris Forbes | f706c50 | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 6008 | char const *vsSource = |
| 6009 | "#version 450\n" |
| 6010 | "void main(){}\n"; |
| 6011 | char const *tcsSource = |
| 6012 | "#version 450\n" |
| 6013 | "layout(location=0) out int x[];\n" |
| 6014 | "layout(vertices=3) out;\n" |
| 6015 | "void main(){\n" |
| 6016 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 6017 | " gl_TessLevelInner[0] = 1;\n" |
| 6018 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 6019 | "}\n"; |
| 6020 | char const *tesSource = |
| 6021 | "#version 450\n" |
| 6022 | "layout(triangles, equal_spacing, cw) in;\n" |
| 6023 | "layout(location=0) patch in int x;\n" |
| 6024 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 6025 | "void main(){\n" |
| 6026 | " gl_Position.xyz = gl_TessCoord;\n" |
| 6027 | " gl_Position.w = x;\n" |
| 6028 | "}\n"; |
| 6029 | char const *fsSource = |
| 6030 | "#version 450\n" |
| 6031 | "layout(location=0) out vec4 color;\n" |
| 6032 | "void main(){\n" |
| 6033 | " color = vec4(1);\n" |
| 6034 | "}\n"; |
| 6035 | |
| 6036 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6037 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 6038 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 6039 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6040 | |
| 6041 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 6042 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 6043 | nullptr, |
| 6044 | 0, |
| 6045 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 6046 | VK_FALSE}; |
| 6047 | |
| 6048 | VkPipelineTessellationStateCreateInfo tsci{ |
| 6049 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 6050 | nullptr, |
| 6051 | 0, |
| 6052 | 3}; |
| 6053 | |
| 6054 | VkPipelineObj pipe(m_device); |
| 6055 | pipe.SetInputAssembly(&iasci); |
| 6056 | pipe.SetTessellation(&tsci); |
| 6057 | pipe.AddColorAttachment(); |
| 6058 | pipe.AddShader(&vs); |
| 6059 | pipe.AddShader(&tcs); |
| 6060 | pipe.AddShader(&tes); |
| 6061 | pipe.AddShader(&fs); |
| 6062 | |
| 6063 | VkDescriptorSetObj descriptorSet(m_device); |
| 6064 | descriptorSet.AppendDummy(); |
| 6065 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6066 | |
| 6067 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6068 | |
| 6069 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6070 | m_errorMonitor->DumpFailureMsgs(); |
| 6071 | FAIL() << "Did not receive Error 'is per-vertex in tessellation control shader stage...'"; |
| 6072 | } |
| 6073 | } |
| 6074 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6075 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 6076 | m_errorMonitor->SetDesiredFailureMsg( |
| 6077 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6078 | "Duplicate vertex input binding descriptions for binding 0"); |
| 6079 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 6080 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6081 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 6082 | |
| 6083 | /* Two binding descriptions for binding 0 */ |
| 6084 | VkVertexInputBindingDescription input_bindings[2]; |
| 6085 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 6086 | |
| 6087 | VkVertexInputAttributeDescription input_attrib; |
| 6088 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 6089 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 6090 | |
| 6091 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6092 | "#version 450\n" |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 6093 | "\n" |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6094 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6095 | "out gl_PerVertex {\n" |
| 6096 | " vec4 gl_Position;\n" |
| 6097 | "};\n" |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 6098 | "void main(){\n" |
| 6099 | " gl_Position = vec4(x);\n" |
| 6100 | "}\n"; |
| 6101 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6102 | "#version 450\n" |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 6103 | "\n" |
| 6104 | "layout(location=0) out vec4 color;\n" |
| 6105 | "void main(){\n" |
| 6106 | " color = vec4(1);\n" |
| 6107 | "}\n"; |
| 6108 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6109 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6110 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 6111 | |
| 6112 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6113 | pipe.AddColorAttachment(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 6114 | pipe.AddShader(&vs); |
| 6115 | pipe.AddShader(&fs); |
| 6116 | |
| 6117 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 6118 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 6119 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 6120 | VkDescriptorSetObj descriptorSet(m_device); |
| 6121 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6122 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 6123 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6124 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 6125 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6126 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6127 | FAIL() << "Did not receive Error 'Duplicate vertex input binding " |
| 6128 | "descriptions for binding 0'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6129 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 6130 | } |
| 6131 | } |
Chris Forbes | 4c94870 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 6132 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6133 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6134 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6135 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6136 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 6137 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 6138 | |
| 6139 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6140 | "#version 450\n" |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 6141 | "\n" |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6142 | "out gl_PerVertex {\n" |
| 6143 | " vec4 gl_Position;\n" |
| 6144 | "};\n" |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 6145 | "void main(){\n" |
| 6146 | " gl_Position = vec4(1);\n" |
| 6147 | "}\n"; |
| 6148 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6149 | "#version 450\n" |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 6150 | "\n" |
| 6151 | "void main(){\n" |
| 6152 | "}\n"; |
| 6153 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6154 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6155 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 6156 | |
| 6157 | VkPipelineObj pipe(m_device); |
| 6158 | pipe.AddShader(&vs); |
| 6159 | pipe.AddShader(&fs); |
| 6160 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6161 | /* set up CB 0, not written */ |
| 6162 | pipe.AddColorAttachment(); |
| 6163 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 6164 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 6165 | VkDescriptorSetObj descriptorSet(m_device); |
| 6166 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6167 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 6168 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6169 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 6170 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6171 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6172 | FAIL() << "Did not receive Error 'Attachment 0 not written by FS'"; |
| 6173 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 6174 | } |
| 6175 | } |
| 6176 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6177 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6178 | // TODO: verify that this matches layer |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6179 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 5c13d4d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6180 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6181 | "FS writes to output location 1 with no matching attachment"); |
| 6182 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 6183 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 6184 | |
| 6185 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6186 | "#version 450\n" |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 6187 | "\n" |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6188 | "out gl_PerVertex {\n" |
| 6189 | " vec4 gl_Position;\n" |
| 6190 | "};\n" |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 6191 | "void main(){\n" |
| 6192 | " gl_Position = vec4(1);\n" |
| 6193 | "}\n"; |
| 6194 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6195 | "#version 450\n" |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 6196 | "\n" |
| 6197 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6198 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 6199 | "void main(){\n" |
| 6200 | " x = vec4(1);\n" |
| 6201 | " y = vec4(1);\n" |
| 6202 | "}\n"; |
| 6203 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6204 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6205 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 6206 | |
| 6207 | VkPipelineObj pipe(m_device); |
| 6208 | pipe.AddShader(&vs); |
| 6209 | pipe.AddShader(&fs); |
| 6210 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6211 | /* set up CB 0, not written */ |
| 6212 | pipe.AddColorAttachment(); |
| 6213 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 6214 | /* FS writes CB 1, but we don't configure it */ |
| 6215 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 6216 | VkDescriptorSetObj descriptorSet(m_device); |
| 6217 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6218 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 6219 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6220 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 6221 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6222 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6223 | FAIL() << "Did not receive Error 'FS writes to output location 1 with " |
| 6224 | "no matching attachment'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6225 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 6226 | } |
| 6227 | } |
| 6228 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6229 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6230 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6231 | "does not match FS output type"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6232 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6233 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6234 | |
| 6235 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6236 | "#version 450\n" |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6237 | "\n" |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6238 | "out gl_PerVertex {\n" |
| 6239 | " vec4 gl_Position;\n" |
| 6240 | "};\n" |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6241 | "void main(){\n" |
| 6242 | " gl_Position = vec4(1);\n" |
| 6243 | "}\n"; |
| 6244 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6245 | "#version 450\n" |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6246 | "\n" |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6247 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6248 | "void main(){\n" |
| 6249 | " x = ivec4(1);\n" |
| 6250 | "}\n"; |
| 6251 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6252 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6253 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6254 | |
| 6255 | VkPipelineObj pipe(m_device); |
| 6256 | pipe.AddShader(&vs); |
| 6257 | pipe.AddShader(&fs); |
| 6258 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6259 | /* set up CB 0; type is UNORM by default */ |
| 6260 | pipe.AddColorAttachment(); |
| 6261 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6262 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6263 | VkDescriptorSetObj descriptorSet(m_device); |
| 6264 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6265 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6266 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6267 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6268 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6269 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6270 | FAIL() << "Did not receive Error 'does not match FS output type'"; |
| 6271 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6272 | } |
| 6273 | } |
Chris Forbes | c205073 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 6274 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6275 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6276 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6277 | "not declared in pipeline layout"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6278 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6279 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6280 | |
| 6281 | char const *vsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6282 | "#version 450\n" |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6283 | "\n" |
Tony Barbour | 19b5f92 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6284 | "out gl_PerVertex {\n" |
| 6285 | " vec4 gl_Position;\n" |
| 6286 | "};\n" |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6287 | "void main(){\n" |
| 6288 | " gl_Position = vec4(1);\n" |
| 6289 | "}\n"; |
| 6290 | char const *fsSource = |
Chris Forbes | 4349404 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6291 | "#version 450\n" |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6292 | "\n" |
| 6293 | "layout(location=0) out vec4 x;\n" |
| 6294 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 6295 | "void main(){\n" |
| 6296 | " x = vec4(bar.y);\n" |
| 6297 | "}\n"; |
| 6298 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6299 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6300 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6301 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6302 | VkPipelineObj pipe(m_device); |
| 6303 | pipe.AddShader(&vs); |
| 6304 | pipe.AddShader(&fs); |
| 6305 | |
| 6306 | /* set up CB 0; type is UNORM by default */ |
| 6307 | pipe.AddColorAttachment(); |
| 6308 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6309 | |
| 6310 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6311 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6312 | |
| 6313 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6314 | |
| 6315 | /* should have generated an error -- pipeline layout does not |
| 6316 | * provide a uniform buffer in 0.0 |
| 6317 | */ |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6318 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6319 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 6320 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6321 | } |
| 6322 | } |
| 6323 | |
Chris Forbes | 680e9b7 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 6324 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 6325 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6326 | "not declared in layout"); |
| 6327 | |
| 6328 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6329 | |
| 6330 | char const *vsSource = |
| 6331 | "#version 450\n" |
Chris Forbes | 680e9b7 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 6332 | "\n" |
| 6333 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 6334 | "out gl_PerVertex {\n" |
| 6335 | " vec4 gl_Position;\n" |
| 6336 | "};\n" |
| 6337 | "void main(){\n" |
| 6338 | " gl_Position = vec4(consts.x);\n" |
| 6339 | "}\n"; |
| 6340 | char const *fsSource = |
| 6341 | "#version 450\n" |
Chris Forbes | 680e9b7 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 6342 | "\n" |
| 6343 | "layout(location=0) out vec4 x;\n" |
| 6344 | "void main(){\n" |
| 6345 | " x = vec4(1);\n" |
| 6346 | "}\n"; |
| 6347 | |
| 6348 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6349 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6350 | |
| 6351 | VkPipelineObj pipe(m_device); |
| 6352 | pipe.AddShader(&vs); |
| 6353 | pipe.AddShader(&fs); |
| 6354 | |
| 6355 | /* set up CB 0; type is UNORM by default */ |
| 6356 | pipe.AddColorAttachment(); |
| 6357 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6358 | |
| 6359 | VkDescriptorSetObj descriptorSet(m_device); |
| 6360 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6361 | |
| 6362 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6363 | |
| 6364 | /* should have generated an error -- no push constant ranges provided! */ |
| 6365 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6366 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 6367 | m_errorMonitor->DumpFailureMsgs(); |
| 6368 | } |
| 6369 | } |
| 6370 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6371 | #endif // SHADER_CHECKER_TESTS |
| 6372 | |
| 6373 | #if DEVICE_LIMITS_TESTS |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6374 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) { |
| 6375 | m_errorMonitor->SetDesiredFailureMsg( |
| 6376 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6377 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6378 | |
| 6379 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6380 | |
| 6381 | // Create an image |
| 6382 | VkImage image; |
| 6383 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6384 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6385 | const int32_t tex_width = 32; |
| 6386 | const int32_t tex_height = 32; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6387 | |
| 6388 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6389 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6390 | image_create_info.pNext = NULL; |
| 6391 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6392 | image_create_info.format = tex_format; |
| 6393 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6394 | image_create_info.extent.height = tex_height; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6395 | image_create_info.extent.depth = 1; |
| 6396 | image_create_info.mipLevels = 1; |
| 6397 | image_create_info.arrayLayers = 1; |
| 6398 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6399 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6400 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6401 | image_create_info.flags = 0; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6402 | |
| 6403 | // Introduce error by sending down a bogus width extent |
| 6404 | image_create_info.extent.width = 65536; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6405 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6406 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6407 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6408 | FAIL() << "Did not receive Error 'CreateImage extents exceed allowable " |
| 6409 | "limits for format'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6410 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6411 | } |
| 6412 | } |
| 6413 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6414 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 6415 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6416 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6417 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6418 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6419 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6420 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6421 | |
| 6422 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6423 | vk_testing::Buffer buffer; |
| 6424 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 6425 | |
| 6426 | BeginCommandBuffer(); |
| 6427 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6428 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6429 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6430 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, " |
| 6431 | "VkDeviceSize dstOffset, is not a multiple of 4'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6432 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6433 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6434 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6435 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6436 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6437 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6438 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6439 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6440 | |
| 6441 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6442 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, " |
| 6443 | "VkDeviceSize dataSize, is not a multiple of 4'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6444 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6445 | } |
| 6446 | EndCommandBuffer(); |
| 6447 | } |
| 6448 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6449 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6450 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6451 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6452 | |
| 6453 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6454 | |
| 6455 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6456 | vk_testing::Buffer buffer; |
| 6457 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 6458 | |
| 6459 | BeginCommandBuffer(); |
| 6460 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6461 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6462 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6463 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, " |
| 6464 | "VkDeviceSize dstOffset, is not a multiple of 4'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6465 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6466 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6467 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6468 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6469 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6470 | "size, is not a multiple of 4"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6471 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6472 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6473 | |
| 6474 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6475 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, " |
| 6476 | "VkDeviceSize size, is not a multiple of 4'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6477 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6478 | } |
| 6479 | EndCommandBuffer(); |
| 6480 | } |
| 6481 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6482 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6483 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6484 | #if IMAGE_TESTS |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6485 | TEST_F(VkLayerTest, InvalidImageView) { |
| 6486 | VkResult err; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6487 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6488 | m_errorMonitor->SetDesiredFailureMsg( |
| 6489 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6490 | "vkCreateImageView called with baseMipLevel 10 "); |
| 6491 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6492 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6493 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6494 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6495 | VkImage image; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6496 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6497 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6498 | const int32_t tex_width = 32; |
| 6499 | const int32_t tex_height = 32; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6500 | |
| 6501 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6502 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6503 | image_create_info.pNext = NULL; |
| 6504 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6505 | image_create_info.format = tex_format; |
| 6506 | image_create_info.extent.width = tex_width; |
| 6507 | image_create_info.extent.height = tex_height; |
| 6508 | image_create_info.extent.depth = 1; |
| 6509 | image_create_info.mipLevels = 1; |
| 6510 | image_create_info.arrayLayers = 1; |
| 6511 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6512 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6513 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6514 | image_create_info.flags = 0; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6515 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6516 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6517 | ASSERT_VK_SUCCESS(err); |
| 6518 | |
| 6519 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6520 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6521 | image_view_create_info.image = image; |
| 6522 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6523 | image_view_create_info.format = tex_format; |
| 6524 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6525 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 6526 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6527 | image_view_create_info.subresourceRange.aspectMask = |
| 6528 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6529 | |
| 6530 | VkImageView view; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6531 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6532 | &view); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6533 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6534 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6535 | FAIL() << "Did not receive Error 'vkCreateImageView called with " |
| 6536 | "baseMipLevel 10...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6537 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6538 | } |
| 6539 | } |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6540 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6541 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 6542 | VkResult err; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6543 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6544 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6545 | "vkCreateImageView: Color image " |
| 6546 | "formats must have ONLY the " |
| 6547 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6548 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6549 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6550 | |
| 6551 | // Create an image and try to create a view with an invalid aspectMask |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6552 | VkImage image; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6553 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6554 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6555 | const int32_t tex_width = 32; |
| 6556 | const int32_t tex_height = 32; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6557 | |
| 6558 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6559 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6560 | image_create_info.pNext = NULL; |
| 6561 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6562 | image_create_info.format = tex_format; |
| 6563 | image_create_info.extent.width = tex_width; |
| 6564 | image_create_info.extent.height = tex_height; |
| 6565 | image_create_info.extent.depth = 1; |
| 6566 | image_create_info.mipLevels = 1; |
| 6567 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6568 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6569 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6570 | image_create_info.flags = 0; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6571 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6572 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6573 | ASSERT_VK_SUCCESS(err); |
| 6574 | |
| 6575 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6576 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6577 | image_view_create_info.image = image; |
| 6578 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6579 | image_view_create_info.format = tex_format; |
| 6580 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 6581 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6582 | // Cause an error by setting an invalid image aspect |
| 6583 | image_view_create_info.subresourceRange.aspectMask = |
| 6584 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6585 | |
| 6586 | VkImageView view; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6587 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6588 | &view); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6589 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6590 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6591 | FAIL() << "Did not receive Error 'VkCreateImageView: Color image " |
| 6592 | "formats must have ...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6593 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6594 | } |
| 6595 | } |
| 6596 | |
Mark Lobodzinski | 298f1c1 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6597 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6598 | VkResult err; |
| 6599 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6600 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6601 | m_errorMonitor->SetDesiredFailureMsg( |
| 6602 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 298f1c1 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6603 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6604 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6605 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6606 | |
| 6607 | // Create two images of different types and try to copy between them |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6608 | VkImage srcImage; |
| 6609 | VkImage dstImage; |
| 6610 | VkDeviceMemory srcMem; |
| 6611 | VkDeviceMemory destMem; |
| 6612 | VkMemoryRequirements memReqs; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6613 | |
| 6614 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6615 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6616 | image_create_info.pNext = NULL; |
| 6617 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6618 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6619 | image_create_info.extent.width = 32; |
| 6620 | image_create_info.extent.height = 32; |
| 6621 | image_create_info.extent.depth = 1; |
| 6622 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | 298f1c1 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6623 | image_create_info.arrayLayers = 4; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6624 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6625 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6626 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6627 | image_create_info.flags = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6628 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6629 | err = |
| 6630 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6631 | ASSERT_VK_SUCCESS(err); |
| 6632 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6633 | err = |
| 6634 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6635 | ASSERT_VK_SUCCESS(err); |
| 6636 | |
| 6637 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6638 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6639 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6640 | memAlloc.pNext = NULL; |
| 6641 | memAlloc.allocationSize = 0; |
| 6642 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6643 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6644 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6645 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6646 | pass = |
| 6647 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6648 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6649 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6650 | ASSERT_VK_SUCCESS(err); |
| 6651 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6652 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6653 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6654 | pass = |
| 6655 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6656 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6657 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6658 | ASSERT_VK_SUCCESS(err); |
| 6659 | |
| 6660 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6661 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6662 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6663 | ASSERT_VK_SUCCESS(err); |
| 6664 | |
| 6665 | BeginCommandBuffer(); |
| 6666 | VkImageCopy copyRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6667 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6668 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6669 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | 298f1c1 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6670 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6671 | copyRegion.srcOffset.x = 0; |
| 6672 | copyRegion.srcOffset.y = 0; |
| 6673 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6674 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6675 | copyRegion.dstSubresource.mipLevel = 0; |
| 6676 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | 298f1c1 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6677 | // Introduce failure by forcing the dst layerCount to differ from src |
| 6678 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6679 | copyRegion.dstOffset.x = 0; |
| 6680 | copyRegion.dstOffset.y = 0; |
| 6681 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6682 | copyRegion.extent.width = 1; |
| 6683 | copyRegion.extent.height = 1; |
| 6684 | copyRegion.extent.depth = 1; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6685 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6686 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6687 | EndCommandBuffer(); |
| 6688 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6689 | if (!m_errorMonitor->DesiredMsgFound()) { |
Mark Lobodzinski | 298f1c1 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6690 | FAIL() << "Did not receive Error 'vkCmdCopyImage: number of layers in " |
| 6691 | "source and destination subresources for pRegions'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6692 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6693 | } |
| 6694 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6695 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6696 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6697 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6698 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6699 | } |
| 6700 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6701 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
| 6702 | // TODO : Create two images with different format sizes and vkCmdCopyImage |
| 6703 | // between them |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6704 | } |
| 6705 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6706 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 6707 | VkResult err; |
| 6708 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6709 | |
Mark Lobodzinski | 298f1c1 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6710 | // Create a color image and a depth/stencil image and try to copy between them |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6711 | m_errorMonitor->SetDesiredFailureMsg( |
| 6712 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 298f1c1 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6713 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6714 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6715 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6716 | |
| 6717 | // Create two images of different types and try to copy between them |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6718 | VkImage srcImage; |
| 6719 | VkImage dstImage; |
| 6720 | VkDeviceMemory srcMem; |
| 6721 | VkDeviceMemory destMem; |
| 6722 | VkMemoryRequirements memReqs; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6723 | |
| 6724 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6725 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6726 | image_create_info.pNext = NULL; |
| 6727 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6728 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6729 | image_create_info.extent.width = 32; |
| 6730 | image_create_info.extent.height = 32; |
| 6731 | image_create_info.extent.depth = 1; |
| 6732 | image_create_info.mipLevels = 1; |
| 6733 | image_create_info.arrayLayers = 1; |
| 6734 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6735 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6736 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6737 | image_create_info.flags = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6738 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6739 | err = |
| 6740 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6741 | ASSERT_VK_SUCCESS(err); |
| 6742 | |
Mark Lobodzinski | 298f1c1 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6743 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6744 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | 298f1c1 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6745 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6746 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6747 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6748 | err = |
| 6749 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6750 | ASSERT_VK_SUCCESS(err); |
| 6751 | |
| 6752 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6753 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6754 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6755 | memAlloc.pNext = NULL; |
| 6756 | memAlloc.allocationSize = 0; |
| 6757 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6758 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6759 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6760 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6761 | pass = |
| 6762 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6763 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6764 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6765 | ASSERT_VK_SUCCESS(err); |
| 6766 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6767 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6768 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6769 | pass = |
| 6770 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6771 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6772 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6773 | ASSERT_VK_SUCCESS(err); |
| 6774 | |
| 6775 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6776 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6777 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6778 | ASSERT_VK_SUCCESS(err); |
| 6779 | |
| 6780 | BeginCommandBuffer(); |
| 6781 | VkImageCopy copyRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6782 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6783 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6784 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6785 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6786 | copyRegion.srcOffset.x = 0; |
| 6787 | copyRegion.srcOffset.y = 0; |
| 6788 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6789 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6790 | copyRegion.dstSubresource.mipLevel = 0; |
| 6791 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6792 | copyRegion.dstSubresource.layerCount = 0; |
| 6793 | copyRegion.dstOffset.x = 0; |
| 6794 | copyRegion.dstOffset.y = 0; |
| 6795 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6796 | copyRegion.extent.width = 1; |
| 6797 | copyRegion.extent.height = 1; |
| 6798 | copyRegion.extent.depth = 1; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6799 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6800 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6801 | EndCommandBuffer(); |
| 6802 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6803 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6804 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched " |
Mark Lobodzinski | 298f1c1 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6805 | "source and dest image depth/stencil formats'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6806 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6807 | } |
| 6808 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6809 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6810 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6811 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6812 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6813 | } |
| 6814 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6815 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 6816 | VkResult err; |
| 6817 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6818 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6819 | m_errorMonitor->SetDesiredFailureMsg( |
| 6820 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6821 | "vkCmdResolveImage called with source sample count less than 2."); |
| 6822 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6823 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6824 | |
| 6825 | // Create two images of sample count 1 and try to Resolve between them |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6826 | VkImage srcImage; |
| 6827 | VkImage dstImage; |
| 6828 | VkDeviceMemory srcMem; |
| 6829 | VkDeviceMemory destMem; |
| 6830 | VkMemoryRequirements memReqs; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6831 | |
| 6832 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6833 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6834 | image_create_info.pNext = NULL; |
| 6835 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6836 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6837 | image_create_info.extent.width = 32; |
| 6838 | image_create_info.extent.height = 1; |
| 6839 | image_create_info.extent.depth = 1; |
| 6840 | image_create_info.mipLevels = 1; |
| 6841 | image_create_info.arrayLayers = 1; |
| 6842 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6843 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6844 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6845 | image_create_info.flags = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6846 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6847 | err = |
| 6848 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6849 | ASSERT_VK_SUCCESS(err); |
| 6850 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6851 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6852 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6853 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6854 | err = |
| 6855 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6856 | ASSERT_VK_SUCCESS(err); |
| 6857 | |
| 6858 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6859 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6860 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6861 | memAlloc.pNext = NULL; |
| 6862 | memAlloc.allocationSize = 0; |
| 6863 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6864 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6865 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6866 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6867 | pass = |
| 6868 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6869 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6870 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6871 | ASSERT_VK_SUCCESS(err); |
| 6872 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6873 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6874 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6875 | pass = |
| 6876 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6877 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6878 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6879 | ASSERT_VK_SUCCESS(err); |
| 6880 | |
| 6881 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6882 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6883 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6884 | ASSERT_VK_SUCCESS(err); |
| 6885 | |
| 6886 | BeginCommandBuffer(); |
| 6887 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6888 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6889 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6890 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6891 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6892 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6893 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6894 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6895 | resolveRegion.srcOffset.x = 0; |
| 6896 | resolveRegion.srcOffset.y = 0; |
| 6897 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6898 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6899 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6900 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6901 | resolveRegion.dstSubresource.layerCount = 0; |
| 6902 | resolveRegion.dstOffset.x = 0; |
| 6903 | resolveRegion.dstOffset.y = 0; |
| 6904 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6905 | resolveRegion.extent.width = 1; |
| 6906 | resolveRegion.extent.height = 1; |
| 6907 | resolveRegion.extent.depth = 1; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6908 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6909 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6910 | EndCommandBuffer(); |
| 6911 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6912 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6913 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with source " |
| 6914 | "sample count less than 2.'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6915 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6916 | } |
| 6917 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6918 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6919 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6920 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6921 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6922 | } |
| 6923 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6924 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 6925 | VkResult err; |
| 6926 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6927 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6928 | m_errorMonitor->SetDesiredFailureMsg( |
| 6929 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6930 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 6931 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6932 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6933 | |
| 6934 | // Create two images of sample count 2 and try to Resolve between them |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6935 | VkImage srcImage; |
| 6936 | VkImage dstImage; |
| 6937 | VkDeviceMemory srcMem; |
| 6938 | VkDeviceMemory destMem; |
| 6939 | VkMemoryRequirements memReqs; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6940 | |
| 6941 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6942 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6943 | image_create_info.pNext = NULL; |
| 6944 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6945 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6946 | image_create_info.extent.width = 32; |
| 6947 | image_create_info.extent.height = 1; |
| 6948 | image_create_info.extent.depth = 1; |
| 6949 | image_create_info.mipLevels = 1; |
| 6950 | image_create_info.arrayLayers = 1; |
| 6951 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6952 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6953 | // Note: Some implementations expect color attachment usage for any |
| 6954 | // multisample surface |
| 6955 | image_create_info.usage = |
| 6956 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6957 | image_create_info.flags = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6958 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6959 | err = |
| 6960 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6961 | ASSERT_VK_SUCCESS(err); |
| 6962 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6963 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6964 | // Note: Some implementations expect color attachment usage for any |
| 6965 | // multisample surface |
| 6966 | image_create_info.usage = |
| 6967 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6968 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6969 | err = |
| 6970 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6971 | ASSERT_VK_SUCCESS(err); |
| 6972 | |
| 6973 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6974 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6975 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6976 | memAlloc.pNext = NULL; |
| 6977 | memAlloc.allocationSize = 0; |
| 6978 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6979 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6980 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6981 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6982 | pass = |
| 6983 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6984 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6985 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6986 | ASSERT_VK_SUCCESS(err); |
| 6987 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6988 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6989 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6990 | pass = |
| 6991 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6992 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6993 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6994 | ASSERT_VK_SUCCESS(err); |
| 6995 | |
| 6996 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6997 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6998 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6999 | ASSERT_VK_SUCCESS(err); |
| 7000 | |
| 7001 | BeginCommandBuffer(); |
| 7002 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7003 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 7004 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7005 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 7006 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7007 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 7008 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7009 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7010 | resolveRegion.srcOffset.x = 0; |
| 7011 | resolveRegion.srcOffset.y = 0; |
| 7012 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 7013 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7014 | resolveRegion.dstSubresource.mipLevel = 0; |
| 7015 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 7016 | resolveRegion.dstSubresource.layerCount = 0; |
| 7017 | resolveRegion.dstOffset.x = 0; |
| 7018 | resolveRegion.dstOffset.y = 0; |
| 7019 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7020 | resolveRegion.extent.width = 1; |
| 7021 | resolveRegion.extent.height = 1; |
| 7022 | resolveRegion.extent.depth = 1; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7023 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 7024 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7025 | EndCommandBuffer(); |
| 7026 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7027 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7028 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with dest " |
| 7029 | "sample count greater than 1.'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7030 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7031 | } |
| 7032 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7033 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7034 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7035 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 7036 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7037 | } |
| 7038 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7039 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 7040 | VkResult err; |
| 7041 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7042 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7043 | m_errorMonitor->SetDesiredFailureMsg( |
| 7044 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7045 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 7046 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7047 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7048 | |
| 7049 | // Create two images of different types and try to copy between them |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7050 | VkImage srcImage; |
| 7051 | VkImage dstImage; |
| 7052 | VkDeviceMemory srcMem; |
| 7053 | VkDeviceMemory destMem; |
| 7054 | VkMemoryRequirements memReqs; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7055 | |
| 7056 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7057 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7058 | image_create_info.pNext = NULL; |
| 7059 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7060 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7061 | image_create_info.extent.width = 32; |
| 7062 | image_create_info.extent.height = 1; |
| 7063 | image_create_info.extent.depth = 1; |
| 7064 | image_create_info.mipLevels = 1; |
| 7065 | image_create_info.arrayLayers = 1; |
| 7066 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 7067 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7068 | // Note: Some implementations expect color attachment usage for any |
| 7069 | // multisample surface |
| 7070 | image_create_info.usage = |
| 7071 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 7072 | image_create_info.flags = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7073 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7074 | err = |
| 7075 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7076 | ASSERT_VK_SUCCESS(err); |
| 7077 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7078 | // Set format to something other than source image |
| 7079 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 7080 | // Note: Some implementations expect color attachment usage for any |
| 7081 | // multisample surface |
| 7082 | image_create_info.usage = |
| 7083 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 7084 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7085 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7086 | err = |
| 7087 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7088 | ASSERT_VK_SUCCESS(err); |
| 7089 | |
| 7090 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7091 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7092 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 7093 | memAlloc.pNext = NULL; |
| 7094 | memAlloc.allocationSize = 0; |
| 7095 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7096 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 7097 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7098 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7099 | pass = |
| 7100 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 7101 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7102 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7103 | ASSERT_VK_SUCCESS(err); |
| 7104 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7105 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7106 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7107 | pass = |
| 7108 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 7109 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7110 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7111 | ASSERT_VK_SUCCESS(err); |
| 7112 | |
| 7113 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 7114 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7115 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7116 | ASSERT_VK_SUCCESS(err); |
| 7117 | |
| 7118 | BeginCommandBuffer(); |
| 7119 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7120 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 7121 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7122 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 7123 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7124 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 7125 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7126 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7127 | resolveRegion.srcOffset.x = 0; |
| 7128 | resolveRegion.srcOffset.y = 0; |
| 7129 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 7130 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7131 | resolveRegion.dstSubresource.mipLevel = 0; |
| 7132 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 7133 | resolveRegion.dstSubresource.layerCount = 0; |
| 7134 | resolveRegion.dstOffset.x = 0; |
| 7135 | resolveRegion.dstOffset.y = 0; |
| 7136 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7137 | resolveRegion.extent.width = 1; |
| 7138 | resolveRegion.extent.height = 1; |
| 7139 | resolveRegion.extent.depth = 1; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7140 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 7141 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7142 | EndCommandBuffer(); |
| 7143 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7144 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7145 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with " |
| 7146 | "unmatched source and dest formats.'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7147 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7148 | } |
| 7149 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7150 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7151 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7152 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 7153 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7154 | } |
| 7155 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7156 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 7157 | VkResult err; |
| 7158 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7159 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7160 | m_errorMonitor->SetDesiredFailureMsg( |
| 7161 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7162 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 7163 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7164 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7165 | |
| 7166 | // Create two images of different types and try to copy between them |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7167 | VkImage srcImage; |
| 7168 | VkImage dstImage; |
| 7169 | VkDeviceMemory srcMem; |
| 7170 | VkDeviceMemory destMem; |
| 7171 | VkMemoryRequirements memReqs; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7172 | |
| 7173 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7174 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7175 | image_create_info.pNext = NULL; |
| 7176 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7177 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7178 | image_create_info.extent.width = 32; |
| 7179 | image_create_info.extent.height = 1; |
| 7180 | image_create_info.extent.depth = 1; |
| 7181 | image_create_info.mipLevels = 1; |
| 7182 | image_create_info.arrayLayers = 1; |
| 7183 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 7184 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7185 | // Note: Some implementations expect color attachment usage for any |
| 7186 | // multisample surface |
| 7187 | image_create_info.usage = |
| 7188 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 7189 | image_create_info.flags = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7190 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7191 | err = |
| 7192 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7193 | ASSERT_VK_SUCCESS(err); |
| 7194 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7195 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 7196 | // Note: Some implementations expect color attachment usage for any |
| 7197 | // multisample surface |
| 7198 | image_create_info.usage = |
| 7199 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 7200 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7201 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7202 | err = |
| 7203 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7204 | ASSERT_VK_SUCCESS(err); |
| 7205 | |
| 7206 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7207 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7208 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 7209 | memAlloc.pNext = NULL; |
| 7210 | memAlloc.allocationSize = 0; |
| 7211 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7212 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 7213 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7214 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7215 | pass = |
| 7216 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 7217 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7218 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7219 | ASSERT_VK_SUCCESS(err); |
| 7220 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7221 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7222 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7223 | pass = |
| 7224 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 7225 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7226 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7227 | ASSERT_VK_SUCCESS(err); |
| 7228 | |
| 7229 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 7230 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7231 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7232 | ASSERT_VK_SUCCESS(err); |
| 7233 | |
| 7234 | BeginCommandBuffer(); |
| 7235 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7236 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 7237 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7238 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 7239 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7240 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 7241 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7242 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7243 | resolveRegion.srcOffset.x = 0; |
| 7244 | resolveRegion.srcOffset.y = 0; |
| 7245 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 7246 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7247 | resolveRegion.dstSubresource.mipLevel = 0; |
| 7248 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 7249 | resolveRegion.dstSubresource.layerCount = 0; |
| 7250 | resolveRegion.dstOffset.x = 0; |
| 7251 | resolveRegion.dstOffset.y = 0; |
| 7252 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7253 | resolveRegion.extent.width = 1; |
| 7254 | resolveRegion.extent.height = 1; |
| 7255 | resolveRegion.extent.depth = 1; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7256 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 7257 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7258 | EndCommandBuffer(); |
| 7259 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7260 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7261 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with " |
| 7262 | "unmatched source and dest image types.'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7263 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7264 | } |
| 7265 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7266 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7267 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7268 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 7269 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7270 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7271 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7272 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7273 | // Create a single Image descriptor and cause it to first hit an error due |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7274 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 7275 | // set in aspect |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7276 | // The image format check comes 2nd in validation so we trigger it first, |
| 7277 | // then when we cause aspect fail next, bad format check will be preempted |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7278 | VkResult err; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7279 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7280 | m_errorMonitor->SetDesiredFailureMsg( |
| 7281 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7282 | "Combination depth/stencil image formats can have only the "); |
| 7283 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7284 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7285 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7286 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7287 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 7288 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7289 | |
| 7290 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7291 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7292 | ds_pool_ci.pNext = NULL; |
| 7293 | ds_pool_ci.maxSets = 1; |
| 7294 | ds_pool_ci.poolSizeCount = 1; |
| 7295 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7296 | |
| 7297 | VkDescriptorPool ds_pool; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7298 | err = |
| 7299 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7300 | ASSERT_VK_SUCCESS(err); |
| 7301 | |
| 7302 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7303 | dsl_binding.binding = 0; |
| 7304 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 7305 | dsl_binding.descriptorCount = 1; |
| 7306 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7307 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7308 | |
| 7309 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7310 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7311 | ds_layout_ci.pNext = NULL; |
| 7312 | ds_layout_ci.bindingCount = 1; |
| 7313 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7314 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7315 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7316 | &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7317 | ASSERT_VK_SUCCESS(err); |
| 7318 | |
| 7319 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7320 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7321 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | a4ae48b | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7322 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7323 | alloc_info.descriptorPool = ds_pool; |
| 7324 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7325 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7326 | &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7327 | ASSERT_VK_SUCCESS(err); |
| 7328 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7329 | VkImage image_bad; |
| 7330 | VkImage image_good; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7331 | // One bad format and one good format for Color attachment |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7332 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7333 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7334 | const int32_t tex_width = 32; |
| 7335 | const int32_t tex_height = 32; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7336 | |
| 7337 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7338 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7339 | image_create_info.pNext = NULL; |
| 7340 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7341 | image_create_info.format = tex_format_bad; |
| 7342 | image_create_info.extent.width = tex_width; |
| 7343 | image_create_info.extent.height = tex_height; |
| 7344 | image_create_info.extent.depth = 1; |
| 7345 | image_create_info.mipLevels = 1; |
| 7346 | image_create_info.arrayLayers = 1; |
| 7347 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7348 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7349 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 7350 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 7351 | image_create_info.flags = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7352 | |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7353 | err = |
| 7354 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7355 | ASSERT_VK_SUCCESS(err); |
| 7356 | image_create_info.format = tex_format_good; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7357 | image_create_info.usage = |
| 7358 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 7359 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 7360 | &image_good); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7361 | ASSERT_VK_SUCCESS(err); |
| 7362 | |
| 7363 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7364 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7365 | image_view_create_info.image = image_bad; |
| 7366 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7367 | image_view_create_info.format = tex_format_bad; |
| 7368 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 7369 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 7370 | image_view_create_info.subresourceRange.layerCount = 1; |
| 7371 | image_view_create_info.subresourceRange.levelCount = 1; |
| 7372 | image_view_create_info.subresourceRange.aspectMask = |
| 7373 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7374 | |
| 7375 | VkImageView view; |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7376 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 7377 | &view); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7378 | |
| 7379 | if (!m_errorMonitor->DesiredMsgFound()) { |
Karl Schultz | 99e9d1d | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7380 | FAIL() << "Did not receive Error 'Combination depth-stencil image " |
| 7381 | "formats can have only the....'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7382 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7383 | } |
| 7384 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7385 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 7386 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7387 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7388 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7389 | } |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7390 | #endif // IMAGE_TESTS |
| 7391 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7392 | int main(int argc, char **argv) { |
| 7393 | int result; |
| 7394 | |
Cody Northrop | 50537d0 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 7395 | #ifdef ANDROID |
| 7396 | int vulkanSupport = InitVulkan(); |
| 7397 | if (vulkanSupport == 0) |
| 7398 | return 1; |
| 7399 | #endif |
| 7400 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7401 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 7402 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7403 | |
| 7404 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 7405 | |
| 7406 | result = RUN_ALL_TESTS(); |
| 7407 | |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 7408 | VkTestFramework::Finish(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7409 | return result; |
| 7410 | } |