Tony Barbour | d04e8df | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2015 Valve Corporation |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3 | // Copyright (C) 2015 Google, Inc. |
Tony Barbour | d04e8df | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 4 | // |
| 5 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | // copy of this software and associated documentation files (the "Software"), |
| 7 | // to deal in the Software without restriction, including without limitation |
| 8 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | // and/or sell copies of the Software, and to permit persons to whom the |
| 10 | // Software is furnished to do so, subject to the following conditions: |
| 11 | // |
| 12 | // The above copyright notice and this permission notice shall be included |
| 13 | // in all copies or substantial portions of the Software. |
| 14 | // |
| 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | // DEALINGS IN THE SOFTWARE. |
| 22 | // |
| 23 | // Author: Chia-I Wu <olvaffe@gmail.com> |
| 24 | // Author: Chris Forbes <chrisf@ijw.co.nz> |
| 25 | // Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 26 | // Author: Mark Lobodzinski <mark@lunarg.com> |
| 27 | // Author: Mike Stroyan <mike@LunarG.com> |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 28 | // Author: Tobin Ehlis <tobine@google.com> |
Tony Barbour | d04e8df | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 29 | // Author: Tony Barbour <tony@LunarG.com> |
| 30 | |
| 31 | |
David Pinedo | 329ca9e | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 32 | #include <vulkan/vulkan.h> |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 33 | #include <vulkan/vk_ext_debug_report.h> |
Courtney Goeltzenleuchter | 0abdb66 | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 34 | #include "test_common.h" |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 35 | #include "vkrenderframework.h" |
Tobin Ehlis | 56d204a | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 36 | #include "vk_layer_config.h" |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 37 | #include "../icd/common/icd-spv.h" |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 38 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 39 | #define GLM_FORCE_RADIANS |
| 40 | #include "glm/glm.hpp" |
| 41 | #include <glm/gtc/matrix_transform.hpp> |
| 42 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 43 | #define MEM_TRACKER_TESTS 1 |
| 44 | #define OBJ_TRACKER_TESTS 1 |
| 45 | #define DRAW_STATE_TESTS 1 |
| 46 | #define THREADING_TESTS 1 |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 47 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 48 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 49 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 50 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 51 | //-------------------------------------------------------------------------------------- |
| 52 | // Mesh and VertexFormat Data |
| 53 | //-------------------------------------------------------------------------------------- |
| 54 | struct Vertex |
| 55 | { |
| 56 | float posX, posY, posZ, posW; // Position data |
| 57 | float r, g, b, a; // Color |
| 58 | }; |
| 59 | |
| 60 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
| 61 | |
| 62 | typedef enum _BsoFailSelect { |
| 63 | BsoFailNone = 0x00000000, |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 64 | BsoFailLineWidth = 0x00000001, |
| 65 | BsoFailDepthBias = 0x00000002, |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 66 | BsoFailViewport = 0x00000004, |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 67 | BsoFailScissor = 0x00000008, |
| 68 | BsoFailBlend = 0x00000010, |
| 69 | BsoFailDepthBounds = 0x00000020, |
| 70 | BsoFailStencilReadMask = 0x00000040, |
| 71 | BsoFailStencilWriteMask = 0x00000080, |
| 72 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 73 | } BsoFailSelect; |
| 74 | |
| 75 | struct vktriangle_vs_uniform { |
| 76 | // Must start with MVP |
| 77 | float mvp[4][4]; |
| 78 | float position[3][4]; |
| 79 | float color[3][4]; |
| 80 | }; |
| 81 | |
Mark Lobodzinski | 6bbdff1 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 82 | static const char bindStateVertShaderText[] = |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 83 | "#version 130\n" |
| 84 | "vec2 vertices[3];\n" |
| 85 | "void main() {\n" |
| 86 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 87 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 88 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 89 | " gl_Position = vec4(vertices[gl_VertexID % 3], 0.0, 1.0);\n" |
| 90 | "}\n"; |
| 91 | |
Mark Lobodzinski | 6bbdff1 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 92 | static const char bindStateFragShaderText[] = |
Cody Northrop | 74a2d2c | 2015-06-16 17:32:04 -0600 | [diff] [blame] | 93 | "#version 140\n" |
| 94 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 95 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 96 | "\n" |
| 97 | "layout(location = 0) out vec4 uFragColor;\n" |
| 98 | "void main(){\n" |
| 99 | " uFragColor = vec4(0,1,0,1);\n" |
| 100 | "}\n"; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 101 | |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 102 | static VkBool32 myDbgFunc( |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 103 | VkFlags msgFlags, |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 104 | VkDebugReportObjectTypeEXT objType, |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 105 | uint64_t srcObject, |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 106 | size_t location, |
| 107 | int32_t msgCode, |
| 108 | const char* pLayerPrefix, |
| 109 | const char* pMsg, |
Courtney Goeltzenleuchter | 072b6f2 | 2015-11-30 11:52:06 -0700 | [diff] [blame] | 110 | const void* pUserData); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 111 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 112 | // ******************************************************** |
| 113 | // ErrorMonitor Usage: |
| 114 | // |
| 115 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 116 | // encountered log messages. Passing NULL will match all log messages. |
| 117 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 118 | // |
| 119 | // Call DesiredMsgFound to determine if the desired failure message |
| 120 | // was encountered. |
| 121 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 122 | class ErrorMonitor { |
| 123 | public: |
Tony Barbour | 0c1bdc6 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 124 | ErrorMonitor() |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 125 | { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 126 | test_platform_thread_create_mutex(&m_mutex); |
| 127 | test_platform_thread_lock_mutex(&m_mutex); |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 128 | m_msgFlags = VK_DEBUG_REPORT_INFO_BIT_EXT; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 129 | m_bailout = NULL; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 130 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 131 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 132 | |
| 133 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 134 | { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 135 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 136 | m_desiredMsg.clear(); |
| 137 | m_failureMsg.clear(); |
| 138 | m_otherMsgs.clear(); |
| 139 | m_desiredMsg = msgString; |
| 140 | m_msgFound = VK_FALSE; |
| 141 | m_msgFlags = msgFlags; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 142 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 143 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 144 | |
| 145 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) |
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 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 148 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 149 | if (m_bailout != NULL) { |
| 150 | *m_bailout = true; |
| 151 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 152 | string errorString(msgString); |
| 153 | if (msgFlags & m_msgFlags) { |
| 154 | if (errorString.find(m_desiredMsg) != string::npos) { |
| 155 | m_failureMsg = errorString; |
| 156 | m_msgFound = VK_TRUE; |
| 157 | result = VK_TRUE; |
| 158 | } else { |
| 159 | m_otherMsgs.push_back(errorString); |
| 160 | } |
| 161 | } |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 162 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 163 | return result; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 164 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 165 | |
| 166 | vector<string> GetOtherFailureMsgs(void) |
| 167 | { |
| 168 | return m_otherMsgs; |
| 169 | } |
| 170 | |
| 171 | string GetFailureMsg(void) |
| 172 | { |
| 173 | return m_failureMsg; |
| 174 | } |
| 175 | |
| 176 | VkBool32 DesiredMsgFound(void) |
| 177 | { |
| 178 | return m_msgFound; |
| 179 | } |
| 180 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 181 | void SetBailout(bool *bailout) |
| 182 | { |
| 183 | m_bailout = bailout; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 184 | } |
| 185 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 186 | void DumpFailureMsgs(void) |
| 187 | { |
| 188 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 189 | cout << "Other error messages logged for this test were:" << endl; |
| 190 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 191 | cout << " " << *iter << endl; |
| 192 | } |
| 193 | } |
| 194 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 195 | private: |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 196 | VkFlags m_msgFlags; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 197 | string m_desiredMsg; |
| 198 | string m_failureMsg; |
| 199 | vector<string> m_otherMsgs; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 200 | test_platform_thread_mutex m_mutex; |
| 201 | bool* m_bailout; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 202 | VkBool32 m_msgFound; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 203 | }; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 204 | |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 205 | static VkBool32 myDbgFunc( |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 206 | VkFlags msgFlags, |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 207 | VkDebugReportObjectTypeEXT objType, |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 208 | uint64_t srcObject, |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 209 | size_t location, |
| 210 | int32_t msgCode, |
| 211 | const char* pLayerPrefix, |
| 212 | const char* pMsg, |
Courtney Goeltzenleuchter | 072b6f2 | 2015-11-30 11:52:06 -0700 | [diff] [blame] | 213 | const void* pUserData) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 214 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 215 | if (msgFlags & (VK_DEBUG_REPORT_WARN_BIT_EXT | VK_DEBUG_REPORT_PERF_WARN_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 216 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 217 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 218 | } |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 219 | return false; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 220 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 221 | |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 222 | class VkLayerTest : public VkRenderFramework |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 223 | { |
| 224 | public: |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 225 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 226 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 227 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 228 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 229 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 230 | { GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, failMask); } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 231 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 232 | /* Convenience functions that use built-in command buffer */ |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 233 | VkResult BeginCommandBuffer() { return BeginCommandBuffer(*m_commandBuffer); } |
| 234 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 235 | void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 236 | { m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, firstInstance); } |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 237 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 238 | { m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); } |
| 239 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
| 240 | void QueueCommandBuffer(const VkFence& fence) { m_commandBuffer->QueueCommandBuffer(fence); } |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 241 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 242 | { m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); } |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 243 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 244 | { m_commandBuffer->BindIndexBuffer(indexBuffer, offset); } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 245 | protected: |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 246 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 247 | |
| 248 | virtual void SetUp() { |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 249 | std::vector<const char *> instance_layer_names; |
| 250 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 251 | std::vector<const char *> instance_extension_names; |
| 252 | std::vector<const char *> device_extension_names; |
Tony Barbour | 950ebc0 | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 253 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 254 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | de53c5b | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 255 | /* |
| 256 | * Since CreateDbgMsgCallback is an instance level extension call |
| 257 | * any extension / layer that utilizes that feature also needs |
| 258 | * to be enabled at create instance time. |
| 259 | */ |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 260 | // Use Threading layer first to protect others from ThreadCommandBufferCollision test |
Jon Ashburn | 1068ad5 | 2015-11-25 08:56:58 -0700 | [diff] [blame] | 261 | instance_layer_names.push_back("VK_LAYER_LUNARG_Threading"); |
| 262 | instance_layer_names.push_back("VK_LAYER_LUNARG_ObjectTracker"); |
| 263 | instance_layer_names.push_back("VK_LAYER_LUNARG_MemTracker"); |
| 264 | instance_layer_names.push_back("VK_LAYER_LUNARG_DrawState"); |
Jon Ashburn | 1068ad5 | 2015-11-25 08:56:58 -0700 | [diff] [blame] | 265 | instance_layer_names.push_back("VK_LAYER_LUNARG_DeviceLimits"); |
| 266 | instance_layer_names.push_back("VK_LAYER_LUNARG_Image"); |
Courtney Goeltzenleuchter | 23b5f8d | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 267 | |
Jon Ashburn | 1068ad5 | 2015-11-25 08:56:58 -0700 | [diff] [blame] | 268 | device_layer_names.push_back("VK_LAYER_LUNARG_Threading"); |
| 269 | device_layer_names.push_back("VK_LAYER_LUNARG_ObjectTracker"); |
| 270 | device_layer_names.push_back("VK_LAYER_LUNARG_MemTracker"); |
| 271 | device_layer_names.push_back("VK_LAYER_LUNARG_DrawState"); |
Jon Ashburn | 1068ad5 | 2015-11-25 08:56:58 -0700 | [diff] [blame] | 272 | device_layer_names.push_back("VK_LAYER_LUNARG_DeviceLimits"); |
| 273 | device_layer_names.push_back("VK_LAYER_LUNARG_Image"); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 274 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 275 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 276 | this->app_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 277 | this->app_info.pApplicationName = "layer_tests"; |
| 278 | this->app_info.applicationVersion = 1; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 279 | this->app_info.pEngineName = "unittest"; |
| 280 | this->app_info.engineVersion = 1; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 281 | this->app_info.apiVersion = VK_API_VERSION; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 282 | |
Tony Barbour | 0c1bdc6 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 283 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 284 | InitFramework(instance_layer_names, device_layer_names, |
| 285 | instance_extension_names, device_extension_names, |
| 286 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | virtual void TearDown() { |
| 290 | // Clean up resources before we reset |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 291 | ShutdownFramework(); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 292 | delete m_errorMonitor; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 293 | } |
| 294 | }; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 295 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 296 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 297 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 298 | VkResult result; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 299 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 300 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 301 | |
| 302 | /* |
| 303 | * For render test all drawing happens in a single render pass |
| 304 | * on a single command buffer. |
| 305 | */ |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 306 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 307 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | return result; |
| 311 | } |
| 312 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 313 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 314 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 315 | VkResult result; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 316 | |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 317 | if (renderPass()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 318 | commandBuffer.EndRenderPass(); |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 319 | } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 320 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 321 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 322 | |
| 323 | return result; |
| 324 | } |
| 325 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 326 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask) |
| 327 | { |
| 328 | // Create identity matrix |
| 329 | int i; |
| 330 | struct vktriangle_vs_uniform data; |
| 331 | |
| 332 | glm::mat4 Projection = glm::mat4(1.0f); |
| 333 | glm::mat4 View = glm::mat4(1.0f); |
| 334 | glm::mat4 Model = glm::mat4(1.0f); |
| 335 | glm::mat4 MVP = Projection * View * Model; |
| 336 | const int matrixSize = sizeof(MVP); |
| 337 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
| 338 | |
| 339 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 340 | |
| 341 | static const Vertex tri_data[] = |
| 342 | { |
| 343 | { XYZ1( -1, -1, 0 ), XYZ1( 1.f, 0.f, 0.f ) }, |
| 344 | { XYZ1( 1, -1, 0 ), XYZ1( 0.f, 1.f, 0.f ) }, |
| 345 | { XYZ1( 0, 1, 0 ), XYZ1( 0.f, 0.f, 1.f ) }, |
| 346 | }; |
| 347 | |
| 348 | for (i=0; i<3; i++) { |
| 349 | data.position[i][0] = tri_data[i].posX; |
| 350 | data.position[i][1] = tri_data[i].posY; |
| 351 | data.position[i][2] = tri_data[i].posZ; |
| 352 | data.position[i][3] = tri_data[i].posW; |
| 353 | data.color[i][0] = tri_data[i].r; |
| 354 | data.color[i][1] = tri_data[i].g; |
| 355 | data.color[i][2] = tri_data[i].b; |
| 356 | data.color[i][3] = tri_data[i].a; |
| 357 | } |
| 358 | |
| 359 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 360 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 361 | |
| 362 | VkConstantBufferObj constantBuffer(m_device, bufSize*2, sizeof(float), (const void*) &data); |
| 363 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 364 | VkShaderObj vs(m_device,vertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 365 | VkShaderObj ps(m_device,fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 366 | |
| 367 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 368 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 369 | pipelineobj.AddShader(&vs); |
| 370 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 371 | if (failMask & BsoFailLineWidth) { |
| 372 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
| 373 | } |
| 374 | if (failMask & BsoFailDepthBias) { |
| 375 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
| 376 | } |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 377 | // Viewport and scissors must stay in synch or other errors will occur than the ones we want |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 378 | if (failMask & BsoFailViewport) { |
| 379 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 380 | m_viewports.clear(); |
| 381 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 382 | } |
| 383 | if (failMask & BsoFailScissor) { |
| 384 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 385 | m_scissors.clear(); |
| 386 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 387 | } |
| 388 | if (failMask & BsoFailBlend) { |
| 389 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
| 390 | } |
| 391 | if (failMask & BsoFailDepthBounds) { |
| 392 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 393 | } |
| 394 | if (failMask & BsoFailStencilReadMask) { |
| 395 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 396 | } |
| 397 | if (failMask & BsoFailStencilWriteMask) { |
| 398 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 399 | } |
| 400 | if (failMask & BsoFailStencilReference) { |
| 401 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 402 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 403 | |
| 404 | VkDescriptorSetObj descriptorSet(m_device); |
| 405 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, constantBuffer); |
| 406 | |
| 407 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 408 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 409 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 410 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 411 | |
| 412 | // render triangle |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 413 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 414 | |
| 415 | // finalize recording of the command buffer |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 416 | EndCommandBuffer(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 417 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 418 | QueueCommandBuffer(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 419 | } |
| 420 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 421 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 422 | { |
| 423 | if (m_depthStencil->Initialized()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 424 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 425 | } else { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 426 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 427 | } |
| 428 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 429 | commandBuffer->PrepareAttachments(); |
Cody Northrop | 2605cb0 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 430 | // Make sure depthWriteEnable is set so that Depth fail test will work correctly |
| 431 | // Make sure stencilTestEnable is set so that Stencil fail test will work correctly |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 432 | VkStencilOpState stencil = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 433 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 434 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 435 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 436 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 437 | |
| 438 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 439 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 440 | ds_ci.pNext = NULL; |
| 441 | ds_ci.depthTestEnable = VK_FALSE; |
| 442 | ds_ci.depthWriteEnable = VK_TRUE; |
| 443 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 444 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
| 445 | ds_ci.stencilTestEnable = VK_TRUE; |
| 446 | ds_ci.front = stencil; |
| 447 | ds_ci.back = stencil; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 448 | |
Tobin Ehlis | 40e9f52 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 449 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 450 | pipelineobj.SetViewport(m_viewports); |
| 451 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 452 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Cody Northrop | ccfa96d | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 453 | VkResult err = pipelineobj.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 454 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 455 | commandBuffer->BindPipeline(pipelineobj); |
| 456 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | // ******************************************************************************************************************** |
| 460 | // ******************************************************************************************************************** |
| 461 | // ******************************************************************************************************************** |
| 462 | // ******************************************************************************************************************** |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 463 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 464 | #if 0 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 465 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 466 | { |
| 467 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 468 | VkFenceCreateInfo fenceInfo = {}; |
| 469 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 470 | fenceInfo.pNext = NULL; |
| 471 | fenceInfo.flags = 0; |
| 472 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 473 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 474 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 475 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | e389b88 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 476 | |
| 477 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 478 | vk_testing::Buffer buffer; |
| 479 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 480 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 481 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 482 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 483 | EndCommandBuffer(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 484 | |
| 485 | testFence.init(*m_device, fenceInfo); |
| 486 | |
| 487 | // Bypass framework since it does the waits automatically |
| 488 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 489 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 490 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 491 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 492 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 493 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 494 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 495 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 496 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 497 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 498 | |
| 499 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 500 | ASSERT_VK_SUCCESS( err ); |
| 501 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 502 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 503 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 504 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 505 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 506 | FAIL() << "Did not receive Error 'Resetting CB (0xaddress) before it has completed. You must check CB flag before.'"; |
| 507 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 508 | } |
| 509 | } |
| 510 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 511 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 512 | { |
| 513 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 514 | VkFenceCreateInfo fenceInfo = {}; |
| 515 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 516 | fenceInfo.pNext = NULL; |
| 517 | fenceInfo.flags = 0; |
| 518 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 519 | 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] | 520 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 521 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 522 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 523 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 524 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 525 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 526 | 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] | 527 | EndCommandBuffer(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 528 | |
| 529 | testFence.init(*m_device, fenceInfo); |
| 530 | |
| 531 | // Bypass framework since it does the waits automatically |
| 532 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 533 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 534 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 535 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 536 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 537 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 538 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 539 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 540 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 541 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 542 | |
| 543 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 544 | ASSERT_VK_SUCCESS( err ); |
| 545 | |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 546 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 547 | VkCommandBufferBeginInfo info = {}; |
| 548 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 549 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 550 | info.renderPass = VK_NULL_HANDLE; |
| 551 | info.subpass = 0; |
| 552 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | fdc1cd0 | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 553 | info.occlusionQueryEnable = VK_FALSE; |
| 554 | info.queryFlags = 0; |
| 555 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 556 | |
| 557 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 558 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 559 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 560 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 561 | FAIL() << "Did not receive Error 'Calling vkBeginCommandBuffer() on an active CB (0xaddress) before it has completed'"; |
| 562 | m_errorMonitor->DumpFailureMsgs(); |
| 563 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 564 | } |
| 565 | } |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 566 | #endif |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 567 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) |
| 568 | { |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 569 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 570 | bool pass; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 571 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 572 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 573 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 574 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 575 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 576 | |
| 577 | // Create an image, allocate memory, free it, and then try to bind it |
| 578 | VkImage image; |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 579 | VkDeviceMemory mem; |
| 580 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 581 | |
| 582 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 583 | const int32_t tex_width = 32; |
| 584 | const int32_t tex_height = 32; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 585 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 586 | VkImageCreateInfo image_create_info = {}; |
| 587 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 588 | image_create_info.pNext = NULL; |
| 589 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 590 | image_create_info.format = tex_format; |
| 591 | image_create_info.extent.width = tex_width; |
| 592 | image_create_info.extent.height = tex_height; |
| 593 | image_create_info.extent.depth = 1; |
| 594 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 595 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 596 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 597 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 598 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 599 | image_create_info.flags = 0; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 600 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 601 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 602 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 603 | mem_alloc.pNext = NULL; |
| 604 | mem_alloc.allocationSize = 0; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 605 | // Introduce failure, do NOT set memProps to VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 606 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 607 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 608 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 609 | ASSERT_VK_SUCCESS(err); |
| 610 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 611 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 612 | image, |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 613 | &mem_reqs); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 614 | |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 615 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 616 | |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 617 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 618 | if(!pass) { // If we can't find any unmappable memory this test doesn't make sense |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 619 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 49a3b65 | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 620 | return; |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 621 | } |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 622 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 623 | // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 624 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 625 | ASSERT_VK_SUCCESS(err); |
| 626 | |
| 627 | // Try to bind free memory that has been freed |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 628 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 629 | ASSERT_VK_SUCCESS(err); |
| 630 | |
| 631 | // Map memory as if to initialize the image |
| 632 | void *mappedAddress = NULL; |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 633 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, &mappedAddress); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 634 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 635 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 636 | FAIL() << "Did not receive Error 'Error received did not match expected error message from vkMapMemory in MemTracker'"; |
| 637 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 638 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 639 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 640 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 641 | } |
| 642 | |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 643 | // TODO : Is this test still valid. Not sure it is with updates to memory binding model |
| 644 | // Verify and delete the test of fix the check |
| 645 | //TEST_F(VkLayerTest, FreeBoundMemory) |
| 646 | //{ |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 647 | // VkResult err; |
| 648 | // |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 649 | // m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARN_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 650 | // "Freeing memory object while it still has references"); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 651 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 652 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 653 | |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 654 | // // Create an image, allocate memory, free it, and then try to bind it |
| 655 | // VkImage image; |
| 656 | // VkDeviceMemory mem; |
| 657 | // VkMemoryRequirements mem_reqs; |
| 658 | // |
| 659 | // const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 660 | // const int32_t tex_width = 32; |
| 661 | // const int32_t tex_height = 32; |
| 662 | // |
| 663 | // const VkImageCreateInfo image_create_info = { |
| 664 | // .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 665 | // .pNext = NULL, |
| 666 | // .imageType = VK_IMAGE_TYPE_2D, |
| 667 | // .format = tex_format, |
| 668 | // .extent = { tex_width, tex_height, 1 }, |
| 669 | // .mipLevels = 1, |
| 670 | // .arraySize = 1, |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 671 | // .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 672 | // .tiling = VK_IMAGE_TILING_LINEAR, |
| 673 | // .usage = VK_IMAGE_USAGE_SAMPLED_BIT, |
| 674 | // .flags = 0, |
| 675 | // }; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 676 | // VkMemoryAllocateInfo mem_alloc = { |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 677 | // .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 678 | // .pNext = NULL, |
| 679 | // .allocationSize = 0, |
| 680 | // .memoryTypeIndex = 0, |
| 681 | // }; |
| 682 | // |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 683 | // err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 684 | // ASSERT_VK_SUCCESS(err); |
| 685 | // |
| 686 | // err = vkGetImageMemoryRequirements(m_device->device(), |
| 687 | // image, |
| 688 | // &mem_reqs); |
| 689 | // ASSERT_VK_SUCCESS(err); |
| 690 | // |
| 691 | // mem_alloc.allocationSize = mem_reqs.size; |
| 692 | // |
| 693 | // err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 694 | // ASSERT_VK_SUCCESS(err); |
| 695 | // |
| 696 | // // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 697 | // err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 698 | // ASSERT_VK_SUCCESS(err); |
| 699 | // |
| 700 | // // Bind memory to Image object |
| 701 | // err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 702 | // ASSERT_VK_SUCCESS(err); |
| 703 | // |
| 704 | // // Introduce validation failure, free memory while still bound to object |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 705 | // vkFreeMemory(m_device->device(), mem, NULL); |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 706 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 707 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 708 | // FAIL() << "Did not receive Warning 'Freeing memory object while it still has references'"); |
| 709 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 710 | // } |
| 711 | //} |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 712 | |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 713 | TEST_F(VkLayerTest, RebindMemory) |
| 714 | { |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 715 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 716 | bool pass; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 717 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 718 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 719 | "which has already been bound to mem object"); |
| 720 | |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 721 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 722 | |
| 723 | // Create an image, allocate memory, free it, and then try to bind it |
| 724 | VkImage image; |
| 725 | VkDeviceMemory mem1; |
| 726 | VkDeviceMemory mem2; |
| 727 | VkMemoryRequirements mem_reqs; |
| 728 | |
| 729 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 730 | const int32_t tex_width = 32; |
| 731 | const int32_t tex_height = 32; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 732 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 733 | VkImageCreateInfo image_create_info = {}; |
| 734 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 735 | image_create_info.pNext = NULL; |
| 736 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 737 | image_create_info.format = tex_format; |
| 738 | image_create_info.extent.width = tex_width; |
| 739 | image_create_info.extent.height = tex_height; |
| 740 | image_create_info.extent.depth = 1; |
| 741 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 742 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 743 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 744 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 745 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 746 | image_create_info.flags = 0; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 747 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 748 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 749 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 750 | mem_alloc.pNext = NULL; |
| 751 | mem_alloc.allocationSize = 0; |
| 752 | mem_alloc.memoryTypeIndex = 0; |
| 753 | |
| 754 | // Introduce failure, do NOT set memProps to VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 755 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 756 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 757 | ASSERT_VK_SUCCESS(err); |
| 758 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 759 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 760 | image, |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 761 | &mem_reqs); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 762 | |
| 763 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 764 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 765 | ASSERT_TRUE(pass); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 766 | |
| 767 | // allocate 2 memory objects |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 768 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 769 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 770 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 771 | ASSERT_VK_SUCCESS(err); |
| 772 | |
| 773 | // Bind first memory object to Image object |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 774 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 775 | ASSERT_VK_SUCCESS(err); |
| 776 | |
| 777 | // Introduce validation failure, try to bind a different memory object to the same image object |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 778 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 779 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 780 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 781 | FAIL() << "Did not receive Error when rebinding memory to an object"; |
| 782 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 783 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 784 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 785 | vkDestroyImage(m_device->device(), image, NULL); |
| 786 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 787 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 788 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 789 | |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 790 | TEST_F(VkLayerTest, SubmitSignaledFence) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 791 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 792 | vk_testing::Fence testFence; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 793 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 794 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 795 | "submitted in SIGNALED state. Fences must be reset before being submitted"); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 796 | |
| 797 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 798 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 799 | fenceInfo.pNext = NULL; |
| 800 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 801 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 802 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 803 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 804 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 805 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 806 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 807 | 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] | 808 | EndCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 809 | |
| 810 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 811 | |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 812 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 813 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 814 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 815 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 816 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 817 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 818 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 819 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 820 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 821 | |
| 822 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 823 | vkQueueWaitIdle(m_device->m_queue ); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 824 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 825 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 826 | FAIL() << "Did not receive Error 'VkQueueSubmit with fence in SIGNALED_STATE'"; |
| 827 | m_errorMonitor->DumpFailureMsgs(); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 828 | } |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | TEST_F(VkLayerTest, ResetUnsignaledFence) |
| 832 | { |
| 833 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 834 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 835 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 836 | fenceInfo.pNext = NULL; |
| 837 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 838 | // TODO: verify that this matches layer |
| 839 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARN_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 840 | "submitted to VkResetFences in UNSIGNALED STATE"); |
| 841 | |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 842 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 843 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | a499234 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 844 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 845 | vkResetFences(m_device->device(), 1, fences); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 846 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 847 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 848 | FAIL() << "Did not receive Error 'VkResetFences with fence in UNSIGNALED_STATE'"; |
| 849 | m_errorMonitor->DumpFailureMsgs(); |
| 850 | } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 851 | } |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 852 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 853 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 854 | #if 0 |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 855 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 856 | { |
| 857 | // Initiate Draw w/o a PSO bound |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 858 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 859 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 860 | "Invalid usage flag for image "); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 861 | |
| 862 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 863 | VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 864 | BeginCommandBuffer(); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 865 | |
| 866 | const VkExtent3D e3d = { |
| 867 | .width = 128, |
| 868 | .height = 128, |
| 869 | .depth = 1, |
| 870 | }; |
| 871 | const VkImageCreateInfo ici = { |
| 872 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 873 | .pNext = NULL, |
| 874 | .imageType = VK_IMAGE_TYPE_2D, |
| 875 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 876 | .extent = e3d, |
| 877 | .mipLevels = 1, |
| 878 | .arraySize = 1, |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 879 | .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 880 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | c3b8eea | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 881 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 882 | .flags = 0, |
| 883 | }; |
| 884 | |
| 885 | VkImage dsi; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 886 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 887 | VkDepthStencilView dsv; |
| 888 | const VkDepthStencilViewCreateInfo dsvci = { |
| 889 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 890 | .pNext = NULL, |
| 891 | .image = dsi, |
| 892 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 893 | .baseArrayLayer = 0, |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 894 | .arraySize = 1, |
| 895 | .flags = 0, |
| 896 | }; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 897 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 898 | |
| 899 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 900 | FAIL() << "Error received was not 'Invalid usage flag for image...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 901 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 902 | } |
| 903 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 904 | #endif // 0 |
| 905 | #endif // MEM_TRACKER_TESTS |
| 906 | |
Tobin Ehlis | 40e9f52 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 907 | #if OBJ_TRACKER_TESTS |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 908 | TEST_F(VkLayerTest, PipelineNotBound) |
| 909 | { |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 910 | VkResult err; |
| 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 VkPipeline Object "); |
| 914 | |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 915 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 916 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 917 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 918 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 919 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 920 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 921 | |
| 922 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 923 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 924 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 925 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 926 | ds_pool_ci.poolSizeCount = 1; |
| 927 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 928 | |
| 929 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 930 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 931 | ASSERT_VK_SUCCESS(err); |
| 932 | |
| 933 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 934 | dsl_binding.binding = 0; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 935 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 936 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 937 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 938 | dsl_binding.pImmutableSamplers = NULL; |
| 939 | |
| 940 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 941 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 942 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 943 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 944 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 945 | |
| 946 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 947 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 948 | ASSERT_VK_SUCCESS(err); |
| 949 | |
| 950 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 951 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 952 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 953 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 954 | alloc_info.descriptorPool = ds_pool; |
| 955 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 956 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 957 | ASSERT_VK_SUCCESS(err); |
| 958 | |
| 959 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 960 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 961 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 962 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 963 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 964 | |
| 965 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 966 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 967 | ASSERT_VK_SUCCESS(err); |
| 968 | |
| 969 | VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 970 | |
| 971 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 972 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 973 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 974 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 975 | FAIL() << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be'" << endl; |
| 976 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 977 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 978 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 979 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 980 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 981 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 982 | } |
| 983 | |
| 984 | TEST_F(VkLayerTest, BindInvalidMemory) |
| 985 | { |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 986 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 987 | bool pass; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 988 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 989 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 990 | "Invalid VkDeviceMemory Object "); |
| 991 | |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 992 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 993 | |
| 994 | // Create an image, allocate memory, free it, and then try to bind it |
| 995 | VkImage image; |
| 996 | VkDeviceMemory mem; |
| 997 | VkMemoryRequirements mem_reqs; |
| 998 | |
| 999 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1000 | const int32_t tex_width = 32; |
| 1001 | const int32_t tex_height = 32; |
| 1002 | |
| 1003 | VkImageCreateInfo image_create_info = {}; |
| 1004 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1005 | image_create_info.pNext = NULL; |
| 1006 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1007 | image_create_info.format = tex_format; |
| 1008 | image_create_info.extent.width = tex_width; |
| 1009 | image_create_info.extent.height = tex_height; |
| 1010 | image_create_info.extent.depth = 1; |
| 1011 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1012 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1013 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1014 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1015 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1016 | image_create_info.flags = 0; |
| 1017 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1018 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1019 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1020 | mem_alloc.pNext = NULL; |
| 1021 | mem_alloc.allocationSize = 0; |
| 1022 | mem_alloc.memoryTypeIndex = 0; |
| 1023 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1024 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1025 | ASSERT_VK_SUCCESS(err); |
| 1026 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1027 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1028 | image, |
| 1029 | &mem_reqs); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1030 | |
| 1031 | mem_alloc.allocationSize = mem_reqs.size; |
| 1032 | |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1033 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1034 | ASSERT_TRUE(pass); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1035 | |
| 1036 | // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1037 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1038 | ASSERT_VK_SUCCESS(err); |
| 1039 | |
| 1040 | // Introduce validation failure, free memory before binding |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1041 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1042 | |
| 1043 | // Try to bind free memory that has been freed |
| 1044 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1045 | // This may very well return an error. |
| 1046 | (void)err; |
| 1047 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1048 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1049 | FAIL() << "Did not receive Error 'Invalid VkDeviceMemory Object 0x<handle>'"; |
| 1050 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1051 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1052 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1053 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) |
| 1057 | { |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1058 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1059 | bool pass; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1060 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1061 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Invalid VkImage Object "); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1062 | |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1063 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1064 | |
| 1065 | // Create an image object, allocate memory, destroy the object and then try to bind it |
| 1066 | VkImage image; |
| 1067 | VkDeviceMemory mem; |
| 1068 | VkMemoryRequirements mem_reqs; |
| 1069 | |
| 1070 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1071 | const int32_t tex_width = 32; |
| 1072 | const int32_t tex_height = 32; |
| 1073 | |
| 1074 | VkImageCreateInfo image_create_info = {}; |
| 1075 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1076 | image_create_info.pNext = NULL; |
| 1077 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1078 | image_create_info.format = tex_format; |
| 1079 | image_create_info.extent.width = tex_width; |
| 1080 | image_create_info.extent.height = tex_height; |
| 1081 | image_create_info.extent.depth = 1; |
| 1082 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1083 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1084 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1085 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1086 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1087 | image_create_info.flags = 0; |
| 1088 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1089 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1090 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1091 | mem_alloc.pNext = NULL; |
| 1092 | mem_alloc.allocationSize = 0; |
| 1093 | mem_alloc.memoryTypeIndex = 0; |
| 1094 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1095 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1096 | ASSERT_VK_SUCCESS(err); |
| 1097 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1098 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1099 | image, |
| 1100 | &mem_reqs); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1101 | |
| 1102 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1103 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1104 | ASSERT_TRUE(pass); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1105 | |
| 1106 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1107 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1108 | ASSERT_VK_SUCCESS(err); |
| 1109 | |
| 1110 | // Introduce validation failure, destroy Image object before binding |
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 | ASSERT_VK_SUCCESS(err); |
| 1113 | |
| 1114 | // Now Try to bind memory to this destroyed object |
| 1115 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1116 | // This may very well return an error. |
| 1117 | (void) err; |
| 1118 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1119 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1120 | FAIL() << "Did not receive Error 'Invalid VkImage Object 0x<handle>'"; |
| 1121 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1122 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1123 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1124 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1125 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1126 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1127 | #endif // OBJ_TRACKER_TESTS |
| 1128 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1129 | #if DRAW_STATE_TESTS |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1130 | TEST_F(VkLayerTest, LineWidthStateNotBound) |
| 1131 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1132 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1133 | "Dynamic line width state not set for this command buffer"); |
| 1134 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1135 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line width state object is not bound beforehand"); |
| 1136 | |
| 1137 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailLineWidth); |
| 1138 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1139 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1140 | FAIL() << "Did not receive Error 'Dynamic line width state not set for this command buffer'"; |
| 1141 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1142 | } |
| 1143 | } |
| 1144 | |
| 1145 | TEST_F(VkLayerTest, DepthBiasStateNotBound) |
| 1146 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1147 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1148 | "Dynamic depth bias state not set for this command buffer"); |
| 1149 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1150 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bias state object is not bound beforehand"); |
| 1151 | |
| 1152 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBias); |
| 1153 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1154 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1155 | FAIL() << "Did not receive Error 'Dynamic depth bias state not set for this command buffer'"; |
| 1156 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1157 | } |
| 1158 | } |
| 1159 | |
Cody Northrop | bca3bcd | 2015-10-27 16:54:28 -0600 | [diff] [blame] | 1160 | // Disable these two tests until we can sort out how to track multiple layer errors |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1161 | TEST_F(VkLayerTest, ViewportStateNotBound) |
| 1162 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1163 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1164 | "Dynamic viewport state not set for this command buffer"); |
| 1165 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1166 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1167 | |
| 1168 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailViewport); |
| 1169 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1170 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1171 | FAIL() << "Did not recieve Error 'Dynamic scissor state not set for this command buffer'"; |
| 1172 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1173 | } |
| 1174 | } |
| 1175 | |
| 1176 | TEST_F(VkLayerTest, ScissorStateNotBound) |
| 1177 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1178 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1179 | "Dynamic scissor state not set for this command buffer"); |
| 1180 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1181 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1182 | |
| 1183 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailScissor); |
| 1184 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1185 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1186 | FAIL() << "Did not recieve Error ' Expected: 'Dynamic scissor state not set for this command buffer'"; |
| 1187 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1188 | } |
| 1189 | } |
| 1190 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1191 | TEST_F(VkLayerTest, BlendStateNotBound) |
| 1192 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1193 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1194 | "Dynamic blend object state not set for this command buffer"); |
| 1195 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1196 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend state object is not bound beforehand"); |
| 1197 | |
| 1198 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailBlend); |
| 1199 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1200 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1201 | FAIL() << "Did not recieve Error 'Dynamic blend object state not set for this command buffer'"; |
| 1202 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1203 | } |
| 1204 | } |
| 1205 | |
| 1206 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) |
| 1207 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1208 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1209 | "Dynamic depth bounds state not set for this command buffer"); |
| 1210 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1211 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bounds state object is not bound beforehand"); |
| 1212 | |
| 1213 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBounds); |
| 1214 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1215 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1216 | FAIL() << "Did not receive Error 'Dynamic depth bounds state not set for this command buffer'"; |
| 1217 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | TEST_F(VkLayerTest, StencilReadMaskNotSet) |
| 1222 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1223 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1224 | "Dynamic stencil read mask state not set for this command buffer"); |
| 1225 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1226 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1227 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1228 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil read mask is not set beforehand"); |
| 1229 | |
| 1230 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReadMask); |
| 1231 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1232 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1233 | FAIL() << "Did not receive Error 'Dynamic stencil read mask state not set for this command buffer'"; |
| 1234 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1235 | } |
| 1236 | } |
| 1237 | |
| 1238 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) |
| 1239 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1240 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1241 | "Dynamic stencil write mask state not set for this command buffer"); |
| 1242 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1243 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1244 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1245 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil write mask is not set beforehand"); |
| 1246 | |
| 1247 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilWriteMask); |
| 1248 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1249 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1250 | FAIL() << "Did not receive Error 'Dynamic stencil write mask state not set for this command buffer'"; |
| 1251 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1252 | } |
| 1253 | } |
| 1254 | |
| 1255 | TEST_F(VkLayerTest, StencilReferenceNotSet) |
| 1256 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1257 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1258 | "Dynamic stencil reference state not set for this command buffer"); |
| 1259 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1260 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil reference is not set beforehand"); |
| 1261 | |
| 1262 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReference); |
| 1263 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1264 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1265 | FAIL() << "Did not receive Error 'Dynamic stencil reference state not set for this command buffer'"; |
| 1266 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1267 | } |
| 1268 | } |
| 1269 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1270 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1271 | { |
| 1272 | vk_testing::Fence testFence; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1273 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1274 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1275 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has been submitted"); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1276 | |
| 1277 | VkFenceCreateInfo fenceInfo = {}; |
| 1278 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1279 | fenceInfo.pNext = NULL; |
| 1280 | fenceInfo.flags = 0; |
| 1281 | |
| 1282 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1283 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1284 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1285 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1286 | // We luck out b/c by default the framework creates CB w/ the VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1287 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1288 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1289 | EndCommandBuffer(); |
| 1290 | |
| 1291 | testFence.init(*m_device, fenceInfo); |
| 1292 | |
| 1293 | // Bypass framework since it does the waits automatically |
| 1294 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1295 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1296 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1297 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1298 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1299 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1300 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1301 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1302 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1303 | submit_info.pSignalSemaphores = NULL; |
| 1304 | |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1305 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1306 | ASSERT_VK_SUCCESS( err ); |
| 1307 | |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1308 | // Cause validation error by re-submitting cmd buffer that should only be submitted once |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1309 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1310 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1311 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1312 | FAIL() << "Did not receive Error 'CB (0xaddress) was created w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set...'"; |
| 1313 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1314 | } |
| 1315 | } |
| 1316 | |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1317 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) |
| 1318 | { |
| 1319 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1320 | VkResult err; |
| 1321 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1322 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1323 | "Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
| 1324 | |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1325 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1326 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1327 | |
| 1328 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer descriptor from it |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1329 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1330 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1331 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1332 | |
| 1333 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1334 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1335 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1336 | ds_pool_ci.flags = 0; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1337 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1338 | ds_pool_ci.poolSizeCount = 1; |
| 1339 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1340 | |
| 1341 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1342 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1343 | ASSERT_VK_SUCCESS(err); |
| 1344 | |
| 1345 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1346 | dsl_binding.binding = 0; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1347 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1348 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1349 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1350 | dsl_binding.pImmutableSamplers = NULL; |
| 1351 | |
| 1352 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1353 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1354 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1355 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1356 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1357 | |
| 1358 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1359 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1360 | ASSERT_VK_SUCCESS(err); |
| 1361 | |
| 1362 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1363 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1364 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1365 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1366 | alloc_info.descriptorPool = ds_pool; |
| 1367 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1368 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1369 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1370 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1371 | FAIL() << "Did not receive Error 'Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER...'"; |
| 1372 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1373 | } |
| 1374 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1375 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1376 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1377 | } |
| 1378 | |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1379 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) |
| 1380 | { |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1381 | VkResult err; |
| 1382 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1383 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1384 | "It is invalid to call vkFreeDescriptorSets() with a pool created without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
| 1385 | |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1386 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1387 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1388 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1389 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1390 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1391 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1392 | |
| 1393 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1394 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1395 | ds_pool_ci.pNext = NULL; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1396 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1397 | ds_pool_ci.poolSizeCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1398 | ds_pool_ci.flags = 0; |
| 1399 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1400 | // app can only call vkResetDescriptorPool on this pool.; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1401 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1402 | |
| 1403 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1404 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1405 | ASSERT_VK_SUCCESS(err); |
| 1406 | |
| 1407 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1408 | dsl_binding.binding = 0; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1409 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1410 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1411 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1412 | dsl_binding.pImmutableSamplers = NULL; |
| 1413 | |
| 1414 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1415 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1416 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1417 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1418 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1419 | |
| 1420 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1421 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1422 | ASSERT_VK_SUCCESS(err); |
| 1423 | |
| 1424 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1425 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1426 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1427 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1428 | alloc_info.descriptorPool = ds_pool; |
| 1429 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1430 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1431 | ASSERT_VK_SUCCESS(err); |
| 1432 | |
| 1433 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1434 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1435 | FAIL() << "Did not receive Error 'It is invalid to call vkFreeDescriptorSets() with a pool created with...'"; |
| 1436 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1437 | } |
| 1438 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1439 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1440 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1441 | } |
| 1442 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1443 | TEST_F(VkLayerTest, InvalidDescriptorPool) |
| 1444 | { |
| 1445 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1446 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1447 | // Attempt to clear DS Pool with bad object |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1448 | /* |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1449 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1450 | "Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call"); |
| 1451 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1452 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1453 | vkResetDescriptorPool(device(), badPool); |
| 1454 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1455 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1456 | FAIL() << "Did not receive Error 'Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1457 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1458 | }*/ |
| 1459 | } |
| 1460 | |
| 1461 | TEST_F(VkLayerTest, InvalidDescriptorSet) |
| 1462 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1463 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1464 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1465 | // Create a valid cmd buffer |
| 1466 | // call vkCmdBindDescriptorSets w/ false DS |
| 1467 | } |
| 1468 | |
| 1469 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) |
| 1470 | { |
| 1471 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1472 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1473 | } |
| 1474 | |
| 1475 | TEST_F(VkLayerTest, InvalidPipeline) |
| 1476 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1477 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1478 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1479 | // Create a valid cmd buffer |
| 1480 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1481 | // |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1482 | // m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1483 | // "Attempt to bind Pipeline "); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1484 | // |
| 1485 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1486 | // VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1487 | // BeginCommandBuffer(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1488 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1489 | // vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1490 | // |
| 1491 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 1492 | // FAIL() << "Did not receive Error 'Attempt to bind Pipeline 0xbaadb1be that doesn't exist!'"; |
| 1493 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1494 | // } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1495 | } |
| 1496 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1497 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1498 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1499 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on CommandBuffer |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1500 | VkResult err; |
| 1501 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1502 | // TODO: verify that this matches layer |
| 1503 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARN_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1504 | " bound but it was never updated. "); |
| 1505 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1506 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1507 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1508 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1509 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1510 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1511 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1512 | |
| 1513 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1514 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1515 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1516 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1517 | ds_pool_ci.poolSizeCount = 1; |
| 1518 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1519 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1520 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1521 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1522 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1523 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1524 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1525 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1526 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1527 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1528 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1529 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1530 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1531 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1532 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1533 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1534 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1535 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1536 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1537 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1538 | ASSERT_VK_SUCCESS(err); |
| 1539 | |
| 1540 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1541 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1542 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1543 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1544 | alloc_info.descriptorPool = ds_pool; |
| 1545 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1546 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1547 | ASSERT_VK_SUCCESS(err); |
| 1548 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1549 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1550 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1551 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1552 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1553 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1554 | |
| 1555 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1556 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1557 | ASSERT_VK_SUCCESS(err); |
| 1558 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1559 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1560 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 1561 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1562 | |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1563 | VkPipelineObj pipe(m_device); |
| 1564 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1565 | pipe.AddShader(&fs); |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1566 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1567 | |
| 1568 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1569 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1570 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1571 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1572 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1573 | FAIL() << "Did not recieve Warning 'DS <blah> bound but it was never updated. You may want to either update it or not bind it.'"; |
| 1574 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1575 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1576 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1577 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1578 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1579 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1580 | } |
| 1581 | |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1582 | TEST_F(VkLayerTest, InvalidBufferViewObject) |
| 1583 | { |
| 1584 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
| 1585 | VkResult err; |
| 1586 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1587 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1588 | "Attempt to update descriptor with invalid bufferView "); |
| 1589 | |
| 1590 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1591 | VkDescriptorPoolSize ds_type_count = {}; |
| 1592 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1593 | ds_type_count.descriptorCount = 1; |
| 1594 | |
| 1595 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1596 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1597 | ds_pool_ci.pNext = NULL; |
| 1598 | ds_pool_ci.maxSets = 1; |
| 1599 | ds_pool_ci.poolSizeCount = 1; |
| 1600 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1601 | |
| 1602 | VkDescriptorPool ds_pool; |
| 1603 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1604 | ASSERT_VK_SUCCESS(err); |
| 1605 | |
| 1606 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1607 | dsl_binding.binding = 0; |
| 1608 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1609 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1610 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1611 | dsl_binding.pImmutableSamplers = NULL; |
| 1612 | |
| 1613 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1614 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1615 | ds_layout_ci.pNext = NULL; |
| 1616 | ds_layout_ci.bindingCount = 1; |
| 1617 | ds_layout_ci.pBinding = &dsl_binding; |
| 1618 | VkDescriptorSetLayout ds_layout; |
| 1619 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 1620 | ASSERT_VK_SUCCESS(err); |
| 1621 | |
| 1622 | VkDescriptorSet descriptorSet; |
| 1623 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1624 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1625 | alloc_info.setLayoutCount = 1; |
| 1626 | alloc_info.descriptorPool = ds_pool; |
| 1627 | alloc_info.pSetLayouts = &ds_layout; |
| 1628 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 1629 | ASSERT_VK_SUCCESS(err); |
| 1630 | |
| 1631 | VkBufferView view = (VkBufferView) 0xbaadbeef; // invalid bufferView object |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1632 | VkWriteDescriptorSet descriptor_write; |
| 1633 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1634 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1635 | descriptor_write.dstSet = descriptorSet; |
| 1636 | descriptor_write.dstBinding = 0; |
| 1637 | descriptor_write.descriptorCount = 1; |
| 1638 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1639 | descriptor_write.pTexelBufferView = &view; |
| 1640 | |
| 1641 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1642 | |
| 1643 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | d949145 | 2015-11-05 10:27:49 -0700 | [diff] [blame] | 1644 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid bufferView'"; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1645 | m_errorMonitor->DumpFailureMsgs(); |
| 1646 | } |
| 1647 | |
| 1648 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1649 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1650 | } |
| 1651 | |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1652 | TEST_F(VkLayerTest, InvalidDynamicOffsetCount) |
| 1653 | { |
| 1654 | // Create a descriptorSet w/ some dynamic descriptors and then don't send offsets when binding |
| 1655 | VkResult err; |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1656 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1657 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but dynamicOffsetCount is 0. "); |
| 1658 | |
| 1659 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1660 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1661 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1662 | |
| 1663 | VkDescriptorPoolSize ds_type_count = {}; |
| 1664 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1665 | ds_type_count.descriptorCount = 1; |
| 1666 | |
| 1667 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1668 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1669 | ds_pool_ci.pNext = NULL; |
| 1670 | ds_pool_ci.maxSets = 1; |
| 1671 | ds_pool_ci.poolSizeCount = 1; |
| 1672 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1673 | |
| 1674 | VkDescriptorPool ds_pool; |
| 1675 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1676 | ASSERT_VK_SUCCESS(err); |
| 1677 | |
| 1678 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1679 | dsl_binding.binding = 0; |
| 1680 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
Jon Ashburn | 96b714a | 2015-11-06 15:31:44 -0700 | [diff] [blame] | 1681 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1682 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1683 | dsl_binding.pImmutableSamplers = NULL; |
| 1684 | |
| 1685 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1686 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1687 | ds_layout_ci.pNext = NULL; |
| 1688 | ds_layout_ci.bindingCount = 1; |
| 1689 | ds_layout_ci.pBinding = &dsl_binding; |
| 1690 | VkDescriptorSetLayout ds_layout; |
| 1691 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 1692 | ASSERT_VK_SUCCESS(err); |
| 1693 | |
| 1694 | VkDescriptorSet descriptorSet; |
| 1695 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1696 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1697 | alloc_info.setLayoutCount = 1; |
| 1698 | alloc_info.descriptorPool = ds_pool; |
| 1699 | alloc_info.pSetLayouts = &ds_layout; |
| 1700 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 1701 | ASSERT_VK_SUCCESS(err); |
| 1702 | |
| 1703 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1704 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1705 | pipeline_layout_ci.pNext = NULL; |
| 1706 | pipeline_layout_ci.setLayoutCount = 1; |
| 1707 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1708 | |
| 1709 | VkPipelineLayout pipeline_layout; |
| 1710 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 1711 | ASSERT_VK_SUCCESS(err); |
| 1712 | |
| 1713 | // Create a buffer to update the descriptor with |
| 1714 | uint32_t qfi = 0; |
| 1715 | VkBufferCreateInfo buffCI = {}; |
| 1716 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1717 | buffCI.size = 1024; |
| 1718 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1719 | buffCI.queueFamilyIndexCount = 1; |
| 1720 | buffCI.pQueueFamilyIndices = &qfi; |
| 1721 | |
| 1722 | VkBuffer dyub; |
| 1723 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 1724 | ASSERT_VK_SUCCESS(err); |
| 1725 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 1726 | VkDescriptorBufferInfo buffInfo = {}; |
| 1727 | buffInfo.buffer = dyub; |
| 1728 | buffInfo.offset = 0; |
| 1729 | buffInfo.range = 1024; |
| 1730 | |
| 1731 | VkWriteDescriptorSet descriptor_write; |
| 1732 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1733 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1734 | descriptor_write.dstSet = descriptorSet; |
| 1735 | descriptor_write.dstBinding = 0; |
| 1736 | descriptor_write.descriptorCount = 1; |
| 1737 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1738 | descriptor_write.pBufferInfo = &buffInfo; |
| 1739 | |
| 1740 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1741 | |
| 1742 | BeginCommandBuffer(); |
| 1743 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptorSet, 0, NULL); |
| 1744 | |
| 1745 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1746 | FAIL() << "Error received was not 'Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but dynamicOffsetCount is 0...'"; |
| 1747 | m_errorMonitor->DumpFailureMsgs(); |
| 1748 | } |
| 1749 | |
| 1750 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1751 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1752 | } |
| 1753 | |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1754 | TEST_F(VkLayerTest, DescriptorSetCompatibility) |
| 1755 | { |
| 1756 | // Test various desriptorSet errors with bad binding combinations |
| 1757 | VkResult err; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1758 | |
| 1759 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1760 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1761 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1762 | |
| 1763 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 1764 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
| 1765 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1766 | ds_type_count[0].descriptorCount = 10; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1767 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 1768 | ds_type_count[1].descriptorCount = 2; |
| 1769 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 1770 | ds_type_count[2].descriptorCount = 2; |
| 1771 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1772 | ds_type_count[3].descriptorCount = 5; |
| 1773 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT type |
| 1774 | //ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 1775 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 1776 | ds_type_count[4].descriptorCount = 2; |
| 1777 | |
| 1778 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1779 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1780 | ds_pool_ci.pNext = NULL; |
| 1781 | ds_pool_ci.maxSets = 1; |
| 1782 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 1783 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 1784 | |
| 1785 | VkDescriptorPool ds_pool; |
| 1786 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1787 | ASSERT_VK_SUCCESS(err); |
| 1788 | |
| 1789 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 1790 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
| 1791 | dsl_binding[0].binding = 0; |
| 1792 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1793 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1794 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 1795 | dsl_binding[0].pImmutableSamplers = NULL; |
| 1796 | |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1797 | // Create layout identical to set0 layout but w/ different stageFlags |
| 1798 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
| 1799 | dsl_fs_stage_only.binding = 0; |
| 1800 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1801 | dsl_fs_stage_only.descriptorCount = 5; |
| 1802 | dsl_fs_stage_only.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at bind time |
| 1803 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1804 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1805 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1806 | ds_layout_ci.pNext = NULL; |
| 1807 | ds_layout_ci.bindingCount = 1; |
| 1808 | ds_layout_ci.pBinding = dsl_binding; |
| 1809 | static const uint32_t NUM_LAYOUTS = 4; |
| 1810 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1811 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
| 1812 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only layout for error case |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1813 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[0]); |
| 1814 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1815 | ds_layout_ci.pBinding = &dsl_fs_stage_only; |
| 1816 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout_fs_only); |
| 1817 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1818 | dsl_binding[0].binding = 0; |
| 1819 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1820 | dsl_binding[0].descriptorCount = 2; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1821 | dsl_binding[0].binding = 1; |
| 1822 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1823 | dsl_binding[0].descriptorCount = 2; |
| 1824 | ds_layout_ci.pBinding = dsl_binding; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1825 | ds_layout_ci.bindingCount = 2; |
| 1826 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[1]); |
| 1827 | ASSERT_VK_SUCCESS(err); |
| 1828 | dsl_binding[0].binding = 0; |
| 1829 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1830 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1831 | ds_layout_ci.bindingCount = 1; |
| 1832 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[2]); |
| 1833 | ASSERT_VK_SUCCESS(err); |
| 1834 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1835 | dsl_binding[0].descriptorCount = 2; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1836 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[3]); |
| 1837 | ASSERT_VK_SUCCESS(err); |
| 1838 | |
| 1839 | static const uint32_t NUM_SETS = 4; |
| 1840 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 1841 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1842 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1843 | alloc_info.setLayoutCount = NUM_LAYOUTS; |
| 1844 | alloc_info.descriptorPool = ds_pool; |
| 1845 | alloc_info.pSetLayouts = ds_layout; |
| 1846 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, descriptorSet); |
| 1847 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1848 | VkDescriptorSet ds0_fs_only = {}; |
| 1849 | alloc_info.setLayoutCount = 1; |
| 1850 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
| 1851 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
| 1852 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1853 | |
| 1854 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1855 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1856 | pipeline_layout_ci.pNext = NULL; |
| 1857 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 1858 | pipeline_layout_ci.pSetLayouts = ds_layout; |
| 1859 | |
| 1860 | VkPipelineLayout pipeline_layout; |
| 1861 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 1862 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1863 | // Create pipelineLayout with only one setLayout |
| 1864 | pipeline_layout_ci.setLayoutCount = 1; |
| 1865 | VkPipelineLayout single_pipe_layout; |
| 1866 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &single_pipe_layout); |
| 1867 | ASSERT_VK_SUCCESS(err); |
| 1868 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 1869 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 1870 | VkPipelineLayout pipe_layout_one_desc; |
| 1871 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipe_layout_one_desc); |
| 1872 | ASSERT_VK_SUCCESS(err); |
| 1873 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 1874 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 1875 | VkPipelineLayout pipe_layout_five_samp; |
| 1876 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipe_layout_five_samp); |
| 1877 | ASSERT_VK_SUCCESS(err); |
| 1878 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 1879 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 1880 | VkPipelineLayout pipe_layout_fs_only; |
| 1881 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipe_layout_fs_only); |
| 1882 | ASSERT_VK_SUCCESS(err); |
| 1883 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 1884 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 1885 | pl_bad_s0[0] = ds_layout_fs_only; |
| 1886 | pl_bad_s0[1] = ds_layout[1]; |
| 1887 | pipeline_layout_ci.setLayoutCount = 2; |
| 1888 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 1889 | VkPipelineLayout pipe_layout_bad_set0; |
| 1890 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipe_layout_bad_set0); |
| 1891 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1892 | |
| 1893 | // Create a buffer to update the descriptor with |
| 1894 | uint32_t qfi = 0; |
| 1895 | VkBufferCreateInfo buffCI = {}; |
| 1896 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1897 | buffCI.size = 1024; |
| 1898 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1899 | buffCI.queueFamilyIndexCount = 1; |
| 1900 | buffCI.pQueueFamilyIndices = &qfi; |
| 1901 | |
| 1902 | VkBuffer dyub; |
| 1903 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 1904 | ASSERT_VK_SUCCESS(err); |
| 1905 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 1906 | static const uint32_t NUM_BUFFS = 5; |
| 1907 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
| 1908 | for (uint32_t i=0; i<NUM_BUFFS; ++i) { |
| 1909 | buffInfo[i].buffer = dyub; |
| 1910 | buffInfo[i].offset = 0; |
| 1911 | buffInfo[i].range = 1024; |
| 1912 | } |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1913 | VkImage image; |
| 1914 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1915 | const int32_t tex_width = 32; |
| 1916 | const int32_t tex_height = 32; |
| 1917 | VkImageCreateInfo image_create_info = {}; |
| 1918 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1919 | image_create_info.pNext = NULL; |
| 1920 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1921 | image_create_info.format = tex_format; |
| 1922 | image_create_info.extent.width = tex_width; |
| 1923 | image_create_info.extent.height = tex_height; |
| 1924 | image_create_info.extent.depth = 1; |
| 1925 | image_create_info.mipLevels = 1; |
| 1926 | image_create_info.arrayLayers = 1; |
| 1927 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1928 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1929 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1930 | image_create_info.flags = 0; |
| 1931 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1932 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1933 | |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1934 | VkImageViewCreateInfo image_view_create_info = {}; |
| 1935 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1936 | image_view_create_info.image = image; |
| 1937 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 1938 | image_view_create_info.format = tex_format; |
| 1939 | image_view_create_info.subresourceRange.layerCount = 1; |
| 1940 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 1941 | image_view_create_info.subresourceRange.levelCount = 1; |
| 1942 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1943 | |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1944 | VkImageView view; |
| 1945 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
| 1946 | ASSERT_VK_SUCCESS(err); |
| 1947 | VkDescriptorImageInfo imageInfo[2] = {}; |
| 1948 | imageInfo[0].imageView = view; |
| 1949 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 1950 | imageInfo[1].imageView = view; |
| 1951 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 1952 | |
| 1953 | static const uint32_t NUM_SET_UPDATES = 3; |
| 1954 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 1955 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1956 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 1957 | descriptor_write[0].dstBinding = 0; |
| 1958 | descriptor_write[0].descriptorCount = 5; |
| 1959 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1960 | descriptor_write[0].pBufferInfo = buffInfo; |
| 1961 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1962 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 1963 | descriptor_write[1].dstBinding = 0; |
| 1964 | descriptor_write[1].descriptorCount = 2; |
| 1965 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 1966 | descriptor_write[1].pImageInfo = imageInfo; |
| 1967 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1968 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 1969 | descriptor_write[2].dstBinding = 1; |
| 1970 | descriptor_write[2].descriptorCount = 2; |
| 1971 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 1972 | descriptor_write[2].pImageInfo = imageInfo; |
| 1973 | |
| 1974 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1975 | |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 1976 | // Create PSO to be used for draw-time errors below |
| 1977 | char const *vsSource = |
| 1978 | "#version 140\n" |
| 1979 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 1980 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 1981 | "\n" |
| 1982 | "void main(){\n" |
| 1983 | " gl_Position = vec4(1);\n" |
| 1984 | "}\n"; |
| 1985 | char const *fsSource = |
| 1986 | "#version 140\n" |
| 1987 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 1988 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 1989 | "\n" |
| 1990 | "layout(location=0) out vec4 x;\n" |
| 1991 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 1992 | "void main(){\n" |
| 1993 | " x = vec4(bar.y);\n" |
| 1994 | "}\n"; |
| 1995 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1996 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1997 | VkPipelineObj pipe(m_device); |
| 1998 | pipe.AddShader(&vs); |
| 1999 | pipe.AddShader(&fs); |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2000 | pipe.AddColorAttachment(); |
| 2001 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2002 | |
| 2003 | BeginCommandBuffer(); |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2004 | |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2005 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2006 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding of PSO |
| 2007 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of cmd_pipeline.c |
| 2008 | // due to the fact that cmd_alloc_dset_data() has not been called in cmd_bind_graphics_pipeline() |
| 2009 | // TODO : Want to cause various binding incompatibility issues here to test DrawState |
| 2010 | // First cause various verify_layout_compatibility() fails |
| 2011 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2012 | // verify_set_layout_compatibility fail cases: |
| 2013 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2014 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " due to: invalid VkPipelineLayout "); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2015 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, (VkPipelineLayout)0xbaadb1be, 0, 1, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2016 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2017 | FAIL() << "Did not receive correct error msg when attempting to bind descriptorSets with invalid VkPipelineLayout."; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2018 | m_errorMonitor->DumpFailureMsgs(); |
| 2019 | } |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2020 | // 2. layoutIndex exceeds # of layouts in layout |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2021 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " attempting to bind set to index 1"); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2022 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2023 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2024 | FAIL() << "Did not receive correct error msg when attempting to bind descriptorSet to index 1 when pipelineLayout only has index 0."; |
| 2025 | m_errorMonitor->DumpFailureMsgs(); |
| 2026 | } |
| 2027 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
| 2028 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 descriptors |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2029 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, ", but corresponding set being bound has 5 descriptors."); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2030 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
| 2031 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2032 | FAIL() << "Did not receive correct error msg when attempting to bind descriptorSet w/ 5 descriptors to pipelineLayout with only 2 descriptors."; |
| 2033 | m_errorMonitor->DumpFailureMsgs(); |
| 2034 | } |
| 2035 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 2036 | // 4. same # of descriptors but mismatch in type |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2037 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " descriptor from pipelineLayout is type 'VK_DESCRIPTOR_TYPE_SAMPLER'"); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2038 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
| 2039 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2040 | FAIL() << "Did not receive correct error msg when attempting to bind UNIFORM_BUFFER descriptorSet to pipelineLayout with overlapping SAMPLER type."; |
| 2041 | m_errorMonitor->DumpFailureMsgs(); |
| 2042 | } |
| 2043 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 2044 | // 5. same # of descriptors but mismatch in stageFlags |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2045 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " descriptor from pipelineLayout has stageFlags "); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2046 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
| 2047 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2048 | FAIL() << "Did not receive correct error msg when attempting to bind UNIFORM_BUFFER descriptorSet with ALL stageFlags to pipelineLayout with FS-only stageFlags."; |
| 2049 | m_errorMonitor->DumpFailureMsgs(); |
| 2050 | } |
| 2051 | // Cause INFO messages due to disturbing previously bound Sets |
| 2052 | // First bind sets 0 & 1 |
| 2053 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2054 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2055 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERF_WARN_BIT_EXT, " previously bound as set #0 was disturbed "); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2056 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 2057 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2058 | FAIL() << "Did not receive correct info msg when binding Set1 w/ pipelineLayout that should disturb Set0."; |
| 2059 | m_errorMonitor->DumpFailureMsgs(); |
| 2060 | } |
| 2061 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
| 2062 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2063 | // 2. Disturb set after last bound set |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2064 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERF_WARN_BIT_EXT, " newly bound as set #0 so set #1 and any subsequent sets were disturbed "); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2065 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
| 2066 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2067 | FAIL() << "Did not receive correct info msg when re-binding Set0 w/ pipelineLayout that should disturb Set1."; |
| 2068 | m_errorMonitor->DumpFailureMsgs(); |
| 2069 | } |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2070 | |
| 2071 | // Cause draw-time errors due to PSO incompatibilities |
| 2072 | // 1. Error due to not binding required set (we actually use same code as above to disturb set0) |
| 2073 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2074 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2075 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " uses set #0 but that set is not bound."); |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2076 | Draw(1, 0, 0, 0); |
| 2077 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2078 | FAIL() << "Did not receive correct error msg when attempting draw requiring Set0 but Set0 is not bound."; |
| 2079 | m_errorMonitor->DumpFailureMsgs(); |
| 2080 | } |
| 2081 | // 2. Error due to bound set not being compatible with PSO's VkPipelineLayout (diff stageFlags in this case) |
| 2082 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, &descriptorSet[0], 0, NULL); |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2083 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " bound as set #0 is not compatible with "); |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2084 | Draw(1, 0, 0, 0); |
| 2085 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2086 | FAIL() << "Did not receive correct error msg when attempted draw where bound Set0 layout is not compatible PSO Set0 layout."; |
| 2087 | m_errorMonitor->DumpFailureMsgs(); |
| 2088 | } |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2089 | // Remaining clean-up |
| 2090 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
| 2091 | for (uint32_t i=0; i<NUM_LAYOUTS; ++i) { |
| 2092 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 2093 | } |
| 2094 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
| 2095 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, descriptorSet); |
| 2096 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2097 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2098 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2099 | } |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2100 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2101 | TEST_F(VkLayerTest, NoBeginCommandBuffer) |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2102 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2103 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2104 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2105 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2106 | |
| 2107 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2108 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2109 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2110 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2111 | |
| 2112 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2113 | FAIL() << "Did not recieve Error 'You must call vkBeginCommandBuffer() before this call to vkEndCommandBuffer()'"; |
| 2114 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2115 | } |
| 2116 | } |
| 2117 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2118 | TEST_F(VkLayerTest, PrimaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2119 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2120 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2121 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2122 | "may not specify framebuffer or renderpass parameters"); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2123 | |
| 2124 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2125 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2126 | // Calls AllocateCommandBuffers |
| 2127 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2128 | |
| 2129 | // Force the failure by setting the Renderpass and Framebuffer fields with (fake) data |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2130 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 2131 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2132 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2133 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2134 | cmd_buf_info.renderPass = (VkRenderPass)0xcadecade; |
| 2135 | cmd_buf_info.framebuffer = (VkFramebuffer)0xcadecade; |
| 2136 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2137 | |
| 2138 | // The error should be caught by validation of the BeginCommandBuffer call |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2139 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2140 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2141 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2142 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Primary Command Buffer may not specify framebuffer or renderpass parameters'"; |
| 2143 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2144 | } |
| 2145 | } |
| 2146 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2147 | TEST_F(VkLayerTest, SecondaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2148 | { |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2149 | VkResult err; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2150 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2151 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2152 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2153 | "must specify framebuffer and renderpass parameters"); |
| 2154 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2155 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2156 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2157 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2158 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2159 | cmd.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2160 | cmd.commandPool = m_commandPool; |
| 2161 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2162 | cmd.bufferCount = 1; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2163 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2164 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2165 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2166 | |
| 2167 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2168 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 2169 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2170 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2171 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2172 | |
| 2173 | // The error should be caught by validation of the BeginCommandBuffer call |
| 2174 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 2175 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2176 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2177 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Secondary Command Buffer must specify framebuffer and renderpass parameters'"; |
| 2178 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2179 | } |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2180 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2181 | } |
| 2182 | |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2183 | TEST_F(VkLayerTest, CommandBufferResetErrors) |
| 2184 | { |
| 2185 | // Cause error due to Begin while recording CB |
| 2186 | // Then cause 2 errors for attempting to reset CB w/o having |
| 2187 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 2188 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2189 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2190 | "Cannot call Begin on CB"); |
| 2191 | |
| 2192 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2193 | |
| 2194 | // Calls AllocateCommandBuffers |
| 2195 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 2196 | |
| 2197 | // Force the failure by setting the Renderpass and Framebuffer fields with (fake) data |
| 2198 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 2199 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2200 | cmd_buf_info.pNext = NULL; |
| 2201 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 2202 | |
| 2203 | // Begin CB to transition to recording state |
| 2204 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2205 | // Can't re-begin. This should trigger error |
| 2206 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2207 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2208 | FAIL() << "Did not receive Error 'Cannot call Begin on CB (0x<ADDR>) in the RECORDING state...'"; |
| 2209 | m_errorMonitor->DumpFailureMsgs(); |
| 2210 | } |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2211 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempt to reset command buffer "); |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2212 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 2213 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 2214 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
| 2215 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2216 | FAIL() << "Did not receive Error 'Attempt to reset command buffer (0x<ADDR>) created from command pool...'"; |
| 2217 | m_errorMonitor->DumpFailureMsgs(); |
| 2218 | } |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2219 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2220 | // Transition CB to RECORDED state |
| 2221 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 2222 | // Now attempting to Begin will implicitly reset, which triggers error |
| 2223 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2224 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2225 | FAIL() << "Did not receive Error 'Call to vkBeginCommandBuffer() on command buffer (0x<ADDR>) attempts to implicitly reset...'"; |
| 2226 | m_errorMonitor->DumpFailureMsgs(); |
| 2227 | } |
| 2228 | } |
| 2229 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2230 | TEST_F(VkLayerTest, InvalidPipelineCreateState) |
| 2231 | { |
| 2232 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2233 | VkResult err; |
| 2234 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2235 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2236 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 2237 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2238 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2239 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2240 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2241 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2242 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2243 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2244 | |
| 2245 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2246 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2247 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2248 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2249 | ds_pool_ci.poolSizeCount = 1; |
| 2250 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2251 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2252 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2253 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2254 | ASSERT_VK_SUCCESS(err); |
| 2255 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2256 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2257 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2258 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2259 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2260 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2261 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2262 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2263 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2264 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2265 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2266 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2267 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2268 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2269 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2270 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2271 | ASSERT_VK_SUCCESS(err); |
| 2272 | |
| 2273 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2274 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2275 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2276 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2277 | alloc_info.descriptorPool = ds_pool; |
| 2278 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2279 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2280 | ASSERT_VK_SUCCESS(err); |
| 2281 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2282 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2283 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2284 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2285 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2286 | |
| 2287 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2288 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2289 | ASSERT_VK_SUCCESS(err); |
| 2290 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2291 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2292 | VkRect2D sc = {}; // dummy scissor to point to |
| 2293 | |
| 2294 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2295 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2296 | vp_state_ci.scissorCount = 1; |
| 2297 | vp_state_ci.pScissors = ≻ |
| 2298 | vp_state_ci.viewportCount = 1; |
| 2299 | vp_state_ci.pViewports = &vp; |
| 2300 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2301 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2302 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2303 | gp_ci.pViewportState = &vp_state_ci; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2304 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2305 | gp_ci.layout = pipeline_layout; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2306 | gp_ci.renderPass = renderPass(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2307 | |
| 2308 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2309 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Chia-I Wu | 7e47070 | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 2310 | pc_ci.initialDataSize = 0; |
| 2311 | pc_ci.pInitialData = 0; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2312 | |
| 2313 | VkPipeline pipeline; |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2314 | VkPipelineCache pipelineCache; |
| 2315 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2316 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2317 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2318 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2319 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2320 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2321 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: Vtx Shader required'"; |
| 2322 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2323 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2324 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2325 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2326 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2327 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2328 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2329 | } |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2330 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 2331 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 2332 | { |
| 2333 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2334 | VkResult err; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2335 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2336 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2337 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive "); |
| 2338 | |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2339 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2340 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2341 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2342 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2343 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2344 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2345 | |
| 2346 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2347 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2348 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2349 | ds_pool_ci.poolSizeCount = 1; |
| 2350 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2351 | |
| 2352 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2353 | err = vkCreateDescriptorPool(m_device->device(), 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] | 2354 | ASSERT_VK_SUCCESS(err); |
| 2355 | |
| 2356 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2357 | dsl_binding.binding = 0; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2358 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2359 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2360 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2361 | dsl_binding.pImmutableSamplers = NULL; |
| 2362 | |
| 2363 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2364 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2365 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2366 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2367 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2368 | |
| 2369 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2370 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2371 | ASSERT_VK_SUCCESS(err); |
| 2372 | |
| 2373 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2374 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2375 | ASSERT_VK_SUCCESS(err); |
| 2376 | |
| 2377 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2378 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2379 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2380 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2381 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2382 | |
| 2383 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2384 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2385 | ASSERT_VK_SUCCESS(err); |
| 2386 | |
| 2387 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 2388 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 2389 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2390 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2391 | // Just using VS txt for Tess shaders as we don't care about functionality |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2392 | VkShaderObj tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 2393 | VkShaderObj te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2394 | |
| 2395 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2396 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2397 | shaderStages[0].shader = vs.handle(); |
| 2398 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2399 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2400 | shaderStages[1].shader = tc.handle(); |
| 2401 | shaderStages[2].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2402 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2403 | shaderStages[2].shader = te.handle(); |
| 2404 | |
| 2405 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
| 2406 | iaCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 99ba2bb | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2407 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2408 | |
| 2409 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 2410 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 2411 | tsCI.patchControlPoints = 0; // This will cause an error |
| 2412 | |
| 2413 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2414 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2415 | gp_ci.pNext = NULL; |
| 2416 | gp_ci.stageCount = 3; |
| 2417 | gp_ci.pStages = shaderStages; |
| 2418 | gp_ci.pVertexInputState = NULL; |
| 2419 | gp_ci.pInputAssemblyState = &iaCI; |
| 2420 | gp_ci.pTessellationState = &tsCI; |
| 2421 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2422 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2423 | gp_ci.pMultisampleState = NULL; |
| 2424 | gp_ci.pDepthStencilState = NULL; |
| 2425 | gp_ci.pColorBlendState = NULL; |
| 2426 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2427 | gp_ci.layout = pipeline_layout; |
| 2428 | gp_ci.renderPass = renderPass(); |
| 2429 | |
| 2430 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2431 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2432 | pc_ci.pNext = NULL; |
| 2433 | pc_ci.initialSize = 0; |
| 2434 | pc_ci.initialData = 0; |
| 2435 | pc_ci.maxSize = 0; |
| 2436 | |
| 2437 | VkPipeline pipeline; |
| 2438 | VkPipelineCache pipelineCache; |
| 2439 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2440 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2441 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2442 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2443 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2444 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2445 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive...'"; |
| 2446 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2447 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2448 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2449 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2450 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2451 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2452 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2453 | } |
| 2454 | */ |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2455 | // Set scissor and viewport counts to different numbers |
| 2456 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) |
| 2457 | { |
| 2458 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2459 | VkResult err; |
| 2460 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2461 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2462 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2463 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2464 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2465 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2466 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2467 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2468 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2469 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2470 | |
| 2471 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2472 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2473 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2474 | ds_pool_ci.poolSizeCount = 1; |
| 2475 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2476 | |
| 2477 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2478 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2479 | ASSERT_VK_SUCCESS(err); |
| 2480 | |
| 2481 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2482 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2483 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2484 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2485 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2486 | |
| 2487 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2488 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2489 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2490 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2491 | |
| 2492 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2493 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2494 | ASSERT_VK_SUCCESS(err); |
| 2495 | |
| 2496 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2497 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2498 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2499 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2500 | alloc_info.descriptorPool = ds_pool; |
| 2501 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2502 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2503 | ASSERT_VK_SUCCESS(err); |
| 2504 | |
| 2505 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2506 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2507 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2508 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2509 | |
| 2510 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2511 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2512 | ASSERT_VK_SUCCESS(err); |
| 2513 | |
| 2514 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2515 | |
| 2516 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2517 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2518 | vp_state_ci.scissorCount = 0; |
| 2519 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2520 | vp_state_ci.pViewports = &vp; |
| 2521 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2522 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2523 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2524 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2525 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2526 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2527 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2528 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2529 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2530 | |
| 2531 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2532 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2533 | gp_ci.stageCount = 2; |
| 2534 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2535 | gp_ci.pViewportState = &vp_state_ci; |
| 2536 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2537 | gp_ci.layout = pipeline_layout; |
| 2538 | gp_ci.renderPass = renderPass(); |
| 2539 | |
| 2540 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2541 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2542 | |
| 2543 | VkPipeline pipeline; |
| 2544 | VkPipelineCache pipelineCache; |
| 2545 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2546 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2547 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2548 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2549 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2550 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2551 | FAIL() << "Did not receive Error 'Gfx Pipeline viewport count (1) must match scissor count (0).'"; |
| 2552 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2553 | } |
| 2554 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2555 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2556 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2557 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2558 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2559 | } |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2560 | // Don't set viewport state in PSO. This is an error b/c we always need this state |
| 2561 | // for the counts even if the data is going to be set dynamically. |
| 2562 | TEST_F(VkLayerTest, PSOViewportStateNotSet) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2563 | { |
| 2564 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2565 | VkResult err; |
| 2566 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2567 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2568 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2569 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2570 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2571 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2572 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2573 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2574 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2575 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2576 | |
| 2577 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2578 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2579 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2580 | ds_pool_ci.poolSizeCount = 1; |
| 2581 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2582 | |
| 2583 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2584 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2585 | ASSERT_VK_SUCCESS(err); |
| 2586 | |
| 2587 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2588 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2589 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2590 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2591 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2592 | |
| 2593 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2594 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2595 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2596 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2597 | |
| 2598 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2599 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2600 | ASSERT_VK_SUCCESS(err); |
| 2601 | |
| 2602 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2603 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2604 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2605 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2606 | alloc_info.descriptorPool = ds_pool; |
| 2607 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2608 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2609 | ASSERT_VK_SUCCESS(err); |
| 2610 | |
| 2611 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2612 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2613 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2614 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2615 | |
| 2616 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2617 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2618 | ASSERT_VK_SUCCESS(err); |
| 2619 | |
| 2620 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2621 | // Set scissor as dynamic to avoid second error |
| 2622 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2623 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2624 | dyn_state_ci.dynamicStateCount = 1; |
| 2625 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2626 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2627 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2628 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2629 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2630 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2631 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2632 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2633 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2634 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2635 | |
| 2636 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2637 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2638 | gp_ci.stageCount = 2; |
| 2639 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2640 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state should cause validation error |
| 2641 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2642 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2643 | gp_ci.layout = pipeline_layout; |
| 2644 | gp_ci.renderPass = renderPass(); |
| 2645 | |
| 2646 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2647 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2648 | |
| 2649 | VkPipeline pipeline; |
| 2650 | VkPipelineCache pipelineCache; |
| 2651 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2652 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2653 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2654 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2655 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2656 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2657 | FAIL() << "Did not receive Error 'Gfx Pipeline pViewportState is null. Even if...'"; |
| 2658 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2659 | } |
| 2660 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2661 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2662 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2663 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2664 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2665 | } |
| 2666 | // Create PSO w/o non-zero viewportCount but no viewport data |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2667 | // Then run second test where dynamic scissor count doesn't match PSO scissor count |
| 2668 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2669 | { |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2670 | VkResult err; |
| 2671 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2672 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2673 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 2674 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2675 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2676 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2677 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2678 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2679 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2680 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2681 | |
| 2682 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2683 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2684 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2685 | ds_pool_ci.poolSizeCount = 1; |
| 2686 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2687 | |
| 2688 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2689 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2690 | ASSERT_VK_SUCCESS(err); |
| 2691 | |
| 2692 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2693 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2694 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2695 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2696 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2697 | |
| 2698 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2699 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2700 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2701 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2702 | |
| 2703 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2704 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2705 | ASSERT_VK_SUCCESS(err); |
| 2706 | |
| 2707 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2708 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2709 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2710 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2711 | alloc_info.descriptorPool = ds_pool; |
| 2712 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2713 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2714 | ASSERT_VK_SUCCESS(err); |
| 2715 | |
| 2716 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2717 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2718 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2719 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2720 | |
| 2721 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2722 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2723 | ASSERT_VK_SUCCESS(err); |
| 2724 | |
| 2725 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2726 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2727 | vp_state_ci.viewportCount = 1; |
| 2728 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2729 | vp_state_ci.scissorCount = 1; |
| 2730 | vp_state_ci.pScissors = NULL; // Scissor is dynamic (below) so this won't cause error |
| 2731 | |
| 2732 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2733 | // Set scissor as dynamic to avoid that error |
| 2734 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2735 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2736 | dyn_state_ci.dynamicStateCount = 1; |
| 2737 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2738 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2739 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2740 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2741 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2742 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2743 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2744 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2745 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2746 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2747 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2748 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2749 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2750 | vi_ci.pNext = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2751 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2752 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2753 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2754 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2755 | |
| 2756 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2757 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2758 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2759 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2760 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2761 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2762 | rs_ci.pNext = nullptr; |
| 2763 | |
| 2764 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2765 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2766 | cb_ci.pNext = nullptr; |
| 2767 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2768 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2769 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2770 | gp_ci.stageCount = 2; |
| 2771 | gp_ci.pStages = shaderStages; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2772 | gp_ci.pVertexInputState = &vi_ci; |
| 2773 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2774 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2775 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2776 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2777 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2778 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2779 | gp_ci.layout = pipeline_layout; |
| 2780 | gp_ci.renderPass = renderPass(); |
| 2781 | |
| 2782 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2783 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2784 | |
| 2785 | VkPipeline pipeline; |
| 2786 | VkPipelineCache pipelineCache; |
| 2787 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2788 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2789 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2790 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2791 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2792 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2793 | FAIL() << "Did not recieve Error 'Gfx Pipeline viewportCount is 1, but pViewports is NULL...'"; |
| 2794 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2795 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2796 | |
| 2797 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2798 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2799 | // First need to successfully create the PSO from above by setting pViewports |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2800 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2801 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1. These counts must match."); |
| 2802 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2803 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2804 | vp_state_ci.pViewports = &vp; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2805 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2806 | ASSERT_VK_SUCCESS(err); |
| 2807 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2808 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2809 | VkRect2D scissors[2] = {}; // don't care about data |
| 2810 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2811 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 2, scissors); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2812 | Draw(1, 0, 0, 0); |
| 2813 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2814 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2815 | FAIL() << "Did not receive Error 'Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1...'"; |
| 2816 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2817 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2818 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2819 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2820 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2821 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2822 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2823 | } |
| 2824 | // Create PSO w/o non-zero scissorCount but no scissor data |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2825 | // Then run second test where dynamic viewportCount doesn't match PSO viewportCount |
| 2826 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2827 | { |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2828 | VkResult err; |
| 2829 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2830 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2831 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 2832 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2833 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2834 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2835 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2836 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2837 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2838 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2839 | |
| 2840 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2841 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2842 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2843 | ds_pool_ci.poolSizeCount = 1; |
| 2844 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2845 | |
| 2846 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2847 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2848 | ASSERT_VK_SUCCESS(err); |
| 2849 | |
| 2850 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2851 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2852 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2853 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2854 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2855 | |
| 2856 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2857 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2858 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2859 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2860 | |
| 2861 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2862 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2863 | ASSERT_VK_SUCCESS(err); |
| 2864 | |
| 2865 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2866 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2867 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2868 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2869 | alloc_info.descriptorPool = ds_pool; |
| 2870 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2871 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2872 | ASSERT_VK_SUCCESS(err); |
| 2873 | |
| 2874 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2875 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2876 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2877 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2878 | |
| 2879 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2880 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2881 | ASSERT_VK_SUCCESS(err); |
| 2882 | |
| 2883 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2884 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2885 | vp_state_ci.scissorCount = 1; |
| 2886 | vp_state_ci.pScissors = NULL; // Null scissor w/ count of 1 should cause error |
| 2887 | vp_state_ci.viewportCount = 1; |
| 2888 | vp_state_ci.pViewports = NULL; // vp is dynamic (below) so this won't cause error |
| 2889 | |
| 2890 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 2891 | // Set scissor as dynamic to avoid that error |
| 2892 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2893 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2894 | dyn_state_ci.dynamicStateCount = 1; |
| 2895 | dyn_state_ci.pDynamicStates = &vp_state; |
| 2896 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2897 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2898 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2899 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2900 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2901 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2902 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2903 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2904 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2905 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2906 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2907 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2908 | vi_ci.pNext = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2909 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2910 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2911 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2912 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2913 | |
| 2914 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2915 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2916 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2917 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2918 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2919 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2920 | rs_ci.pNext = nullptr; |
| 2921 | |
| 2922 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2923 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2924 | cb_ci.pNext = nullptr; |
| 2925 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2926 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2927 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2928 | gp_ci.stageCount = 2; |
| 2929 | gp_ci.pStages = shaderStages; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2930 | gp_ci.pVertexInputState = &vi_ci; |
| 2931 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2932 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2933 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2934 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2935 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2936 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2937 | gp_ci.layout = pipeline_layout; |
| 2938 | gp_ci.renderPass = renderPass(); |
| 2939 | |
| 2940 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2941 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2942 | |
| 2943 | VkPipeline pipeline; |
| 2944 | VkPipelineCache pipelineCache; |
| 2945 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2946 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2947 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2948 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2949 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2950 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2951 | FAIL() << "Did not recieve Error 'Gfx Pipeline scissorCount is 1, but pScissors is NULL...'"; |
| 2952 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2953 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2954 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2955 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2956 | // First need to successfully create the PSO from above by setting pViewports |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2957 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2958 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1. These counts must match."); |
| 2959 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2960 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 2961 | vp_state_ci.pScissors = ≻ |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2962 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2963 | ASSERT_VK_SUCCESS(err); |
| 2964 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2965 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2966 | VkViewport viewports[2] = {}; // don't care about data |
| 2967 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2968 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 2, viewports); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2969 | Draw(1, 0, 0, 0); |
| 2970 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2971 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2972 | FAIL() << "Did not receive Error 'Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1...'"; |
| 2973 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2974 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2975 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2976 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2977 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2978 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2979 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2980 | } |
| 2981 | |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2982 | TEST_F(VkLayerTest, NullRenderPass) |
| 2983 | { |
| 2984 | // Bind a NULL RenderPass |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2985 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2986 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2987 | |
| 2988 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2989 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2990 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2991 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2992 | // Don't care about RenderPass handle b/c error should be flagged before that |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2993 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2994 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2995 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2996 | FAIL() << "Did not receive Error 'You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()'"; |
| 2997 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2998 | } |
| 2999 | } |
| 3000 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3001 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) |
| 3002 | { |
| 3003 | // Bind a BeginRenderPass within an active RenderPass |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3004 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3005 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3006 | |
| 3007 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3008 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3009 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3010 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3011 | // Just create a dummy Renderpass that's non-NULL so we can get to the proper error |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3012 | VkRenderPassBeginInfo rp_begin = {}; |
| 3013 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 3014 | rp_begin.pNext = NULL; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3015 | rp_begin.renderPass = renderPass(); |
| 3016 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3017 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3018 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3019 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3020 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3021 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3022 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3023 | } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3024 | } |
| 3025 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3026 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) |
| 3027 | { |
| 3028 | // Call CmdFillBuffer within an active renderpass |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3029 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3030 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3031 | |
| 3032 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3033 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3034 | |
| 3035 | // Renderpass is started here |
| 3036 | BeginCommandBuffer(); |
| 3037 | |
| 3038 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3039 | vk_testing::Buffer dstBuffer; |
| 3040 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3041 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3042 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3043 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3044 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3045 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3046 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3047 | } |
| 3048 | } |
| 3049 | |
| 3050 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) |
| 3051 | { |
| 3052 | // Call CmdUpdateBuffer within an active renderpass |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3053 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3054 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3055 | |
| 3056 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3057 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3058 | |
| 3059 | // Renderpass is started here |
| 3060 | BeginCommandBuffer(); |
| 3061 | |
| 3062 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3063 | vk_testing::Buffer dstBuffer; |
| 3064 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3065 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3066 | VkDeviceSize dstOffset = 0; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3067 | VkDeviceSize dataSize = 1024; |
| 3068 | const uint32_t *pData = NULL; |
| 3069 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3070 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), dstOffset, dataSize, pData); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3071 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3072 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3073 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3074 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3075 | } |
| 3076 | } |
| 3077 | |
| 3078 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) |
| 3079 | { |
| 3080 | // Call CmdClearColorImage within an active RenderPass |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3081 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3082 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3083 | |
| 3084 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3085 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3086 | |
| 3087 | // Renderpass is started here |
| 3088 | BeginCommandBuffer(); |
| 3089 | |
| 3090 | VkClearColorValue clear_color = {0}; |
| 3091 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 3092 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3093 | const int32_t tex_width = 32; |
| 3094 | const int32_t tex_height = 32; |
| 3095 | VkImageCreateInfo image_create_info = {}; |
| 3096 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3097 | image_create_info.pNext = NULL; |
| 3098 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3099 | image_create_info.format = tex_format; |
| 3100 | image_create_info.extent.width = tex_width; |
| 3101 | image_create_info.extent.height = tex_height; |
| 3102 | image_create_info.extent.depth = 1; |
| 3103 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3104 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3105 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3106 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3107 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3108 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3109 | vk_testing::Image dstImage; |
| 3110 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3111 | |
| 3112 | const VkImageSubresourceRange range = |
| 3113 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 3114 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3115 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), |
| 3116 | dstImage.handle(), |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3117 | VK_IMAGE_LAYOUT_GENERAL, |
| 3118 | &clear_color, |
| 3119 | 1, |
| 3120 | &range); |
| 3121 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3122 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3123 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3124 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3125 | } |
| 3126 | } |
| 3127 | |
| 3128 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) |
| 3129 | { |
| 3130 | // Call CmdClearDepthStencilImage within an active RenderPass |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3131 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3132 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3133 | |
| 3134 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3135 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3136 | |
| 3137 | // Renderpass is started here |
| 3138 | BeginCommandBuffer(); |
| 3139 | |
| 3140 | VkClearDepthStencilValue clear_value = {0}; |
| 3141 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 3142 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 3143 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3144 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3145 | image_create_info.extent.width = 64; |
| 3146 | image_create_info.extent.height = 64; |
| 3147 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3148 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 3149 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3150 | vk_testing::Image dstImage; |
| 3151 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3152 | |
| 3153 | const VkImageSubresourceRange range = |
| 3154 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 3155 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3156 | vkCmdClearDepthStencilImage(m_commandBuffer->GetBufferHandle(), |
| 3157 | dstImage.handle(), |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3158 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, |
| 3159 | &clear_value, |
| 3160 | 1, |
| 3161 | &range); |
| 3162 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3163 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3164 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3165 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3166 | } |
| 3167 | } |
| 3168 | |
| 3169 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) |
| 3170 | { |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3171 | // Call CmdClearAttachmentss outside of an active RenderPass |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3172 | VkResult err; |
| 3173 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3174 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3175 | "vkCmdClearAttachments: This call must be issued inside an active render pass"); |
| 3176 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3177 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3178 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3179 | |
| 3180 | // Start no RenderPass |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3181 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3182 | ASSERT_VK_SUCCESS(err); |
| 3183 | |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3184 | VkClearAttachment color_attachment; |
| 3185 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3186 | color_attachment.clearValue.color.float32[0] = 0; |
| 3187 | color_attachment.clearValue.color.float32[1] = 0; |
| 3188 | color_attachment.clearValue.color.float32[2] = 0; |
| 3189 | color_attachment.clearValue.color.float32[3] = 0; |
| 3190 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3191 | VkClearRect clear_rect = { { { 0, 0 }, { 32, 32 } } }; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3192 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3193 | 1, &color_attachment, |
| 3194 | 1, &clear_rect); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3195 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3196 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3197 | FAIL() << "Did not receive Error 'vkCmdClearAttachments: This call must be issued inside an active render pass.'"; |
| 3198 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3199 | } |
| 3200 | } |
| 3201 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3202 | TEST_F(VkLayerTest, InvalidDynamicStateObject) |
| 3203 | { |
| 3204 | // Create a valid cmd buffer |
| 3205 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3206 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 3207 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3208 | } |
Tobin Ehlis | 201b1ba | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 3209 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3210 | TEST_F(VkLayerTest, IdxBufferAlignmentError) |
| 3211 | { |
| 3212 | // Bind a BeginRenderPass within an active RenderPass |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3213 | VkResult err; |
| 3214 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3215 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3216 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 3217 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3218 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3219 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3220 | uint32_t qfi = 0; |
| 3221 | VkBufferCreateInfo buffCI = {}; |
| 3222 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3223 | buffCI.size = 1024; |
| 3224 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3225 | buffCI.queueFamilyIndexCount = 1; |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3226 | buffCI.pQueueFamilyIndices = &qfi; |
| 3227 | |
| 3228 | VkBuffer ib; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3229 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3230 | ASSERT_VK_SUCCESS(err); |
| 3231 | |
| 3232 | BeginCommandBuffer(); |
| 3233 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3234 | //vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3235 | // Should error before calling to driver so don't care about actual data |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3236 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3237 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3238 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3239 | FAIL() << "Did not receive Error 'vkCmdBindIndexBuffer() offset (0x7) does not fall on ...'"; |
| 3240 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3241 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3242 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3243 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3244 | } |
| 3245 | |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3246 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) |
| 3247 | { |
| 3248 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be secondary) |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3249 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3250 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3251 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3252 | |
| 3253 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3254 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3255 | |
| 3256 | BeginCommandBuffer(); |
| 3257 | //ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3258 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 3259 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3260 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3261 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3262 | FAIL() << "Did not receive Error 'vkCmdExecuteCommands() called w/ Primary Cmd Buffer '"; |
| 3263 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3264 | } |
| 3265 | } |
| 3266 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3267 | TEST_F(VkLayerTest, DSTypeMismatch) |
| 3268 | { |
| 3269 | // Create DS w/ layout of one type and attempt Update w/ mis-matched type |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3270 | VkResult err; |
| 3271 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3272 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3273 | "Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match "); |
| 3274 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3275 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3276 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3277 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3278 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3279 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3280 | |
| 3281 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3282 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3283 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3284 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3285 | ds_pool_ci.poolSizeCount = 1; |
| 3286 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3287 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3288 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3289 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3290 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3291 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3292 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3293 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3294 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3295 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3296 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3297 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3298 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3299 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3300 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3301 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3302 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3303 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3304 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3305 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3306 | ASSERT_VK_SUCCESS(err); |
| 3307 | |
| 3308 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3309 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3310 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3311 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3312 | alloc_info.descriptorPool = ds_pool; |
| 3313 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3314 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3315 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3316 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3317 | VkSamplerCreateInfo sampler_ci = {}; |
| 3318 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3319 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3320 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3321 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3322 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3323 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3324 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3325 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3326 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | 0717ed5 | 2015-12-14 14:59:20 -0700 | [diff] [blame] | 3327 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3328 | sampler_ci.maxAnisotropy = 1; |
| 3329 | sampler_ci.compareEnable = VK_FALSE; |
| 3330 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3331 | sampler_ci.minLod = 1.0; |
| 3332 | sampler_ci.maxLod = 1.0; |
| 3333 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3334 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3335 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3336 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3337 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3338 | ASSERT_VK_SUCCESS(err); |
| 3339 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3340 | VkDescriptorImageInfo info = {}; |
| 3341 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3342 | |
| 3343 | VkWriteDescriptorSet descriptor_write; |
| 3344 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3345 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3346 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3347 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3348 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3349 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3350 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3351 | |
| 3352 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3353 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3354 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3355 | FAIL() << "Did not receive Error 'Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match...'"; |
| 3356 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3357 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3358 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3359 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3360 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3361 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3362 | } |
| 3363 | |
| 3364 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) |
| 3365 | { |
| 3366 | // For overlapping Update, have arrayIndex exceed that of layout |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3367 | VkResult err; |
| 3368 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3369 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3370 | "Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding"); |
| 3371 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3372 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3373 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3374 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3375 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3376 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3377 | |
| 3378 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3379 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3380 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3381 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3382 | ds_pool_ci.poolSizeCount = 1; |
| 3383 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3384 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3385 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3386 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3387 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3388 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3389 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3390 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3391 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3392 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3393 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3394 | dsl_binding.pImmutableSamplers = NULL; |
| 3395 | |
| 3396 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3397 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3398 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3399 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3400 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3401 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3402 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3403 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3404 | ASSERT_VK_SUCCESS(err); |
| 3405 | |
| 3406 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3407 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3408 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3409 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3410 | alloc_info.descriptorPool = ds_pool; |
| 3411 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3412 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3413 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3414 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3415 | VkSamplerCreateInfo sampler_ci = {}; |
| 3416 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3417 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3418 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3419 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3420 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3421 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3422 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3423 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3424 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | 0717ed5 | 2015-12-14 14:59:20 -0700 | [diff] [blame] | 3425 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3426 | sampler_ci.maxAnisotropy = 1; |
| 3427 | sampler_ci.compareEnable = VK_FALSE; |
| 3428 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3429 | sampler_ci.minLod = 1.0; |
| 3430 | sampler_ci.maxLod = 1.0; |
| 3431 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3432 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3433 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3434 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3435 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3436 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3437 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3438 | VkDescriptorImageInfo info = {}; |
| 3439 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3440 | |
| 3441 | VkWriteDescriptorSet descriptor_write; |
| 3442 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3443 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3444 | descriptor_write.dstSet = descriptorSet; |
| 3445 | descriptor_write.dstArrayElement = 1; /* This index out of bounds for the update */ |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3446 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3447 | // 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] | 3448 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3449 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3450 | |
| 3451 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3452 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3453 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3454 | FAIL() << "Did not receive Error 'Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding...'"; |
| 3455 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3456 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3457 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3458 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3459 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3460 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3461 | } |
| 3462 | |
| 3463 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) |
| 3464 | { |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3465 | // Create layout w/ count of 1 and attempt update to that layout w/ binding index 2 |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3466 | VkResult err; |
| 3467 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3468 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3469 | " does not have binding to match update binding "); |
| 3470 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3471 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3472 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3473 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3474 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3475 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3476 | |
| 3477 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3478 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3479 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3480 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3481 | ds_pool_ci.poolSizeCount = 1; |
| 3482 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3483 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3484 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3485 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3486 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3487 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3488 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3489 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3490 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3491 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3492 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3493 | dsl_binding.pImmutableSamplers = NULL; |
| 3494 | |
| 3495 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3496 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3497 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3498 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3499 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3500 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3501 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3502 | ASSERT_VK_SUCCESS(err); |
| 3503 | |
| 3504 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3505 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3506 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3507 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3508 | alloc_info.descriptorPool = ds_pool; |
| 3509 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3510 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3511 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3512 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3513 | VkSamplerCreateInfo sampler_ci = {}; |
| 3514 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3515 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3516 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3517 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3518 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3519 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3520 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3521 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3522 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | 0717ed5 | 2015-12-14 14:59:20 -0700 | [diff] [blame] | 3523 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3524 | sampler_ci.maxAnisotropy = 1; |
| 3525 | sampler_ci.compareEnable = VK_FALSE; |
| 3526 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3527 | sampler_ci.minLod = 1.0; |
| 3528 | sampler_ci.maxLod = 1.0; |
| 3529 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3530 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3531 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3532 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3533 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3534 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3535 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3536 | VkDescriptorImageInfo info = {}; |
| 3537 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3538 | |
| 3539 | VkWriteDescriptorSet descriptor_write; |
| 3540 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3541 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3542 | descriptor_write.dstSet = descriptorSet; |
| 3543 | descriptor_write.dstBinding = 2; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3544 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3545 | // 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] | 3546 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3547 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3548 | |
| 3549 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3550 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3551 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3552 | FAIL() << "Did not receive Error 'Descriptor Set <blah> does not have binding to match update binding '"; |
| 3553 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3554 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3555 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3556 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3557 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3558 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3559 | } |
| 3560 | |
| 3561 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) |
| 3562 | { |
| 3563 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* types |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3564 | VkResult err; |
| 3565 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3566 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3567 | "Unexpected UPDATE struct of type "); |
| 3568 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3569 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3570 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3571 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3572 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3573 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3574 | |
| 3575 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3576 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3577 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3578 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3579 | ds_pool_ci.poolSizeCount = 1; |
| 3580 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3581 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3582 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3583 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3584 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3585 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3586 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3587 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3588 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3589 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3590 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3591 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3592 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3593 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3594 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3595 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3596 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3597 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3598 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3599 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3600 | ASSERT_VK_SUCCESS(err); |
| 3601 | |
| 3602 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3603 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3604 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3605 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3606 | alloc_info.descriptorPool = ds_pool; |
| 3607 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3608 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3609 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3610 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3611 | VkSamplerCreateInfo sampler_ci = {}; |
| 3612 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3613 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3614 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3615 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3616 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3617 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3618 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3619 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3620 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | 0717ed5 | 2015-12-14 14:59:20 -0700 | [diff] [blame] | 3621 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3622 | sampler_ci.maxAnisotropy = 1; |
| 3623 | sampler_ci.compareEnable = VK_FALSE; |
| 3624 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3625 | sampler_ci.minLod = 1.0; |
| 3626 | sampler_ci.maxLod = 1.0; |
| 3627 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3628 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3629 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3630 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3631 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3632 | |
| 3633 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3634 | VkDescriptorImageInfo info = {}; |
| 3635 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3636 | |
| 3637 | VkWriteDescriptorSet descriptor_write; |
| 3638 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3639 | descriptor_write.sType = (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3640 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3641 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3642 | // 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] | 3643 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3644 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3645 | |
| 3646 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3647 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3648 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3649 | FAIL() << "Did not receive Error 'Unexpected UPDATE struct of type '"; |
| 3650 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3651 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3652 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3653 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3654 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3655 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3656 | } |
| 3657 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3658 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) |
| 3659 | { |
| 3660 | // Create a single Sampler descriptor and send it an invalid Sampler |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3661 | VkResult err; |
| 3662 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3663 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3664 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 3665 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3666 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3667 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied code |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3668 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3669 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3670 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3671 | |
| 3672 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3673 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3674 | ds_pool_ci.pNext = NULL; |
| 3675 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3676 | ds_pool_ci.poolSizeCount = 1; |
| 3677 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3678 | |
| 3679 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3680 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3681 | ASSERT_VK_SUCCESS(err); |
| 3682 | |
| 3683 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3684 | dsl_binding.binding = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3685 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3686 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3687 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3688 | dsl_binding.pImmutableSamplers = NULL; |
| 3689 | |
| 3690 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3691 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3692 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3693 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3694 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3695 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3696 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3697 | ASSERT_VK_SUCCESS(err); |
| 3698 | |
| 3699 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3700 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3701 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3702 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3703 | alloc_info.descriptorPool = ds_pool; |
| 3704 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3705 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3706 | ASSERT_VK_SUCCESS(err); |
| 3707 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3708 | VkSampler sampler = (VkSampler) 0xbaadbeef; // Sampler with invalid handle |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3709 | |
| 3710 | VkDescriptorImageInfo descriptor_info; |
| 3711 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3712 | descriptor_info.sampler = sampler; |
| 3713 | |
| 3714 | VkWriteDescriptorSet descriptor_write; |
| 3715 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3716 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3717 | descriptor_write.dstSet = descriptorSet; |
| 3718 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3719 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3720 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3721 | descriptor_write.pImageInfo = &descriptor_info; |
| 3722 | |
| 3723 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3724 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3725 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3726 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid sampler...'"; |
| 3727 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3728 | } |
| 3729 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3730 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3731 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3732 | } |
| 3733 | |
| 3734 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) |
| 3735 | { |
| 3736 | // Create a single combined Image/Sampler descriptor and send it an invalid imageView |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3737 | VkResult err; |
| 3738 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3739 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3740 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 3741 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3742 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3743 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3744 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3745 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3746 | |
| 3747 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3748 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3749 | ds_pool_ci.pNext = NULL; |
| 3750 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3751 | ds_pool_ci.poolSizeCount = 1; |
| 3752 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3753 | |
| 3754 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3755 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3756 | ASSERT_VK_SUCCESS(err); |
| 3757 | |
| 3758 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3759 | dsl_binding.binding = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3760 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3761 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3762 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3763 | dsl_binding.pImmutableSamplers = NULL; |
| 3764 | |
| 3765 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3766 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3767 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3768 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3769 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3770 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3771 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3772 | ASSERT_VK_SUCCESS(err); |
| 3773 | |
| 3774 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3775 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3776 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3777 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3778 | alloc_info.descriptorPool = ds_pool; |
| 3779 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3780 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3781 | ASSERT_VK_SUCCESS(err); |
| 3782 | |
| 3783 | VkSamplerCreateInfo sampler_ci = {}; |
| 3784 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3785 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3786 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3787 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3788 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3789 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3790 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3791 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3792 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | 0717ed5 | 2015-12-14 14:59:20 -0700 | [diff] [blame] | 3793 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3794 | sampler_ci.maxAnisotropy = 1; |
| 3795 | sampler_ci.compareEnable = VK_FALSE; |
| 3796 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3797 | sampler_ci.minLod = 1.0; |
| 3798 | sampler_ci.maxLod = 1.0; |
| 3799 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3800 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3801 | |
| 3802 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3803 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3804 | ASSERT_VK_SUCCESS(err); |
| 3805 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3806 | VkImageView view = (VkImageView) 0xbaadbeef; // invalid imageView object |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3807 | |
| 3808 | VkDescriptorImageInfo descriptor_info; |
| 3809 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3810 | descriptor_info.sampler = sampler; |
| 3811 | descriptor_info.imageView = view; |
| 3812 | |
| 3813 | VkWriteDescriptorSet descriptor_write; |
| 3814 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3815 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3816 | descriptor_write.dstSet = descriptorSet; |
| 3817 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3818 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3819 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3820 | descriptor_write.pImageInfo = &descriptor_info; |
| 3821 | |
| 3822 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3823 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3824 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3825 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid imageView...'"; |
| 3826 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3827 | } |
| 3828 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3829 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3830 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3831 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3832 | } |
| 3833 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3834 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) |
| 3835 | { |
| 3836 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update into the other |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3837 | VkResult err; |
| 3838 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3839 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3840 | "Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER "); |
| 3841 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3842 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3843 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3844 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3845 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3846 | ds_type_count[0].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3847 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3848 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3849 | |
| 3850 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3851 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3852 | ds_pool_ci.pNext = NULL; |
| 3853 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3854 | ds_pool_ci.poolSizeCount = 2; |
| 3855 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3856 | |
| 3857 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3858 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3859 | ASSERT_VK_SUCCESS(err); |
| 3860 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3861 | dsl_binding[0].binding = 0; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3862 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3863 | dsl_binding[0].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3864 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3865 | dsl_binding[0].pImmutableSamplers = NULL; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3866 | dsl_binding[1].binding = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3867 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3868 | dsl_binding[1].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3869 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3870 | dsl_binding[1].pImmutableSamplers = NULL; |
| 3871 | |
| 3872 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3873 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3874 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3875 | ds_layout_ci.bindingCount = 2; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3876 | ds_layout_ci.pBinding = dsl_binding; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3877 | |
| 3878 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3879 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3880 | ASSERT_VK_SUCCESS(err); |
| 3881 | |
| 3882 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3883 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3884 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3885 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3886 | alloc_info.descriptorPool = ds_pool; |
| 3887 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3888 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3889 | ASSERT_VK_SUCCESS(err); |
| 3890 | |
| 3891 | VkSamplerCreateInfo sampler_ci = {}; |
| 3892 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3893 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3894 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3895 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3896 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3897 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3898 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3899 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3900 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | 0717ed5 | 2015-12-14 14:59:20 -0700 | [diff] [blame] | 3901 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3902 | sampler_ci.maxAnisotropy = 1; |
| 3903 | sampler_ci.compareEnable = VK_FALSE; |
| 3904 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3905 | sampler_ci.minLod = 1.0; |
| 3906 | sampler_ci.maxLod = 1.0; |
| 3907 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3908 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3909 | |
| 3910 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3911 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3912 | ASSERT_VK_SUCCESS(err); |
| 3913 | |
| 3914 | VkDescriptorImageInfo info = {}; |
| 3915 | info.sampler = sampler; |
| 3916 | |
| 3917 | VkWriteDescriptorSet descriptor_write; |
| 3918 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 3919 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3920 | descriptor_write.dstSet = descriptorSet; |
| 3921 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3922 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3923 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3924 | descriptor_write.pImageInfo = &info; |
| 3925 | // This write update should succeed |
| 3926 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3927 | // Now perform a copy update that fails due to type mismatch |
| 3928 | VkCopyDescriptorSet copy_ds_update; |
| 3929 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3930 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3931 | copy_ds_update.srcSet = descriptorSet; |
| 3932 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3933 | copy_ds_update.dstSet = descriptorSet; |
| 3934 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3935 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3936 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3937 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3938 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3939 | FAIL() << "Did not receive Error 'Copy descriptor update index 0, update count #1, has src update descriptor type_DESCRIPTOR_TYPE_SAMPLER'"; |
| 3940 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3941 | } |
| 3942 | // Now perform a copy update that fails due to binding out of bounds |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3943 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3944 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3945 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3946 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3947 | copy_ds_update.srcSet = descriptorSet; |
| 3948 | copy_ds_update.srcBinding = 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3949 | copy_ds_update.dstSet = descriptorSet; |
| 3950 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3951 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3952 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3953 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3954 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3955 | FAIL() << "Did not receive Error 'Copy descriptor update 0 has srcBinding 3 which is out of bounds...'"; |
| 3956 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3957 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3958 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3959 | // Now perform a copy update that fails due to binding out of bounds |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3960 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3961 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 3962 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3963 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3964 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3965 | copy_ds_update.srcSet = descriptorSet; |
| 3966 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3967 | copy_ds_update.dstSet = descriptorSet; |
| 3968 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3969 | copy_ds_update.descriptorCount = 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3970 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3971 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3972 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3973 | FAIL() << "Did not receive Error 'Copy descriptor src update is out of bounds for matching binding 1...'"; |
| 3974 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3975 | } |
| 3976 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3977 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3978 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3979 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3980 | } |
| 3981 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3982 | TEST_F(VkLayerTest, NumSamplesMismatch) |
| 3983 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3984 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3985 | VkResult err; |
| 3986 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3987 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3988 | "Num samples mismatch! "); |
| 3989 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3990 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3991 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3992 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3993 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3994 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3995 | |
| 3996 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3997 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3998 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3999 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4000 | ds_pool_ci.poolSizeCount = 1; |
| 4001 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4002 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4003 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4004 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4005 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4006 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4007 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4008 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4009 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4010 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4011 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4012 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4013 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4014 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4015 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4016 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4017 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4018 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4019 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4020 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4021 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4022 | ASSERT_VK_SUCCESS(err); |
| 4023 | |
| 4024 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4025 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4026 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4027 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4028 | alloc_info.descriptorPool = ds_pool; |
| 4029 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4030 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4031 | ASSERT_VK_SUCCESS(err); |
| 4032 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4033 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4034 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4035 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4036 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4037 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4038 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 4039 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4040 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4041 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4042 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4043 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4044 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4045 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4046 | |
| 4047 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4048 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4049 | ASSERT_VK_SUCCESS(err); |
| 4050 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4051 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4052 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4053 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4054 | VkPipelineObj pipe(m_device); |
| 4055 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4056 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4057 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4058 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4059 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4060 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4061 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4062 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4063 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4064 | FAIL() << "Did not recieve Error 'Num samples mismatch!...'"; |
| 4065 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4066 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4067 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4068 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4069 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4070 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4071 | } |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4072 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4073 | TEST_F(VkLayerTest, ClearCmdNoDraw) |
| 4074 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4075 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior to issuing a Draw |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4076 | VkResult err; |
| 4077 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4078 | // TODO: verify that this matches layer |
| 4079 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARN_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4080 | "vkCmdClearAttachments() issued on CB object "); |
| 4081 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4082 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4083 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4084 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4085 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4086 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4087 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4088 | |
| 4089 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4090 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4091 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4092 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4093 | ds_pool_ci.poolSizeCount = 1; |
| 4094 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4095 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4096 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4097 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4098 | ASSERT_VK_SUCCESS(err); |
| 4099 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4100 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4101 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4102 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4103 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4104 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4105 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4106 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4107 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4108 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4109 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4110 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4111 | ds_layout_ci.pBinding = &dsl_binding; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4112 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4113 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4114 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4115 | ASSERT_VK_SUCCESS(err); |
| 4116 | |
| 4117 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4118 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4119 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4120 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4121 | alloc_info.descriptorPool = ds_pool; |
| 4122 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4123 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4124 | ASSERT_VK_SUCCESS(err); |
| 4125 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4126 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4127 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4128 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4129 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4130 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4131 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 4132 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4133 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4134 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4135 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4136 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4137 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4138 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4139 | |
| 4140 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4141 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4142 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4143 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4144 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4145 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 4146 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4147 | |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4148 | VkPipelineObj pipe(m_device); |
| 4149 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4150 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4151 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4152 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4153 | |
| 4154 | BeginCommandBuffer(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4155 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4156 | // Main thing we care about for this test is that the VkImage obj we're clearing matches Color Attachment of FB |
| 4157 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4158 | VkClearAttachment color_attachment; |
| 4159 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4160 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 4161 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 4162 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 4163 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 4164 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4165 | VkClearRect clear_rect = { { { 0, 0 }, { (int)m_width, (int)m_height } } }; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4166 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4167 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4168 | |
| 4169 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4170 | FAIL() << "Did not receive Error 'vkCommandClearAttachments() issued on CB object...'"; |
| 4171 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4172 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4173 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4174 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4175 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4176 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4177 | } |
| 4178 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4179 | TEST_F(VkLayerTest, VtxBufferBadIndex) |
| 4180 | { |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4181 | VkResult err; |
| 4182 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4183 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERF_WARN_BIT_EXT, |
Mark Lobodzinski | 74e8469 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 4184 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4185 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4186 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4187 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4188 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4189 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4190 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4191 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4192 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4193 | |
| 4194 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4195 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4196 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4197 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4198 | ds_pool_ci.poolSizeCount = 1; |
| 4199 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4200 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4201 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4202 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4203 | ASSERT_VK_SUCCESS(err); |
| 4204 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4205 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4206 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4207 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4208 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4209 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4210 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4211 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4212 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4213 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4214 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4215 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4216 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4217 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4218 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4219 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4220 | ASSERT_VK_SUCCESS(err); |
| 4221 | |
| 4222 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4223 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4224 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4225 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4226 | alloc_info.descriptorPool = ds_pool; |
| 4227 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4228 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4229 | ASSERT_VK_SUCCESS(err); |
| 4230 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4231 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4232 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4233 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4234 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4235 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4236 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 4237 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4238 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4239 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4240 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4241 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4242 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4243 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4244 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4245 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4246 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4247 | ASSERT_VK_SUCCESS(err); |
| 4248 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4249 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4250 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4251 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4252 | VkPipelineObj pipe(m_device); |
| 4253 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4254 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4255 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4256 | pipe.SetViewport(m_viewports); |
| 4257 | pipe.SetScissor(m_scissors); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4258 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4259 | |
| 4260 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4261 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | d28acef | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4262 | // Don't care about actual data, just need to get to draw to flag error |
| 4263 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
| 4264 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data); |
| 4265 | 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] | 4266 | Draw(1, 0, 0, 0); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4267 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4268 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4269 | FAIL() << "Did not receive Error 'Vtx Buffer Index 0 was bound, but no vtx buffers are attached to PSO.'"; |
| 4270 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4271 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4272 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4273 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4274 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4275 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4276 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4277 | #endif // DRAW_STATE_TESTS |
| 4278 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 4279 | #if THREADING_TESTS |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4280 | #if GTEST_IS_THREADSAFE |
| 4281 | struct thread_data_struct { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4282 | VkCommandBuffer commandBuffer; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4283 | VkEvent event; |
| 4284 | bool bailout; |
| 4285 | }; |
| 4286 | |
| 4287 | extern "C" void *AddToCommandBuffer(void *arg) |
| 4288 | { |
| 4289 | struct thread_data_struct *data = (struct thread_data_struct *) arg; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4290 | |
| 4291 | for (int i = 0; i<10000; i++) { |
Chia-I Wu | cba6cea | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4292 | vkCmdSetEvent(data->commandBuffer, data->event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4293 | if (data->bailout) { |
| 4294 | break; |
| 4295 | } |
| 4296 | } |
| 4297 | return NULL; |
| 4298 | } |
| 4299 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4300 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4301 | { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4302 | test_platform_thread thread; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4303 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4304 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "THREADING ERROR"); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4305 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4306 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4307 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4308 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4309 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4310 | // Calls AllocateCommandBuffers |
| 4311 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4312 | |
| 4313 | // Avoid creating RenderPass |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4314 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4315 | |
| 4316 | VkEventCreateInfo event_info; |
| 4317 | VkEvent event; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4318 | VkResult err; |
| 4319 | |
| 4320 | memset(&event_info, 0, sizeof(event_info)); |
| 4321 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 4322 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4323 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4324 | ASSERT_VK_SUCCESS(err); |
| 4325 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4326 | err = vkResetEvent(device(), event); |
| 4327 | ASSERT_VK_SUCCESS(err); |
| 4328 | |
| 4329 | struct thread_data_struct data; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4330 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4331 | data.event = event; |
| 4332 | data.bailout = false; |
| 4333 | m_errorMonitor->SetBailout(&data.bailout); |
| 4334 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4335 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4336 | // Add many entries to command buffer from this thread at the same time. |
| 4337 | AddToCommandBuffer(&data); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4338 | |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4339 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4340 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4341 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4342 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4343 | FAIL() << "Did not receive Error 'THREADING ERROR' from using one VkCommandBufferObj in two threads"; |
| 4344 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4345 | } |
| 4346 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4347 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4348 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4349 | #endif // GTEST_IS_THREADSAFE |
| 4350 | #endif // THREADING_TESTS |
| 4351 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4352 | #if SHADER_CHECKER_TESTS |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4353 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) |
| 4354 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4355 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4356 | "Shader is not SPIR-V"); |
| 4357 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4358 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4359 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4360 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4361 | VkShaderModule module; |
| 4362 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4363 | struct icd_spv_header spv; |
| 4364 | |
| 4365 | spv.magic = ICD_SPV_MAGIC; |
| 4366 | spv.version = ICD_SPV_VERSION; |
| 4367 | spv.gen_magic = 0; |
| 4368 | |
| 4369 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4370 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4371 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4372 | moduleCreateInfo.codeSize = 4; |
| 4373 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4374 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4375 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4376 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4377 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4378 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4379 | } |
| 4380 | } |
| 4381 | |
| 4382 | TEST_F(VkLayerTest, InvalidSPIRVMagic) |
| 4383 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4384 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4385 | "Shader is not SPIR-V"); |
| 4386 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4387 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4388 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4389 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4390 | VkShaderModule module; |
| 4391 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4392 | struct icd_spv_header spv; |
| 4393 | |
| 4394 | spv.magic = ~ICD_SPV_MAGIC; |
| 4395 | spv.version = ICD_SPV_VERSION; |
| 4396 | spv.gen_magic = 0; |
| 4397 | |
| 4398 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4399 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4400 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4401 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4402 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4403 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4404 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4405 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4406 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4407 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4408 | } |
| 4409 | } |
| 4410 | |
| 4411 | TEST_F(VkLayerTest, InvalidSPIRVVersion) |
| 4412 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4413 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4414 | "Shader is not SPIR-V"); |
| 4415 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4416 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4417 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4418 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4419 | VkShaderModule module; |
| 4420 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4421 | struct icd_spv_header spv; |
| 4422 | |
| 4423 | spv.magic = ICD_SPV_MAGIC; |
| 4424 | spv.version = ~ICD_SPV_VERSION; |
| 4425 | spv.gen_magic = 0; |
| 4426 | |
| 4427 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4428 | moduleCreateInfo.pNext = NULL; |
| 4429 | |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4430 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4431 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4432 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4433 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4434 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4435 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4436 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4437 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4438 | } |
| 4439 | } |
| 4440 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4441 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) |
| 4442 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4443 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERF_WARN_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4444 | "not consumed by fragment shader"); |
| 4445 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4446 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4447 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4448 | |
| 4449 | char const *vsSource = |
| 4450 | "#version 140\n" |
| 4451 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4452 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4453 | "\n" |
| 4454 | "layout(location=0) out float x;\n" |
| 4455 | "void main(){\n" |
| 4456 | " gl_Position = vec4(1);\n" |
| 4457 | " x = 0;\n" |
| 4458 | "}\n"; |
| 4459 | char const *fsSource = |
| 4460 | "#version 140\n" |
| 4461 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4462 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4463 | "\n" |
| 4464 | "layout(location=0) out vec4 color;\n" |
| 4465 | "void main(){\n" |
| 4466 | " color = vec4(1);\n" |
| 4467 | "}\n"; |
| 4468 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4469 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4470 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4471 | |
| 4472 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4473 | pipe.AddColorAttachment(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4474 | pipe.AddShader(&vs); |
| 4475 | pipe.AddShader(&fs); |
| 4476 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4477 | VkDescriptorSetObj descriptorSet(m_device); |
| 4478 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4479 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4480 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4481 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4482 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4483 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4484 | FAIL() << "Did not receive Warning 'not consumed by fragment shader'"; |
| 4485 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4486 | } |
| 4487 | } |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4488 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4489 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) |
| 4490 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4491 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4492 | "not written by vertex shader"); |
| 4493 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4494 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4495 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4496 | |
| 4497 | char const *vsSource = |
| 4498 | "#version 140\n" |
| 4499 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4500 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4501 | "\n" |
| 4502 | "void main(){\n" |
| 4503 | " gl_Position = vec4(1);\n" |
| 4504 | "}\n"; |
| 4505 | char const *fsSource = |
| 4506 | "#version 140\n" |
| 4507 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4508 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4509 | "\n" |
| 4510 | "layout(location=0) in float x;\n" |
| 4511 | "layout(location=0) out vec4 color;\n" |
| 4512 | "void main(){\n" |
| 4513 | " color = vec4(x);\n" |
| 4514 | "}\n"; |
| 4515 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4516 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4517 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4518 | |
| 4519 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4520 | pipe.AddColorAttachment(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4521 | pipe.AddShader(&vs); |
| 4522 | pipe.AddShader(&fs); |
| 4523 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4524 | VkDescriptorSetObj descriptorSet(m_device); |
| 4525 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4526 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4527 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4528 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4529 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4530 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4531 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 4532 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4533 | } |
| 4534 | } |
| 4535 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4536 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) |
| 4537 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4538 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4539 | "Type mismatch on location 0"); |
| 4540 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4541 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4542 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4543 | |
| 4544 | char const *vsSource = |
| 4545 | "#version 140\n" |
| 4546 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4547 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4548 | "\n" |
| 4549 | "layout(location=0) out int x;\n" |
| 4550 | "void main(){\n" |
| 4551 | " x = 0;\n" |
| 4552 | " gl_Position = vec4(1);\n" |
| 4553 | "}\n"; |
| 4554 | char const *fsSource = |
| 4555 | "#version 140\n" |
| 4556 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4557 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4558 | "\n" |
| 4559 | "layout(location=0) in float x;\n" /* VS writes int */ |
| 4560 | "layout(location=0) out vec4 color;\n" |
| 4561 | "void main(){\n" |
| 4562 | " color = vec4(x);\n" |
| 4563 | "}\n"; |
| 4564 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4565 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4566 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4567 | |
| 4568 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4569 | pipe.AddColorAttachment(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4570 | pipe.AddShader(&vs); |
| 4571 | pipe.AddShader(&fs); |
| 4572 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4573 | VkDescriptorSetObj descriptorSet(m_device); |
| 4574 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4575 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4576 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4577 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4578 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4579 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4580 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 4581 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4582 | } |
| 4583 | } |
| 4584 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4585 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) |
| 4586 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4587 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERF_WARN_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4588 | "location 0 not consumed by VS"); |
| 4589 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4590 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4591 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4592 | |
| 4593 | VkVertexInputBindingDescription input_binding; |
| 4594 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4595 | |
| 4596 | VkVertexInputAttributeDescription input_attrib; |
| 4597 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4598 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4599 | |
| 4600 | char const *vsSource = |
| 4601 | "#version 140\n" |
| 4602 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4603 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4604 | "\n" |
| 4605 | "void main(){\n" |
| 4606 | " gl_Position = vec4(1);\n" |
| 4607 | "}\n"; |
| 4608 | char const *fsSource = |
| 4609 | "#version 140\n" |
| 4610 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4611 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4612 | "\n" |
| 4613 | "layout(location=0) out vec4 color;\n" |
| 4614 | "void main(){\n" |
| 4615 | " color = vec4(1);\n" |
| 4616 | "}\n"; |
| 4617 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4618 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4619 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4620 | |
| 4621 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4622 | pipe.AddColorAttachment(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4623 | pipe.AddShader(&vs); |
| 4624 | pipe.AddShader(&fs); |
| 4625 | |
| 4626 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4627 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4628 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4629 | VkDescriptorSetObj descriptorSet(m_device); |
| 4630 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4631 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4632 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4633 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4634 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4635 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4636 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 4637 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4638 | } |
| 4639 | } |
| 4640 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4641 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) |
| 4642 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4643 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4644 | "VS consumes input at location 0 but not provided"); |
| 4645 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4646 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4647 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4648 | |
| 4649 | char const *vsSource = |
| 4650 | "#version 140\n" |
| 4651 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4652 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4653 | "\n" |
| 4654 | "layout(location=0) in vec4 x;\n" /* not provided */ |
| 4655 | "void main(){\n" |
| 4656 | " gl_Position = x;\n" |
| 4657 | "}\n"; |
| 4658 | char const *fsSource = |
| 4659 | "#version 140\n" |
| 4660 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4661 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4662 | "\n" |
| 4663 | "layout(location=0) out vec4 color;\n" |
| 4664 | "void main(){\n" |
| 4665 | " color = vec4(1);\n" |
| 4666 | "}\n"; |
| 4667 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4668 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4669 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4670 | |
| 4671 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4672 | pipe.AddColorAttachment(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4673 | pipe.AddShader(&vs); |
| 4674 | pipe.AddShader(&fs); |
| 4675 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4676 | VkDescriptorSetObj descriptorSet(m_device); |
| 4677 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4678 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4679 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4680 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4681 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4682 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4683 | FAIL() << "Did not receive Error 'VS consumes input at location 0 but not provided'"; |
| 4684 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4685 | } |
| 4686 | } |
| 4687 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4688 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) |
| 4689 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4690 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4691 | "location 0 does not match VS input type"); |
| 4692 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4693 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4694 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4695 | |
| 4696 | VkVertexInputBindingDescription input_binding; |
| 4697 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4698 | |
| 4699 | VkVertexInputAttributeDescription input_attrib; |
| 4700 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4701 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4702 | |
| 4703 | char const *vsSource = |
| 4704 | "#version 140\n" |
| 4705 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4706 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4707 | "\n" |
| 4708 | "layout(location=0) in int x;\n" /* attrib provided float */ |
| 4709 | "void main(){\n" |
| 4710 | " gl_Position = vec4(x);\n" |
| 4711 | "}\n"; |
| 4712 | char const *fsSource = |
| 4713 | "#version 140\n" |
| 4714 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4715 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4716 | "\n" |
| 4717 | "layout(location=0) out vec4 color;\n" |
| 4718 | "void main(){\n" |
| 4719 | " color = vec4(1);\n" |
| 4720 | "}\n"; |
| 4721 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4722 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4723 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4724 | |
| 4725 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4726 | pipe.AddColorAttachment(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4727 | pipe.AddShader(&vs); |
| 4728 | pipe.AddShader(&fs); |
| 4729 | |
| 4730 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4731 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4732 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4733 | VkDescriptorSetObj descriptorSet(m_device); |
| 4734 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4735 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4736 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4737 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4738 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4739 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4740 | FAIL() << "Did not receive Error 'location 0 does not match VS input type'"; |
| 4741 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4742 | } |
| 4743 | } |
| 4744 | |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 4745 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) |
| 4746 | { |
| 4747 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 4748 | |
| 4749 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4750 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4751 | |
| 4752 | VkVertexInputBindingDescription input_binding; |
| 4753 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4754 | |
| 4755 | VkVertexInputAttributeDescription input_attribs[2]; |
| 4756 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 4757 | |
| 4758 | for (int i = 0; i < 2; i++) { |
| 4759 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 4760 | input_attribs[i].location = i; |
| 4761 | } |
| 4762 | |
| 4763 | char const *vsSource = |
| 4764 | "#version 140\n" |
| 4765 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4766 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4767 | "\n" |
| 4768 | "layout(location=0) in mat2x4 x;\n" |
| 4769 | "void main(){\n" |
| 4770 | " gl_Position = x[0] + x[1];\n" |
| 4771 | "}\n"; |
| 4772 | char const *fsSource = |
| 4773 | "#version 140\n" |
| 4774 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4775 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4776 | "\n" |
| 4777 | "layout(location=0) out vec4 color;\n" |
| 4778 | "void main(){\n" |
| 4779 | " color = vec4(1);\n" |
| 4780 | "}\n"; |
| 4781 | |
| 4782 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4783 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4784 | |
| 4785 | VkPipelineObj pipe(m_device); |
| 4786 | pipe.AddColorAttachment(); |
| 4787 | pipe.AddShader(&vs); |
| 4788 | pipe.AddShader(&fs); |
| 4789 | |
| 4790 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4791 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 4792 | |
| 4793 | VkDescriptorSetObj descriptorSet(m_device); |
| 4794 | descriptorSet.AppendDummy(); |
| 4795 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 4796 | |
| 4797 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4798 | |
| 4799 | /* expect success */ |
| 4800 | if (m_errorMonitor->DesiredMsgFound()) { |
| 4801 | FAIL() << "Expected to succeed but: " << m_errorMonitor->GetFailureMsg(); |
| 4802 | m_errorMonitor->DumpFailureMsgs(); |
| 4803 | } |
| 4804 | } |
| 4805 | |
| 4806 | /* |
| 4807 | * Would work, but not supported by glslang! This is similar to the matrix case above. |
| 4808 | * |
| 4809 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 4810 | { |
| 4811 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 4812 | |
| 4813 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4814 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4815 | |
| 4816 | VkVertexInputBindingDescription input_binding; |
| 4817 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4818 | |
| 4819 | VkVertexInputAttributeDescription input_attribs[2]; |
| 4820 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 4821 | |
| 4822 | for (int i = 0; i < 2; i++) { |
| 4823 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 4824 | input_attribs[i].location = i; |
| 4825 | } |
| 4826 | |
| 4827 | char const *vsSource = |
| 4828 | "#version 140\n" |
| 4829 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4830 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4831 | "\n" |
| 4832 | "layout(location=0) in vec4 x[2];\n" |
| 4833 | "void main(){\n" |
| 4834 | " gl_Position = x[0] + x[1];\n" |
| 4835 | "}\n"; |
| 4836 | char const *fsSource = |
| 4837 | "#version 140\n" |
| 4838 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4839 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4840 | "\n" |
| 4841 | "layout(location=0) out vec4 color;\n" |
| 4842 | "void main(){\n" |
| 4843 | " color = vec4(1);\n" |
| 4844 | "}\n"; |
| 4845 | |
| 4846 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4847 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4848 | |
| 4849 | VkPipelineObj pipe(m_device); |
| 4850 | pipe.AddColorAttachment(); |
| 4851 | pipe.AddShader(&vs); |
| 4852 | pipe.AddShader(&fs); |
| 4853 | |
| 4854 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4855 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 4856 | |
| 4857 | VkDescriptorSetObj descriptorSet(m_device); |
| 4858 | descriptorSet.AppendDummy(); |
| 4859 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 4860 | |
| 4861 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4862 | |
| 4863 | if (m_errorMonitor->DesiredMsgFound()) { |
| 4864 | FAIL() << "Expected to succeed but: " << m_errorMonitor->GetFailureMsg(); |
| 4865 | m_errorMonitor->DumpFailureMsgs(); |
| 4866 | } |
| 4867 | } |
| 4868 | */ |
| 4869 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4870 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) |
| 4871 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4872 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4873 | "Duplicate vertex input binding descriptions for binding 0"); |
| 4874 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4875 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4876 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4877 | |
| 4878 | /* Two binding descriptions for binding 0 */ |
| 4879 | VkVertexInputBindingDescription input_bindings[2]; |
| 4880 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 4881 | |
| 4882 | VkVertexInputAttributeDescription input_attrib; |
| 4883 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4884 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4885 | |
| 4886 | char const *vsSource = |
| 4887 | "#version 140\n" |
| 4888 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4889 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4890 | "\n" |
| 4891 | "layout(location=0) in float x;\n" /* attrib provided float */ |
| 4892 | "void main(){\n" |
| 4893 | " gl_Position = vec4(x);\n" |
| 4894 | "}\n"; |
| 4895 | char const *fsSource = |
| 4896 | "#version 140\n" |
| 4897 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4898 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4899 | "\n" |
| 4900 | "layout(location=0) out vec4 color;\n" |
| 4901 | "void main(){\n" |
| 4902 | " color = vec4(1);\n" |
| 4903 | "}\n"; |
| 4904 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4905 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4906 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4907 | |
| 4908 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4909 | pipe.AddColorAttachment(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4910 | pipe.AddShader(&vs); |
| 4911 | pipe.AddShader(&fs); |
| 4912 | |
| 4913 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 4914 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4915 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4916 | VkDescriptorSetObj descriptorSet(m_device); |
| 4917 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4918 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4919 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4920 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4921 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4922 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4923 | FAIL() << "Did not receive Error 'Duplicate vertex input binding descriptions for binding 0'"; |
| 4924 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4925 | } |
| 4926 | } |
Chris Forbes | 4c94870 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 4927 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4928 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) |
| 4929 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4930 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4931 | "Attachment 0 not written by FS"); |
| 4932 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4933 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4934 | |
| 4935 | char const *vsSource = |
| 4936 | "#version 140\n" |
| 4937 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4938 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4939 | "\n" |
| 4940 | "void main(){\n" |
| 4941 | " gl_Position = vec4(1);\n" |
| 4942 | "}\n"; |
| 4943 | char const *fsSource = |
| 4944 | "#version 140\n" |
| 4945 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4946 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4947 | "\n" |
| 4948 | "void main(){\n" |
| 4949 | "}\n"; |
| 4950 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4951 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4952 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4953 | |
| 4954 | VkPipelineObj pipe(m_device); |
| 4955 | pipe.AddShader(&vs); |
| 4956 | pipe.AddShader(&fs); |
| 4957 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4958 | /* set up CB 0, not written */ |
| 4959 | pipe.AddColorAttachment(); |
| 4960 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4961 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4962 | VkDescriptorSetObj descriptorSet(m_device); |
| 4963 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4964 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4965 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4966 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4967 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4968 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4969 | FAIL() << "Did not receive Error 'Attachment 0 not written by FS'"; |
| 4970 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4971 | } |
| 4972 | } |
| 4973 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4974 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) |
| 4975 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4976 | // TODO: verify that this matches layer |
| 4977 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARN_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4978 | "FS writes to output location 1 with no matching attachment"); |
| 4979 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4980 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4981 | |
| 4982 | char const *vsSource = |
| 4983 | "#version 140\n" |
| 4984 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4985 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4986 | "\n" |
| 4987 | "void main(){\n" |
| 4988 | " gl_Position = vec4(1);\n" |
| 4989 | "}\n"; |
| 4990 | char const *fsSource = |
| 4991 | "#version 140\n" |
| 4992 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4993 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4994 | "\n" |
| 4995 | "layout(location=0) out vec4 x;\n" |
| 4996 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
| 4997 | "void main(){\n" |
| 4998 | " x = vec4(1);\n" |
| 4999 | " y = vec4(1);\n" |
| 5000 | "}\n"; |
| 5001 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5002 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5003 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5004 | |
| 5005 | VkPipelineObj pipe(m_device); |
| 5006 | pipe.AddShader(&vs); |
| 5007 | pipe.AddShader(&fs); |
| 5008 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5009 | /* set up CB 0, not written */ |
| 5010 | pipe.AddColorAttachment(); |
| 5011 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5012 | /* FS writes CB 1, but we don't configure it */ |
| 5013 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5014 | VkDescriptorSetObj descriptorSet(m_device); |
| 5015 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5016 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5017 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5018 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5019 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5020 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5021 | FAIL() << "Did not receive Error 'FS writes to output location 1 with no matching attachment'"; |
| 5022 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5023 | } |
| 5024 | } |
| 5025 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5026 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) |
| 5027 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5028 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5029 | "does not match FS output type"); |
| 5030 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5031 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5032 | |
| 5033 | char const *vsSource = |
| 5034 | "#version 140\n" |
| 5035 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5036 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5037 | "\n" |
| 5038 | "void main(){\n" |
| 5039 | " gl_Position = vec4(1);\n" |
| 5040 | "}\n"; |
| 5041 | char const *fsSource = |
| 5042 | "#version 140\n" |
| 5043 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5044 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5045 | "\n" |
| 5046 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
| 5047 | "void main(){\n" |
| 5048 | " x = ivec4(1);\n" |
| 5049 | "}\n"; |
| 5050 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5051 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5052 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5053 | |
| 5054 | VkPipelineObj pipe(m_device); |
| 5055 | pipe.AddShader(&vs); |
| 5056 | pipe.AddShader(&fs); |
| 5057 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5058 | /* set up CB 0; type is UNORM by default */ |
| 5059 | pipe.AddColorAttachment(); |
| 5060 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5061 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5062 | VkDescriptorSetObj descriptorSet(m_device); |
| 5063 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5064 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5065 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5066 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5067 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5068 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5069 | FAIL() << "Did not receive Error 'does not match FS output type'"; |
| 5070 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5071 | } |
| 5072 | } |
Chris Forbes | c205073 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 5073 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5074 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) |
| 5075 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5076 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5077 | "not declared in pipeline layout"); |
| 5078 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5079 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5080 | |
| 5081 | char const *vsSource = |
| 5082 | "#version 140\n" |
| 5083 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5084 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5085 | "\n" |
| 5086 | "void main(){\n" |
| 5087 | " gl_Position = vec4(1);\n" |
| 5088 | "}\n"; |
| 5089 | char const *fsSource = |
| 5090 | "#version 140\n" |
| 5091 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5092 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5093 | "\n" |
| 5094 | "layout(location=0) out vec4 x;\n" |
| 5095 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5096 | "void main(){\n" |
| 5097 | " x = vec4(bar.y);\n" |
| 5098 | "}\n"; |
| 5099 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5100 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5101 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5102 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5103 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5104 | VkPipelineObj pipe(m_device); |
| 5105 | pipe.AddShader(&vs); |
| 5106 | pipe.AddShader(&fs); |
| 5107 | |
| 5108 | /* set up CB 0; type is UNORM by default */ |
| 5109 | pipe.AddColorAttachment(); |
| 5110 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5111 | |
| 5112 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5113 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5114 | |
| 5115 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5116 | |
| 5117 | /* should have generated an error -- pipeline layout does not |
| 5118 | * provide a uniform buffer in 0.0 |
| 5119 | */ |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5120 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5121 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 5122 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5123 | } |
| 5124 | } |
| 5125 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5126 | #endif // SHADER_CHECKER_TESTS |
| 5127 | |
| 5128 | #if DEVICE_LIMITS_TESTS |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5129 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) |
| 5130 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5131 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5132 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5133 | |
| 5134 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5135 | |
| 5136 | // Create an image |
| 5137 | VkImage image; |
| 5138 | |
| 5139 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5140 | const int32_t tex_width = 32; |
| 5141 | const int32_t tex_height = 32; |
| 5142 | |
| 5143 | VkImageCreateInfo image_create_info = {}; |
| 5144 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5145 | image_create_info.pNext = NULL; |
| 5146 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5147 | image_create_info.format = tex_format; |
| 5148 | image_create_info.extent.width = tex_width; |
| 5149 | image_create_info.extent.height = tex_height; |
| 5150 | image_create_info.extent.depth = 1; |
| 5151 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5152 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5153 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5154 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5155 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5156 | image_create_info.flags = 0; |
| 5157 | |
| 5158 | // Introduce error by sending down a bogus width extent |
| 5159 | image_create_info.extent.width = 65536; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5160 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5161 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5162 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5163 | FAIL() << "Did not receive Error 'CreateImage extents exceed allowable limits for format'"; |
| 5164 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5165 | } |
| 5166 | } |
| 5167 | |
| 5168 | TEST_F(VkLayerTest, CreateImageResourceSizeViolation) |
| 5169 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5170 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5171 | "CreateImage resource size exceeds allowable maximum"); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5172 | |
| 5173 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5174 | |
| 5175 | // Create an image |
| 5176 | VkImage image; |
| 5177 | |
| 5178 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5179 | const int32_t tex_width = 32; |
| 5180 | const int32_t tex_height = 32; |
| 5181 | |
| 5182 | VkImageCreateInfo image_create_info = {}; |
| 5183 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5184 | image_create_info.pNext = NULL; |
| 5185 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5186 | image_create_info.format = tex_format; |
| 5187 | image_create_info.extent.width = tex_width; |
| 5188 | image_create_info.extent.height = tex_height; |
| 5189 | image_create_info.extent.depth = 1; |
| 5190 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5191 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5192 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5193 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5194 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5195 | image_create_info.flags = 0; |
| 5196 | |
| 5197 | // Introduce error by sending down individually allowable values that result in a surface size |
| 5198 | // exceeding the device maximum |
| 5199 | image_create_info.extent.width = 8192; |
| 5200 | image_create_info.extent.height = 8192; |
| 5201 | image_create_info.extent.depth = 16; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5202 | image_create_info.arrayLayers = 4; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5203 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5204 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5205 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5206 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5207 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5208 | FAIL() << "Did not receive Error 'CreateImage resource size exceeds allowable maximum'"; |
| 5209 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5210 | } |
| 5211 | } |
| 5212 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5213 | TEST_F(VkLayerTest, UpdateBufferAlignment) |
| 5214 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5215 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 5216 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5217 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5218 | "dstOffset, is not a multiple of 4"); |
| 5219 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5220 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5221 | |
| 5222 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5223 | vk_testing::Buffer buffer; |
| 5224 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 5225 | |
| 5226 | BeginCommandBuffer(); |
| 5227 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5228 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5229 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5230 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 5231 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5232 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5233 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5234 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5235 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5236 | "dataSize, is not a multiple of 4"); |
| 5237 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5238 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5239 | |
| 5240 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5241 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dataSize, is not a multiple of 4'"; |
| 5242 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5243 | } |
| 5244 | EndCommandBuffer(); |
| 5245 | } |
| 5246 | |
| 5247 | TEST_F(VkLayerTest, FillBufferAlignment) |
| 5248 | { |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5249 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5250 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5251 | |
| 5252 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5253 | |
| 5254 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5255 | vk_testing::Buffer buffer; |
| 5256 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 5257 | |
| 5258 | BeginCommandBuffer(); |
| 5259 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5260 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5261 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5262 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 5263 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5264 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5265 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5266 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5267 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5268 | "size, is not a multiple of 4"); |
| 5269 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5270 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5271 | |
| 5272 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5273 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize size, is not a multiple of 4'"; |
| 5274 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5275 | } |
| 5276 | EndCommandBuffer(); |
| 5277 | } |
| 5278 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5279 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5280 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5281 | #if IMAGE_TESTS |
| 5282 | TEST_F(VkLayerTest, InvalidImageView) |
| 5283 | { |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5284 | VkResult err; |
| 5285 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5286 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5287 | "vkCreateImageView called with baseMipLevel 10 "); |
| 5288 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5289 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5290 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5291 | // Create an image and try to create a view with bad baseMipLevel |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5292 | VkImage image; |
| 5293 | |
| 5294 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5295 | const int32_t tex_width = 32; |
| 5296 | const int32_t tex_height = 32; |
| 5297 | |
| 5298 | VkImageCreateInfo image_create_info = {}; |
| 5299 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5300 | image_create_info.pNext = NULL; |
| 5301 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5302 | image_create_info.format = tex_format; |
| 5303 | image_create_info.extent.width = tex_width; |
| 5304 | image_create_info.extent.height = tex_height; |
| 5305 | image_create_info.extent.depth = 1; |
| 5306 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5307 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5308 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5309 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5310 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5311 | image_create_info.flags = 0; |
| 5312 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5313 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5314 | ASSERT_VK_SUCCESS(err); |
| 5315 | |
| 5316 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5317 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5318 | image_view_create_info.image = image; |
| 5319 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5320 | image_view_create_info.format = tex_format; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5321 | image_view_create_info.subresourceRange.layerCount = 1; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5322 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5323 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5324 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5325 | |
| 5326 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5327 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5328 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5329 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5330 | FAIL() << "Did not receive Error 'vkCreateImageView called with baseMipLevel 10...'"; |
| 5331 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5332 | } |
| 5333 | } |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5334 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5335 | TEST_F(VkLayerTest, InvalidImageViewAspect) |
| 5336 | { |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5337 | VkResult err; |
| 5338 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5339 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5340 | "vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set"); |
| 5341 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5342 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5343 | |
| 5344 | // Create an image and try to create a view with an invalid aspectMask |
| 5345 | VkImage image; |
| 5346 | |
| 5347 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5348 | const int32_t tex_width = 32; |
| 5349 | const int32_t tex_height = 32; |
| 5350 | |
| 5351 | VkImageCreateInfo image_create_info = {}; |
| 5352 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5353 | image_create_info.pNext = NULL; |
| 5354 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5355 | image_create_info.format = tex_format; |
| 5356 | image_create_info.extent.width = tex_width; |
| 5357 | image_create_info.extent.height = tex_height; |
| 5358 | image_create_info.extent.depth = 1; |
| 5359 | image_create_info.mipLevels = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5360 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5361 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5362 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5363 | image_create_info.flags = 0; |
| 5364 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5365 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5366 | ASSERT_VK_SUCCESS(err); |
| 5367 | |
| 5368 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5369 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5370 | image_view_create_info.image = image; |
| 5371 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5372 | image_view_create_info.format = tex_format; |
| 5373 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5374 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5375 | // Cause an error by setting an invalid image aspect |
| 5376 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 5377 | |
| 5378 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5379 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5380 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5381 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5382 | FAIL() << "Did not receive Error 'VkCreateImageView: Color image formats must have ...'"; |
| 5383 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5384 | } |
| 5385 | } |
| 5386 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5387 | TEST_F(VkLayerTest, CopyImageTypeMismatch) |
| 5388 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5389 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5390 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5391 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5392 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5393 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 5394 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5395 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5396 | |
| 5397 | // Create two images of different types and try to copy between them |
| 5398 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5399 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5400 | VkDeviceMemory srcMem; |
| 5401 | VkDeviceMemory destMem; |
| 5402 | VkMemoryRequirements memReqs; |
| 5403 | |
| 5404 | VkImageCreateInfo image_create_info = {}; |
| 5405 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5406 | image_create_info.pNext = NULL; |
| 5407 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5408 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5409 | image_create_info.extent.width = 32; |
| 5410 | image_create_info.extent.height = 32; |
| 5411 | image_create_info.extent.depth = 1; |
| 5412 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5413 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5414 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5415 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5416 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5417 | image_create_info.flags = 0; |
| 5418 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5419 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5420 | ASSERT_VK_SUCCESS(err); |
| 5421 | |
| 5422 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5423 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5424 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5425 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5426 | ASSERT_VK_SUCCESS(err); |
| 5427 | |
| 5428 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5429 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5430 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5431 | memAlloc.pNext = NULL; |
| 5432 | memAlloc.allocationSize = 0; |
| 5433 | memAlloc.memoryTypeIndex = 0; |
| 5434 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5435 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5436 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5437 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5438 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5439 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5440 | ASSERT_VK_SUCCESS(err); |
| 5441 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5442 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5443 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5444 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5445 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5446 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5447 | ASSERT_VK_SUCCESS(err); |
| 5448 | |
| 5449 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5450 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5451 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5452 | ASSERT_VK_SUCCESS(err); |
| 5453 | |
| 5454 | BeginCommandBuffer(); |
| 5455 | VkImageCopy copyRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5456 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5457 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5458 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5459 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5460 | copyRegion.srcOffset.x = 0; |
| 5461 | copyRegion.srcOffset.y = 0; |
| 5462 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5463 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5464 | copyRegion.dstSubresource.mipLevel = 0; |
| 5465 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5466 | copyRegion.dstSubresource.layerCount = 0; |
| 5467 | copyRegion.dstOffset.x = 0; |
| 5468 | copyRegion.dstOffset.y = 0; |
| 5469 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5470 | copyRegion.extent.width = 1; |
| 5471 | copyRegion.extent.height = 1; |
| 5472 | copyRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5473 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5474 | EndCommandBuffer(); |
| 5475 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5476 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5477 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5478 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5479 | } |
| 5480 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5481 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5482 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5483 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5484 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5485 | } |
| 5486 | |
| 5487 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) |
| 5488 | { |
| 5489 | // TODO : Create two images with different format sizes and vkCmdCopyImage between them |
| 5490 | } |
| 5491 | |
| 5492 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) |
| 5493 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5494 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5495 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5496 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5497 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5498 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 5499 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5500 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5501 | |
| 5502 | // Create two images of different types and try to copy between them |
| 5503 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5504 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5505 | VkDeviceMemory srcMem; |
| 5506 | VkDeviceMemory destMem; |
| 5507 | VkMemoryRequirements memReqs; |
| 5508 | |
| 5509 | VkImageCreateInfo image_create_info = {}; |
| 5510 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5511 | image_create_info.pNext = NULL; |
| 5512 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5513 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5514 | image_create_info.extent.width = 32; |
| 5515 | image_create_info.extent.height = 32; |
| 5516 | image_create_info.extent.depth = 1; |
| 5517 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5518 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5519 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5520 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5521 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5522 | image_create_info.flags = 0; |
| 5523 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5524 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5525 | ASSERT_VK_SUCCESS(err); |
| 5526 | |
| 5527 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5528 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5529 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5530 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5531 | ASSERT_VK_SUCCESS(err); |
| 5532 | |
| 5533 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5534 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5535 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5536 | memAlloc.pNext = NULL; |
| 5537 | memAlloc.allocationSize = 0; |
| 5538 | memAlloc.memoryTypeIndex = 0; |
| 5539 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5540 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5541 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5542 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5543 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5544 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5545 | ASSERT_VK_SUCCESS(err); |
| 5546 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5547 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5548 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5549 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5550 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5551 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5552 | ASSERT_VK_SUCCESS(err); |
| 5553 | |
| 5554 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5555 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5556 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5557 | ASSERT_VK_SUCCESS(err); |
| 5558 | |
| 5559 | BeginCommandBuffer(); |
| 5560 | VkImageCopy copyRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5561 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5562 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5563 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5564 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5565 | copyRegion.srcOffset.x = 0; |
| 5566 | copyRegion.srcOffset.y = 0; |
| 5567 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5568 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5569 | copyRegion.dstSubresource.mipLevel = 0; |
| 5570 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5571 | copyRegion.dstSubresource.layerCount = 0; |
| 5572 | copyRegion.dstOffset.x = 0; |
| 5573 | copyRegion.dstOffset.y = 0; |
| 5574 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5575 | copyRegion.extent.width = 1; |
| 5576 | copyRegion.extent.height = 1; |
| 5577 | copyRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5578 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5579 | EndCommandBuffer(); |
| 5580 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5581 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5582 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5583 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5584 | } |
| 5585 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5586 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5587 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5588 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5589 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5590 | } |
| 5591 | |
| 5592 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) |
| 5593 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5594 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5595 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5596 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5597 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5598 | "vkCmdResolveImage called with source sample count less than 2."); |
| 5599 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5600 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5601 | |
| 5602 | // Create two images of sample count 1 and try to Resolve between them |
| 5603 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5604 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5605 | VkDeviceMemory srcMem; |
| 5606 | VkDeviceMemory destMem; |
| 5607 | VkMemoryRequirements memReqs; |
| 5608 | |
| 5609 | VkImageCreateInfo image_create_info = {}; |
| 5610 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5611 | image_create_info.pNext = NULL; |
| 5612 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5613 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5614 | image_create_info.extent.width = 32; |
| 5615 | image_create_info.extent.height = 1; |
| 5616 | image_create_info.extent.depth = 1; |
| 5617 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5618 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5619 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5620 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5621 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5622 | image_create_info.flags = 0; |
| 5623 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5624 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5625 | ASSERT_VK_SUCCESS(err); |
| 5626 | |
| 5627 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5628 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5629 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5630 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5631 | ASSERT_VK_SUCCESS(err); |
| 5632 | |
| 5633 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5634 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5635 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5636 | memAlloc.pNext = NULL; |
| 5637 | memAlloc.allocationSize = 0; |
| 5638 | memAlloc.memoryTypeIndex = 0; |
| 5639 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5640 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5641 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5642 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5643 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5644 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5645 | ASSERT_VK_SUCCESS(err); |
| 5646 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5647 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5648 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5649 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5650 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5651 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5652 | ASSERT_VK_SUCCESS(err); |
| 5653 | |
| 5654 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5655 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5656 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5657 | ASSERT_VK_SUCCESS(err); |
| 5658 | |
| 5659 | BeginCommandBuffer(); |
| 5660 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5661 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5662 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5663 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5664 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5665 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5666 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5667 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5668 | resolveRegion.srcOffset.x = 0; |
| 5669 | resolveRegion.srcOffset.y = 0; |
| 5670 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5671 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5672 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5673 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5674 | resolveRegion.dstSubresource.layerCount = 0; |
| 5675 | resolveRegion.dstOffset.x = 0; |
| 5676 | resolveRegion.dstOffset.y = 0; |
| 5677 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5678 | resolveRegion.extent.width = 1; |
| 5679 | resolveRegion.extent.height = 1; |
| 5680 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5681 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5682 | EndCommandBuffer(); |
| 5683 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5684 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5685 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with source sample count less than 2.'"; |
| 5686 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5687 | } |
| 5688 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5689 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5690 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5691 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5692 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5693 | } |
| 5694 | |
| 5695 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) |
| 5696 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5697 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5698 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5699 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5700 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5701 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 5702 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5703 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5704 | |
| 5705 | // Create two images of sample count 2 and try to Resolve between them |
| 5706 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5707 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5708 | VkDeviceMemory srcMem; |
| 5709 | VkDeviceMemory destMem; |
| 5710 | VkMemoryRequirements memReqs; |
| 5711 | |
| 5712 | VkImageCreateInfo image_create_info = {}; |
| 5713 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5714 | image_create_info.pNext = NULL; |
| 5715 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5716 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5717 | image_create_info.extent.width = 32; |
| 5718 | image_create_info.extent.height = 1; |
| 5719 | image_create_info.extent.depth = 1; |
| 5720 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5721 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5722 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5723 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5724 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5725 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5726 | image_create_info.flags = 0; |
| 5727 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5728 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5729 | ASSERT_VK_SUCCESS(err); |
| 5730 | |
| 5731 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5732 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5733 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5734 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5735 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5736 | ASSERT_VK_SUCCESS(err); |
| 5737 | |
| 5738 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5739 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5740 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5741 | memAlloc.pNext = NULL; |
| 5742 | memAlloc.allocationSize = 0; |
| 5743 | memAlloc.memoryTypeIndex = 0; |
| 5744 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5745 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5746 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5747 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5748 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5749 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5750 | ASSERT_VK_SUCCESS(err); |
| 5751 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5752 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5753 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5754 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5755 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5756 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5757 | ASSERT_VK_SUCCESS(err); |
| 5758 | |
| 5759 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5760 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5761 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5762 | ASSERT_VK_SUCCESS(err); |
| 5763 | |
| 5764 | BeginCommandBuffer(); |
| 5765 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5766 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5767 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5768 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5769 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5770 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5771 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5772 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5773 | resolveRegion.srcOffset.x = 0; |
| 5774 | resolveRegion.srcOffset.y = 0; |
| 5775 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5776 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5777 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5778 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5779 | resolveRegion.dstSubresource.layerCount = 0; |
| 5780 | resolveRegion.dstOffset.x = 0; |
| 5781 | resolveRegion.dstOffset.y = 0; |
| 5782 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5783 | resolveRegion.extent.width = 1; |
| 5784 | resolveRegion.extent.height = 1; |
| 5785 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5786 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5787 | EndCommandBuffer(); |
| 5788 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5789 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5790 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with dest sample count greater than 1.'"; |
| 5791 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5792 | } |
| 5793 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5794 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5795 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5796 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5797 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5798 | } |
| 5799 | |
| 5800 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) |
| 5801 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5802 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5803 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5804 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5805 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5806 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 5807 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5808 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5809 | |
| 5810 | // Create two images of different types and try to copy between them |
| 5811 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5812 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5813 | VkDeviceMemory srcMem; |
| 5814 | VkDeviceMemory destMem; |
| 5815 | VkMemoryRequirements memReqs; |
| 5816 | |
| 5817 | VkImageCreateInfo image_create_info = {}; |
| 5818 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5819 | image_create_info.pNext = NULL; |
| 5820 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5821 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5822 | image_create_info.extent.width = 32; |
| 5823 | image_create_info.extent.height = 1; |
| 5824 | image_create_info.extent.depth = 1; |
| 5825 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5826 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5827 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5828 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5829 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5830 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5831 | image_create_info.flags = 0; |
| 5832 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5833 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5834 | ASSERT_VK_SUCCESS(err); |
| 5835 | |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5836 | // Set format to something other than source image |
| 5837 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 5838 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5839 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5840 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5841 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5842 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5843 | ASSERT_VK_SUCCESS(err); |
| 5844 | |
| 5845 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5846 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5847 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5848 | memAlloc.pNext = NULL; |
| 5849 | memAlloc.allocationSize = 0; |
| 5850 | memAlloc.memoryTypeIndex = 0; |
| 5851 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5852 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5853 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5854 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5855 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5856 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5857 | ASSERT_VK_SUCCESS(err); |
| 5858 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5859 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5860 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5861 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5862 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5863 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5864 | ASSERT_VK_SUCCESS(err); |
| 5865 | |
| 5866 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5867 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5868 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5869 | ASSERT_VK_SUCCESS(err); |
| 5870 | |
| 5871 | BeginCommandBuffer(); |
| 5872 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5873 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5874 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5875 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5876 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5877 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5878 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5879 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5880 | resolveRegion.srcOffset.x = 0; |
| 5881 | resolveRegion.srcOffset.y = 0; |
| 5882 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5883 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5884 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5885 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5886 | resolveRegion.dstSubresource.layerCount = 0; |
| 5887 | resolveRegion.dstOffset.x = 0; |
| 5888 | resolveRegion.dstOffset.y = 0; |
| 5889 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5890 | resolveRegion.extent.width = 1; |
| 5891 | resolveRegion.extent.height = 1; |
| 5892 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5893 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5894 | EndCommandBuffer(); |
| 5895 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5896 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5897 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest formats.'"; |
| 5898 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5899 | } |
| 5900 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5901 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5902 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5903 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5904 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5905 | } |
| 5906 | |
| 5907 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) |
| 5908 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5909 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5910 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5911 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5912 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5913 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 5914 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5915 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5916 | |
| 5917 | // Create two images of different types and try to copy between them |
| 5918 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5919 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5920 | VkDeviceMemory srcMem; |
| 5921 | VkDeviceMemory destMem; |
| 5922 | VkMemoryRequirements memReqs; |
| 5923 | |
| 5924 | VkImageCreateInfo image_create_info = {}; |
| 5925 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5926 | image_create_info.pNext = NULL; |
| 5927 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5928 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5929 | image_create_info.extent.width = 32; |
| 5930 | image_create_info.extent.height = 1; |
| 5931 | image_create_info.extent.depth = 1; |
| 5932 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5933 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5934 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5935 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5936 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5937 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5938 | image_create_info.flags = 0; |
| 5939 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5940 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5941 | ASSERT_VK_SUCCESS(err); |
| 5942 | |
| 5943 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5944 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5945 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5946 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5947 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5948 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5949 | ASSERT_VK_SUCCESS(err); |
| 5950 | |
| 5951 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5952 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5953 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5954 | memAlloc.pNext = NULL; |
| 5955 | memAlloc.allocationSize = 0; |
| 5956 | memAlloc.memoryTypeIndex = 0; |
| 5957 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5958 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5959 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5960 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5961 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5962 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5963 | ASSERT_VK_SUCCESS(err); |
| 5964 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5965 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5966 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5967 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5968 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5969 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5970 | ASSERT_VK_SUCCESS(err); |
| 5971 | |
| 5972 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5973 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5974 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5975 | ASSERT_VK_SUCCESS(err); |
| 5976 | |
| 5977 | BeginCommandBuffer(); |
| 5978 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5979 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5980 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5981 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5982 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5983 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5984 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5985 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5986 | resolveRegion.srcOffset.x = 0; |
| 5987 | resolveRegion.srcOffset.y = 0; |
| 5988 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5989 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5990 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5991 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5992 | resolveRegion.dstSubresource.layerCount = 0; |
| 5993 | resolveRegion.dstOffset.x = 0; |
| 5994 | resolveRegion.dstOffset.y = 0; |
| 5995 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5996 | resolveRegion.extent.width = 1; |
| 5997 | resolveRegion.extent.height = 1; |
| 5998 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5999 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6000 | EndCommandBuffer(); |
| 6001 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6002 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6003 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest image types.'"; |
| 6004 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6005 | } |
| 6006 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6007 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6008 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6009 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6010 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6011 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6012 | |
| 6013 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) |
| 6014 | { |
| 6015 | // Create a single Image descriptor and cause it to first hit an error due |
| 6016 | // to using a DS format, then cause it to hit error due to COLOR_BIT not set in aspect |
| 6017 | // The image format check comes 2nd in validation so we trigger it first, |
| 6018 | // then when we cause aspect fail next, bad format check will be preempted |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6019 | VkResult err; |
| 6020 | |
Courtney Goeltzenleuchter | acb1359 | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6021 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6022 | "Combination depth/stencil image formats can have only the "); |
| 6023 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6024 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6025 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6026 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6027 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6028 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6029 | |
| 6030 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6031 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6032 | ds_pool_ci.pNext = NULL; |
| 6033 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6034 | ds_pool_ci.poolSizeCount = 1; |
| 6035 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6036 | |
| 6037 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6038 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6039 | ASSERT_VK_SUCCESS(err); |
| 6040 | |
| 6041 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6042 | dsl_binding.binding = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6043 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6044 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6045 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6046 | dsl_binding.pImmutableSamplers = NULL; |
| 6047 | |
| 6048 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6049 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6050 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6051 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6052 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6053 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6054 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6055 | ASSERT_VK_SUCCESS(err); |
| 6056 | |
| 6057 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6058 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6059 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6060 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6061 | alloc_info.descriptorPool = ds_pool; |
| 6062 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6063 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6064 | ASSERT_VK_SUCCESS(err); |
| 6065 | |
| 6066 | VkImage image_bad; |
| 6067 | VkImage image_good; |
| 6068 | // One bad format and one good format for Color attachment |
| 6069 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 6070 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
| 6071 | const int32_t tex_width = 32; |
| 6072 | const int32_t tex_height = 32; |
| 6073 | |
| 6074 | VkImageCreateInfo image_create_info = {}; |
| 6075 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6076 | image_create_info.pNext = NULL; |
| 6077 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6078 | image_create_info.format = tex_format_bad; |
| 6079 | image_create_info.extent.width = tex_width; |
| 6080 | image_create_info.extent.height = tex_height; |
| 6081 | image_create_info.extent.depth = 1; |
| 6082 | image_create_info.mipLevels = 1; |
| 6083 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6084 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6085 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6086 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 6087 | image_create_info.flags = 0; |
| 6088 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6089 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6090 | ASSERT_VK_SUCCESS(err); |
| 6091 | image_create_info.format = tex_format_good; |
| 6092 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6093 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_good); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6094 | ASSERT_VK_SUCCESS(err); |
| 6095 | |
| 6096 | VkImageViewCreateInfo image_view_create_info = {}; |
| 6097 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6098 | image_view_create_info.image = image_bad; |
| 6099 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6100 | image_view_create_info.format = tex_format_bad; |
| 6101 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 6102 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6103 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6104 | image_view_create_info.subresourceRange.levelCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6105 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6106 | |
| 6107 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6108 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6109 | |
| 6110 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6111 | FAIL() << "Did not receive Error 'Combination depth-stencil image formats can have only the....'"; |
| 6112 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6113 | } |
| 6114 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6115 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 6116 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6117 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6118 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6119 | } |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6120 | #endif // IMAGE_TESTS |
| 6121 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 6122 | int main(int argc, char **argv) { |
| 6123 | int result; |
| 6124 | |
| 6125 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 6126 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 6127 | |
| 6128 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 6129 | |
| 6130 | result = RUN_ALL_TESTS(); |
| 6131 | |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 6132 | VkTestFramework::Finish(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 6133 | return result; |
| 6134 | } |