Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2015 Valve Corporation |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3 | // Copyright (C) 2015 Google, Inc. |
Tony Barbour | 65c48b3 | 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 | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 28 | // Author: Tobin Ehlis <tobine@google.com> |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 29 | // Author: Tony Barbour <tony@LunarG.com> |
| 30 | |
| 31 | |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 32 | #include <vulkan/vulkan.h> |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 33 | #include <vulkan/vk_ext_debug_report.h> |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 34 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 35 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 36 | #include "vk_layer_config.h" |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 37 | #include "../icd/common/icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 38 | |
Mark Lobodzinski | 3780e14 | 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 | 0788f52 | 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 | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 47 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 48 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 49 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 50 | |
Mark Lobodzinski | 3780e14 | 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 | 271ba75 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 64 | BsoFailLineWidth = 0x00000001, |
| 65 | BsoFailDepthBias = 0x00000002, |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 66 | BsoFailViewport = 0x00000004, |
Tobin Ehlis | 963a404 | 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 | 3780e14 | 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 | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 82 | static const char bindStateVertShaderText[] = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 83 | "#version 400\n" |
| 84 | "#extension GL_ARB_separate_shader_objects : require\n" |
| 85 | "#extension GL_ARB_shading_language_420pack : require\n" |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 86 | "vec2 vertices[3];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 87 | "out gl_PerVertex {\n" |
| 88 | " vec4 gl_Position;\n" |
| 89 | "};\n" |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 90 | "void main() {\n" |
| 91 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 92 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 93 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 94 | " gl_Position = vec4(vertices[gl_VertexID % 3], 0.0, 1.0);\n" |
| 95 | "}\n"; |
| 96 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 97 | static const char bindStateFragShaderText[] = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 98 | "#version 400\n" |
Cody Northrop | 8a3bb13 | 2015-06-16 17:32:04 -0600 | [diff] [blame] | 99 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 100 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 101 | "\n" |
| 102 | "layout(location = 0) out vec4 uFragColor;\n" |
| 103 | "void main(){\n" |
| 104 | " uFragColor = vec4(0,1,0,1);\n" |
| 105 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 106 | |
Jesse Hall | 4fb40e6 | 2015-12-22 21:27:55 -0800 | [diff] [blame] | 107 | static VKAPI_ATTR VkBool32 VKAPI_CALL myDbgFunc( |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 108 | VkFlags msgFlags, |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 109 | VkDebugReportObjectTypeEXT objType, |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 110 | uint64_t srcObject, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 111 | size_t location, |
| 112 | int32_t msgCode, |
| 113 | const char* pLayerPrefix, |
| 114 | const char* pMsg, |
Courtney Goeltzenleuchter | af5e755 | 2015-11-30 11:52:06 -0700 | [diff] [blame] | 115 | const void* pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 116 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 117 | // ******************************************************** |
| 118 | // ErrorMonitor Usage: |
| 119 | // |
| 120 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 121 | // encountered log messages. Passing NULL will match all log messages. |
| 122 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 123 | // |
| 124 | // Call DesiredMsgFound to determine if the desired failure message |
| 125 | // was encountered. |
| 126 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 127 | class ErrorMonitor { |
| 128 | public: |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 129 | ErrorMonitor() |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 130 | { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 131 | test_platform_thread_create_mutex(&m_mutex); |
| 132 | test_platform_thread_lock_mutex(&m_mutex); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 133 | m_msgFlags = VK_DEBUG_REPORT_INFO_BIT_EXT; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 134 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 135 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 136 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 137 | |
| 138 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 139 | { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 140 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 141 | m_desiredMsg.clear(); |
| 142 | m_failureMsg.clear(); |
| 143 | m_otherMsgs.clear(); |
| 144 | m_desiredMsg = msgString; |
| 145 | m_msgFound = VK_FALSE; |
| 146 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 147 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 148 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 149 | |
| 150 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 151 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 152 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 153 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 154 | if (m_bailout != NULL) { |
| 155 | *m_bailout = true; |
| 156 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 157 | string errorString(msgString); |
| 158 | if (msgFlags & m_msgFlags) { |
| 159 | if (errorString.find(m_desiredMsg) != string::npos) { |
| 160 | m_failureMsg = errorString; |
| 161 | m_msgFound = VK_TRUE; |
| 162 | result = VK_TRUE; |
| 163 | } else { |
| 164 | m_otherMsgs.push_back(errorString); |
| 165 | } |
| 166 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 167 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 168 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 169 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 170 | |
| 171 | vector<string> GetOtherFailureMsgs(void) |
| 172 | { |
| 173 | return m_otherMsgs; |
| 174 | } |
| 175 | |
| 176 | string GetFailureMsg(void) |
| 177 | { |
| 178 | return m_failureMsg; |
| 179 | } |
| 180 | |
| 181 | VkBool32 DesiredMsgFound(void) |
| 182 | { |
| 183 | return m_msgFound; |
| 184 | } |
| 185 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 186 | void SetBailout(bool *bailout) |
| 187 | { |
| 188 | m_bailout = bailout; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 189 | } |
| 190 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 191 | void DumpFailureMsgs(void) |
| 192 | { |
| 193 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 194 | cout << "Other error messages logged for this test were:" << endl; |
| 195 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 196 | cout << " " << *iter << endl; |
| 197 | } |
| 198 | } |
| 199 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 200 | private: |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 201 | VkFlags m_msgFlags; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 202 | string m_desiredMsg; |
| 203 | string m_failureMsg; |
| 204 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 205 | test_platform_thread_mutex m_mutex; |
| 206 | bool* m_bailout; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 207 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 208 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 209 | |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 210 | static VkBool32 myDbgFunc( |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 211 | VkFlags msgFlags, |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 212 | VkDebugReportObjectTypeEXT objType, |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 213 | uint64_t srcObject, |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 214 | size_t location, |
| 215 | int32_t msgCode, |
| 216 | const char* pLayerPrefix, |
| 217 | const char* pMsg, |
Courtney Goeltzenleuchter | af5e755 | 2015-11-30 11:52:06 -0700 | [diff] [blame] | 218 | const void* pUserData) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 219 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 220 | if (msgFlags & (VK_DEBUG_REPORT_WARN_BIT_EXT | VK_DEBUG_REPORT_PERF_WARN_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 221 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 222 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 223 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 224 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 225 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 226 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 227 | class VkLayerTest : public VkRenderFramework |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 228 | { |
| 229 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 230 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 231 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 232 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 233 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 234 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 235 | { GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, failMask); } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 236 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 237 | /* Convenience functions that use built-in command buffer */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 238 | VkResult BeginCommandBuffer() { return BeginCommandBuffer(*m_commandBuffer); } |
| 239 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 240 | void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 241 | { m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, firstInstance); } |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 242 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 243 | { m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); } |
| 244 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
| 245 | void QueueCommandBuffer(const VkFence& fence) { m_commandBuffer->QueueCommandBuffer(fence); } |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 246 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 247 | { m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); } |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 248 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 249 | { m_commandBuffer->BindIndexBuffer(indexBuffer, offset); } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 250 | protected: |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 251 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 252 | |
| 253 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 254 | std::vector<const char *> instance_layer_names; |
| 255 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 256 | std::vector<const char *> instance_extension_names; |
| 257 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 258 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 259 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 260 | /* |
| 261 | * Since CreateDbgMsgCallback is an instance level extension call |
| 262 | * any extension / layer that utilizes that feature also needs |
| 263 | * to be enabled at create instance time. |
| 264 | */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 265 | // Use Threading layer first to protect others from ThreadCommandBufferCollision test |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 266 | instance_layer_names.push_back("VK_LAYER_LUNARG_threading"); |
| 267 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 268 | instance_layer_names.push_back("VK_LAYER_LUNARG_mem_tracker"); |
| 269 | instance_layer_names.push_back("VK_LAYER_LUNARG_draw_state"); |
| 270 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 271 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 272 | |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 273 | device_layer_names.push_back("VK_LAYER_LUNARG_threading"); |
| 274 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 275 | device_layer_names.push_back("VK_LAYER_LUNARG_mem_tracker"); |
| 276 | device_layer_names.push_back("VK_LAYER_LUNARG_draw_state"); |
| 277 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 278 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 279 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 280 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 281 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 282 | this->app_info.pApplicationName = "layer_tests"; |
| 283 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 284 | this->app_info.pEngineName = "unittest"; |
| 285 | this->app_info.engineVersion = 1; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 286 | this->app_info.apiVersion = VK_API_VERSION; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 287 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 288 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 289 | InitFramework(instance_layer_names, device_layer_names, |
| 290 | instance_extension_names, device_extension_names, |
| 291 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | virtual void TearDown() { |
| 295 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 296 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 297 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 298 | } |
| 299 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 300 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 301 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 302 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 303 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 304 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 305 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 306 | |
| 307 | /* |
| 308 | * For render test all drawing happens in a single render pass |
| 309 | * on a single command buffer. |
| 310 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 311 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 312 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | return result; |
| 316 | } |
| 317 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 318 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 319 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 320 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 321 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 322 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 323 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 324 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 325 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 326 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 327 | |
| 328 | return result; |
| 329 | } |
| 330 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 331 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask) |
| 332 | { |
| 333 | // Create identity matrix |
| 334 | int i; |
| 335 | struct vktriangle_vs_uniform data; |
| 336 | |
| 337 | glm::mat4 Projection = glm::mat4(1.0f); |
| 338 | glm::mat4 View = glm::mat4(1.0f); |
| 339 | glm::mat4 Model = glm::mat4(1.0f); |
| 340 | glm::mat4 MVP = Projection * View * Model; |
| 341 | const int matrixSize = sizeof(MVP); |
| 342 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
| 343 | |
| 344 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 345 | |
| 346 | static const Vertex tri_data[] = |
| 347 | { |
| 348 | { XYZ1( -1, -1, 0 ), XYZ1( 1.f, 0.f, 0.f ) }, |
| 349 | { XYZ1( 1, -1, 0 ), XYZ1( 0.f, 1.f, 0.f ) }, |
| 350 | { XYZ1( 0, 1, 0 ), XYZ1( 0.f, 0.f, 1.f ) }, |
| 351 | }; |
| 352 | |
| 353 | for (i=0; i<3; i++) { |
| 354 | data.position[i][0] = tri_data[i].posX; |
| 355 | data.position[i][1] = tri_data[i].posY; |
| 356 | data.position[i][2] = tri_data[i].posZ; |
| 357 | data.position[i][3] = tri_data[i].posW; |
| 358 | data.color[i][0] = tri_data[i].r; |
| 359 | data.color[i][1] = tri_data[i].g; |
| 360 | data.color[i][2] = tri_data[i].b; |
| 361 | data.color[i][3] = tri_data[i].a; |
| 362 | } |
| 363 | |
| 364 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 365 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 366 | |
| 367 | VkConstantBufferObj constantBuffer(m_device, bufSize*2, sizeof(float), (const void*) &data); |
| 368 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 369 | VkShaderObj vs(m_device,vertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 370 | VkShaderObj ps(m_device,fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 371 | |
| 372 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 373 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 374 | pipelineobj.AddShader(&vs); |
| 375 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 376 | if (failMask & BsoFailLineWidth) { |
| 377 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
| 378 | } |
| 379 | if (failMask & BsoFailDepthBias) { |
| 380 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
| 381 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 382 | // Viewport and scissors must stay in synch or other errors will occur than the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 383 | if (failMask & BsoFailViewport) { |
| 384 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 385 | m_viewports.clear(); |
| 386 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 387 | } |
| 388 | if (failMask & BsoFailScissor) { |
| 389 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 390 | m_scissors.clear(); |
| 391 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 392 | } |
| 393 | if (failMask & BsoFailBlend) { |
| 394 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
| 395 | } |
| 396 | if (failMask & BsoFailDepthBounds) { |
| 397 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 398 | } |
| 399 | if (failMask & BsoFailStencilReadMask) { |
| 400 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 401 | } |
| 402 | if (failMask & BsoFailStencilWriteMask) { |
| 403 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 404 | } |
| 405 | if (failMask & BsoFailStencilReference) { |
| 406 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 407 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 408 | |
| 409 | VkDescriptorSetObj descriptorSet(m_device); |
| 410 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, constantBuffer); |
| 411 | |
| 412 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 413 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 414 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 415 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 416 | |
| 417 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 418 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 419 | |
| 420 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 421 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 422 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 423 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 424 | } |
| 425 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 426 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 427 | { |
| 428 | if (m_depthStencil->Initialized()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 429 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 430 | } else { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 431 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 432 | } |
| 433 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 434 | commandBuffer->PrepareAttachments(); |
Cody Northrop | 82485a8 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 435 | // Make sure depthWriteEnable is set so that Depth fail test will work correctly |
| 436 | // Make sure stencilTestEnable is set so that Stencil fail test will work correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 437 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 438 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 439 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 440 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 441 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 442 | |
| 443 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 444 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 445 | ds_ci.pNext = NULL; |
| 446 | ds_ci.depthTestEnable = VK_FALSE; |
| 447 | ds_ci.depthWriteEnable = VK_TRUE; |
| 448 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 449 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
| 450 | ds_ci.stencilTestEnable = VK_TRUE; |
| 451 | ds_ci.front = stencil; |
| 452 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 453 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 454 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 455 | pipelineobj.SetViewport(m_viewports); |
| 456 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 457 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 458 | VkResult err = pipelineobj.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 459 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 460 | commandBuffer->BindPipeline(pipelineobj); |
| 461 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | // ******************************************************************************************************************** |
| 465 | // ******************************************************************************************************************** |
| 466 | // ******************************************************************************************************************** |
| 467 | // ******************************************************************************************************************** |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 468 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 469 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 470 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 471 | { |
| 472 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 473 | VkFenceCreateInfo fenceInfo = {}; |
| 474 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 475 | fenceInfo.pNext = NULL; |
| 476 | fenceInfo.flags = 0; |
| 477 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 478 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 479 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 480 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 481 | |
| 482 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 483 | vk_testing::Buffer buffer; |
| 484 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 485 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 486 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 487 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 488 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 489 | |
| 490 | testFence.init(*m_device, fenceInfo); |
| 491 | |
| 492 | // Bypass framework since it does the waits automatically |
| 493 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 494 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 495 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 496 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 497 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 498 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 499 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 500 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 501 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 502 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 503 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 504 | |
| 505 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 506 | ASSERT_VK_SUCCESS( err ); |
| 507 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 508 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 509 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 510 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 511 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 512 | FAIL() << "Did not receive Error 'Resetting CB (0xaddress) before it has completed. You must check CB flag before.'"; |
| 513 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 514 | } |
| 515 | } |
| 516 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 517 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 518 | { |
| 519 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 520 | VkFenceCreateInfo fenceInfo = {}; |
| 521 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 522 | fenceInfo.pNext = NULL; |
| 523 | fenceInfo.flags = 0; |
| 524 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 525 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Calling vkBeginCommandBuffer() on active CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 526 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 527 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 528 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 529 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 530 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 531 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 532 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 533 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 534 | |
| 535 | testFence.init(*m_device, fenceInfo); |
| 536 | |
| 537 | // Bypass framework since it does the waits automatically |
| 538 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 539 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 540 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 541 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 542 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 543 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 544 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 545 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 546 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 547 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 548 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 549 | |
| 550 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 551 | ASSERT_VK_SUCCESS( err ); |
| 552 | |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 553 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 554 | VkCommandBufferBeginInfo info = {}; |
| 555 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 556 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 557 | info.renderPass = VK_NULL_HANDLE; |
| 558 | info.subpass = 0; |
| 559 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 560 | info.occlusionQueryEnable = VK_FALSE; |
| 561 | info.queryFlags = 0; |
| 562 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 563 | |
| 564 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 565 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 566 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 567 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 568 | FAIL() << "Did not receive Error 'Calling vkBeginCommandBuffer() on an active CB (0xaddress) before it has completed'"; |
| 569 | m_errorMonitor->DumpFailureMsgs(); |
| 570 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 571 | } |
| 572 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 573 | #endif |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 574 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) |
| 575 | { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 576 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 577 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 578 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 579 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 580 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 581 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 582 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 583 | |
| 584 | // Create an image, allocate memory, free it, and then try to bind it |
| 585 | VkImage image; |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 586 | VkDeviceMemory mem; |
| 587 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 588 | |
| 589 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 590 | const int32_t tex_width = 32; |
| 591 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 592 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 593 | VkImageCreateInfo image_create_info = {}; |
| 594 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 595 | image_create_info.pNext = NULL; |
| 596 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 597 | image_create_info.format = tex_format; |
| 598 | image_create_info.extent.width = tex_width; |
| 599 | image_create_info.extent.height = tex_height; |
| 600 | image_create_info.extent.depth = 1; |
| 601 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 602 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 603 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 604 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 605 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 606 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 607 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 608 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 609 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 610 | mem_alloc.pNext = NULL; |
| 611 | mem_alloc.allocationSize = 0; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 612 | // Introduce failure, do NOT set memProps to VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 613 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 614 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 615 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 616 | ASSERT_VK_SUCCESS(err); |
| 617 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 618 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 619 | image, |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 620 | &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 621 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 622 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 623 | |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 624 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 625 | if(!pass) { // If we can't find any unmappable memory this test doesn't make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 626 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 627 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 628 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 629 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 630 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 631 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 632 | ASSERT_VK_SUCCESS(err); |
| 633 | |
| 634 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 635 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 636 | ASSERT_VK_SUCCESS(err); |
| 637 | |
| 638 | // Map memory as if to initialize the image |
| 639 | void *mappedAddress = NULL; |
Mark Lobodzinski | f0670cc | 2016-01-05 15:30:41 -0700 | [diff] [blame] | 640 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 641 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 642 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 643 | FAIL() << "Did not receive Error 'Error received did not match expected error message from vkMapMemory in MemTracker'"; |
| 644 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 645 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 646 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 647 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 648 | } |
| 649 | |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 650 | // TODO : Is this test still valid. Not sure it is with updates to memory binding model |
| 651 | // Verify and delete the test of fix the check |
| 652 | //TEST_F(VkLayerTest, FreeBoundMemory) |
| 653 | //{ |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 654 | // VkResult err; |
| 655 | // |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 656 | // m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARN_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 657 | // "Freeing memory object while it still has references"); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 658 | // |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 659 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 660 | |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 661 | // // Create an image, allocate memory, free it, and then try to bind it |
| 662 | // VkImage image; |
| 663 | // VkDeviceMemory mem; |
| 664 | // VkMemoryRequirements mem_reqs; |
| 665 | // |
| 666 | // const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 667 | // const int32_t tex_width = 32; |
| 668 | // const int32_t tex_height = 32; |
| 669 | // |
| 670 | // const VkImageCreateInfo image_create_info = { |
| 671 | // .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 672 | // .pNext = NULL, |
| 673 | // .imageType = VK_IMAGE_TYPE_2D, |
| 674 | // .format = tex_format, |
| 675 | // .extent = { tex_width, tex_height, 1 }, |
| 676 | // .mipLevels = 1, |
| 677 | // .arraySize = 1, |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 678 | // .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 679 | // .tiling = VK_IMAGE_TILING_LINEAR, |
| 680 | // .usage = VK_IMAGE_USAGE_SAMPLED_BIT, |
| 681 | // .flags = 0, |
| 682 | // }; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 683 | // VkMemoryAllocateInfo mem_alloc = { |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 684 | // .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 685 | // .pNext = NULL, |
| 686 | // .allocationSize = 0, |
| 687 | // .memoryTypeIndex = 0, |
| 688 | // }; |
| 689 | // |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 690 | // err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 691 | // ASSERT_VK_SUCCESS(err); |
| 692 | // |
| 693 | // err = vkGetImageMemoryRequirements(m_device->device(), |
| 694 | // image, |
| 695 | // &mem_reqs); |
| 696 | // ASSERT_VK_SUCCESS(err); |
| 697 | // |
| 698 | // mem_alloc.allocationSize = mem_reqs.size; |
| 699 | // |
| 700 | // err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 701 | // ASSERT_VK_SUCCESS(err); |
| 702 | // |
| 703 | // // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 704 | // err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 705 | // ASSERT_VK_SUCCESS(err); |
| 706 | // |
| 707 | // // Bind memory to Image object |
| 708 | // err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 709 | // ASSERT_VK_SUCCESS(err); |
| 710 | // |
| 711 | // // Introduce validation failure, free memory while still bound to object |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 712 | // vkFreeMemory(m_device->device(), mem, NULL); |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 713 | // |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 714 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 715 | // FAIL() << "Did not receive Warning 'Freeing memory object while it still has references'"); |
| 716 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 717 | // } |
| 718 | //} |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 719 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 720 | TEST_F(VkLayerTest, RebindMemory) |
| 721 | { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 722 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 723 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 724 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 725 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 726 | "which has already been bound to mem object"); |
| 727 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 728 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 729 | |
| 730 | // Create an image, allocate memory, free it, and then try to bind it |
| 731 | VkImage image; |
| 732 | VkDeviceMemory mem1; |
| 733 | VkDeviceMemory mem2; |
| 734 | VkMemoryRequirements mem_reqs; |
| 735 | |
| 736 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 737 | const int32_t tex_width = 32; |
| 738 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 739 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 740 | VkImageCreateInfo image_create_info = {}; |
| 741 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 742 | image_create_info.pNext = NULL; |
| 743 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 744 | image_create_info.format = tex_format; |
| 745 | image_create_info.extent.width = tex_width; |
| 746 | image_create_info.extent.height = tex_height; |
| 747 | image_create_info.extent.depth = 1; |
| 748 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 749 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 750 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 751 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 752 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 753 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 754 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 755 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 756 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 757 | mem_alloc.pNext = NULL; |
| 758 | mem_alloc.allocationSize = 0; |
| 759 | mem_alloc.memoryTypeIndex = 0; |
| 760 | |
| 761 | // Introduce failure, do NOT set memProps to VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 762 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 763 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 764 | ASSERT_VK_SUCCESS(err); |
| 765 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 766 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 767 | image, |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 768 | &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 769 | |
| 770 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 771 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 772 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 773 | |
| 774 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 775 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 776 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 777 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 778 | ASSERT_VK_SUCCESS(err); |
| 779 | |
| 780 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 781 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 782 | ASSERT_VK_SUCCESS(err); |
| 783 | |
| 784 | // Introduce validation failure, try to bind a different memory object to the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 785 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 786 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 787 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 788 | FAIL() << "Did not receive Error when rebinding memory to an object"; |
| 789 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 790 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 791 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 792 | vkDestroyImage(m_device->device(), image, NULL); |
| 793 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 794 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 795 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 796 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 797 | TEST_F(VkLayerTest, SubmitSignaledFence) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 798 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 799 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 800 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 801 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 802 | "submitted in SIGNALED state. Fences must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 803 | |
| 804 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 805 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 806 | fenceInfo.pNext = NULL; |
| 807 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 808 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 809 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 810 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 811 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 812 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 813 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 814 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 815 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 816 | |
| 817 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 818 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 819 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 820 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 821 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 822 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 823 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 824 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 825 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 826 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 827 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 828 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 829 | |
| 830 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 831 | vkQueueWaitIdle(m_device->m_queue ); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 832 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 833 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 834 | FAIL() << "Did not receive Error 'VkQueueSubmit with fence in SIGNALED_STATE'"; |
| 835 | m_errorMonitor->DumpFailureMsgs(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 836 | } |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 837 | } |
| 838 | |
| 839 | TEST_F(VkLayerTest, ResetUnsignaledFence) |
| 840 | { |
| 841 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 842 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 843 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 844 | fenceInfo.pNext = NULL; |
| 845 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 846 | // TODO: verify that this matches layer |
| 847 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARN_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 848 | "submitted to VkResetFences in UNSIGNALED STATE"); |
| 849 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 850 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 851 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 852 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 853 | vkResetFences(m_device->device(), 1, fences); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 854 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 855 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 856 | FAIL() << "Did not receive Error 'VkResetFences with fence in UNSIGNALED_STATE'"; |
| 857 | m_errorMonitor->DumpFailureMsgs(); |
| 858 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 859 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 860 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 861 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 862 | #if 0 |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 863 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 864 | { |
| 865 | // Initiate Draw w/o a PSO bound |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 866 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 867 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 868 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 869 | |
| 870 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 871 | VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 872 | BeginCommandBuffer(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 873 | |
| 874 | const VkExtent3D e3d = { |
| 875 | .width = 128, |
| 876 | .height = 128, |
| 877 | .depth = 1, |
| 878 | }; |
| 879 | const VkImageCreateInfo ici = { |
| 880 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 881 | .pNext = NULL, |
| 882 | .imageType = VK_IMAGE_TYPE_2D, |
| 883 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 884 | .extent = e3d, |
| 885 | .mipLevels = 1, |
| 886 | .arraySize = 1, |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 887 | .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 888 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | 660f0ca | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 889 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 890 | .flags = 0, |
| 891 | }; |
| 892 | |
| 893 | VkImage dsi; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 894 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 895 | VkDepthStencilView dsv; |
| 896 | const VkDepthStencilViewCreateInfo dsvci = { |
| 897 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 898 | .pNext = NULL, |
| 899 | .image = dsi, |
| 900 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 4a26189 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 901 | .baseArrayLayer = 0, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 902 | .arraySize = 1, |
| 903 | .flags = 0, |
| 904 | }; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 905 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 906 | |
| 907 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 908 | FAIL() << "Error received was not 'Invalid usage flag for image...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 909 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 910 | } |
| 911 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 912 | #endif // 0 |
| 913 | #endif // MEM_TRACKER_TESTS |
| 914 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 915 | #if OBJ_TRACKER_TESTS |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 916 | TEST_F(VkLayerTest, PipelineNotBound) |
| 917 | { |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 918 | VkResult err; |
| 919 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 920 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 921 | "Invalid VkPipeline Object "); |
| 922 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 923 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 924 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 925 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 926 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 927 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 928 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 929 | |
| 930 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 931 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 932 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 933 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 934 | ds_pool_ci.poolSizeCount = 1; |
| 935 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 936 | |
| 937 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 938 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 939 | ASSERT_VK_SUCCESS(err); |
| 940 | |
| 941 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 942 | dsl_binding.binding = 0; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 943 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 944 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 945 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 946 | dsl_binding.pImmutableSamplers = NULL; |
| 947 | |
| 948 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 949 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 950 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 951 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 952 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 953 | |
| 954 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 955 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 956 | ASSERT_VK_SUCCESS(err); |
| 957 | |
| 958 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 959 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 960 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 961 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 962 | alloc_info.descriptorPool = ds_pool; |
| 963 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 964 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 965 | ASSERT_VK_SUCCESS(err); |
| 966 | |
| 967 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 968 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 969 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 970 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 971 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 972 | |
| 973 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 974 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 975 | ASSERT_VK_SUCCESS(err); |
| 976 | |
| 977 | VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 978 | |
| 979 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 980 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 981 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 982 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 983 | FAIL() << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be'" << endl; |
| 984 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 985 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 986 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 987 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 988 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 989 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 990 | } |
| 991 | |
| 992 | TEST_F(VkLayerTest, BindInvalidMemory) |
| 993 | { |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 994 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 995 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 996 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 997 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 998 | "Invalid VkDeviceMemory Object "); |
| 999 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1000 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1001 | |
| 1002 | // Create an image, allocate memory, free it, and then try to bind it |
| 1003 | VkImage image; |
| 1004 | VkDeviceMemory mem; |
| 1005 | VkMemoryRequirements mem_reqs; |
| 1006 | |
| 1007 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1008 | const int32_t tex_width = 32; |
| 1009 | const int32_t tex_height = 32; |
| 1010 | |
| 1011 | VkImageCreateInfo image_create_info = {}; |
| 1012 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1013 | image_create_info.pNext = NULL; |
| 1014 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1015 | image_create_info.format = tex_format; |
| 1016 | image_create_info.extent.width = tex_width; |
| 1017 | image_create_info.extent.height = tex_height; |
| 1018 | image_create_info.extent.depth = 1; |
| 1019 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1020 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1021 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1022 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1023 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1024 | image_create_info.flags = 0; |
| 1025 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1026 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1027 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1028 | mem_alloc.pNext = NULL; |
| 1029 | mem_alloc.allocationSize = 0; |
| 1030 | mem_alloc.memoryTypeIndex = 0; |
| 1031 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1032 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1033 | ASSERT_VK_SUCCESS(err); |
| 1034 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1035 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1036 | image, |
| 1037 | &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1038 | |
| 1039 | mem_alloc.allocationSize = mem_reqs.size; |
| 1040 | |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1041 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1042 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1043 | |
| 1044 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1045 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1046 | ASSERT_VK_SUCCESS(err); |
| 1047 | |
| 1048 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1049 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1050 | |
| 1051 | // Try to bind free memory that has been freed |
| 1052 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1053 | // This may very well return an error. |
| 1054 | (void)err; |
| 1055 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1056 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1057 | FAIL() << "Did not receive Error 'Invalid VkDeviceMemory Object 0x<handle>'"; |
| 1058 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1059 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1060 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1061 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1062 | } |
| 1063 | |
| 1064 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) |
| 1065 | { |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1066 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1067 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1068 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1069 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1070 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1071 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1072 | |
| 1073 | // Create an image object, allocate memory, destroy the object and then try to bind it |
| 1074 | VkImage image; |
| 1075 | VkDeviceMemory mem; |
| 1076 | VkMemoryRequirements mem_reqs; |
| 1077 | |
| 1078 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1079 | const int32_t tex_width = 32; |
| 1080 | const int32_t tex_height = 32; |
| 1081 | |
| 1082 | VkImageCreateInfo image_create_info = {}; |
| 1083 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1084 | image_create_info.pNext = NULL; |
| 1085 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1086 | image_create_info.format = tex_format; |
| 1087 | image_create_info.extent.width = tex_width; |
| 1088 | image_create_info.extent.height = tex_height; |
| 1089 | image_create_info.extent.depth = 1; |
| 1090 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1091 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1092 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1093 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1094 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1095 | image_create_info.flags = 0; |
| 1096 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1097 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1098 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1099 | mem_alloc.pNext = NULL; |
| 1100 | mem_alloc.allocationSize = 0; |
| 1101 | mem_alloc.memoryTypeIndex = 0; |
| 1102 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1103 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1104 | ASSERT_VK_SUCCESS(err); |
| 1105 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1106 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1107 | image, |
| 1108 | &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1109 | |
| 1110 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1111 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1112 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1113 | |
| 1114 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1115 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1116 | ASSERT_VK_SUCCESS(err); |
| 1117 | |
| 1118 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1119 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1120 | ASSERT_VK_SUCCESS(err); |
| 1121 | |
| 1122 | // Now Try to bind memory to this destroyed object |
| 1123 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1124 | // This may very well return an error. |
| 1125 | (void) err; |
| 1126 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1127 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1128 | FAIL() << "Did not receive Error 'Invalid VkImage Object 0x<handle>'"; |
| 1129 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1130 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1131 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1132 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1133 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1134 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1135 | #endif // OBJ_TRACKER_TESTS |
| 1136 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1137 | #if DRAW_STATE_TESTS |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1138 | TEST_F(VkLayerTest, LineWidthStateNotBound) |
| 1139 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1140 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1141 | "Dynamic line width state not set for this command buffer"); |
| 1142 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1143 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line width state object is not bound beforehand"); |
| 1144 | |
| 1145 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailLineWidth); |
| 1146 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1147 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1148 | FAIL() << "Did not receive Error 'Dynamic line width state not set for this command buffer'"; |
| 1149 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1150 | } |
| 1151 | } |
| 1152 | |
| 1153 | TEST_F(VkLayerTest, DepthBiasStateNotBound) |
| 1154 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1155 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1156 | "Dynamic depth bias state not set for this command buffer"); |
| 1157 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1158 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bias state object is not bound beforehand"); |
| 1159 | |
| 1160 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBias); |
| 1161 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1162 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1163 | FAIL() << "Did not receive Error 'Dynamic depth bias state not set for this command buffer'"; |
| 1164 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1165 | } |
| 1166 | } |
| 1167 | |
Cody Northrop | 4063c9a | 2015-10-27 16:54:28 -0600 | [diff] [blame] | 1168 | // Disable these two tests until we can sort out how to track multiple layer errors |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1169 | TEST_F(VkLayerTest, ViewportStateNotBound) |
| 1170 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1171 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1172 | "Dynamic viewport state not set for this command buffer"); |
| 1173 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1174 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1175 | |
| 1176 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailViewport); |
| 1177 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1178 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1179 | FAIL() << "Did not recieve Error 'Dynamic scissor state not set for this command buffer'"; |
| 1180 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | TEST_F(VkLayerTest, ScissorStateNotBound) |
| 1185 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1186 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1187 | "Dynamic scissor state not set for this command buffer"); |
| 1188 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1189 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1190 | |
| 1191 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailScissor); |
| 1192 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1193 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1194 | FAIL() << "Did not recieve Error ' Expected: 'Dynamic scissor state not set for this command buffer'"; |
| 1195 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1196 | } |
| 1197 | } |
| 1198 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1199 | TEST_F(VkLayerTest, BlendStateNotBound) |
| 1200 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1201 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1202 | "Dynamic blend object state not set for this command buffer"); |
| 1203 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1204 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend state object is not bound beforehand"); |
| 1205 | |
| 1206 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailBlend); |
| 1207 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1208 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1209 | FAIL() << "Did not recieve Error 'Dynamic blend object state not set for this command buffer'"; |
| 1210 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1211 | } |
| 1212 | } |
| 1213 | |
| 1214 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) |
| 1215 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1216 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1217 | "Dynamic depth bounds state not set for this command buffer"); |
| 1218 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1219 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bounds state object is not bound beforehand"); |
| 1220 | |
| 1221 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBounds); |
| 1222 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1223 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1224 | FAIL() << "Did not receive Error 'Dynamic depth bounds state not set for this command buffer'"; |
| 1225 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1226 | } |
| 1227 | } |
| 1228 | |
| 1229 | TEST_F(VkLayerTest, StencilReadMaskNotSet) |
| 1230 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1231 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1232 | "Dynamic stencil read mask state not set for this command buffer"); |
| 1233 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1234 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1235 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1236 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil read mask is not set beforehand"); |
| 1237 | |
| 1238 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReadMask); |
| 1239 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1240 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1241 | FAIL() << "Did not receive Error 'Dynamic stencil read mask state not set for this command buffer'"; |
| 1242 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1243 | } |
| 1244 | } |
| 1245 | |
| 1246 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) |
| 1247 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1248 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1249 | "Dynamic stencil write mask state not set for this command buffer"); |
| 1250 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1251 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1252 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1253 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil write mask is not set beforehand"); |
| 1254 | |
| 1255 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilWriteMask); |
| 1256 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1257 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1258 | FAIL() << "Did not receive Error 'Dynamic stencil write mask state not set for this command buffer'"; |
| 1259 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1260 | } |
| 1261 | } |
| 1262 | |
| 1263 | TEST_F(VkLayerTest, StencilReferenceNotSet) |
| 1264 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1265 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1266 | "Dynamic stencil reference state not set for this command buffer"); |
| 1267 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1268 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil reference is not set beforehand"); |
| 1269 | |
| 1270 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReference); |
| 1271 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1272 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1273 | FAIL() << "Did not receive Error 'Dynamic stencil reference state not set for this command buffer'"; |
| 1274 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1275 | } |
| 1276 | } |
| 1277 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1278 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1279 | { |
| 1280 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1281 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1282 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1283 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1284 | |
| 1285 | VkFenceCreateInfo fenceInfo = {}; |
| 1286 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1287 | fenceInfo.pNext = NULL; |
| 1288 | fenceInfo.flags = 0; |
| 1289 | |
| 1290 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1291 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1292 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1293 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1294 | // We luck out b/c by default the framework creates CB w/ the VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1295 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1296 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1297 | EndCommandBuffer(); |
| 1298 | |
| 1299 | testFence.init(*m_device, fenceInfo); |
| 1300 | |
| 1301 | // Bypass framework since it does the waits automatically |
| 1302 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1303 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1304 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1305 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1306 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1307 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1308 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1309 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1310 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1311 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1312 | submit_info.pSignalSemaphores = NULL; |
| 1313 | |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1314 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1315 | ASSERT_VK_SUCCESS( err ); |
| 1316 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1317 | // Cause validation error by re-submitting cmd buffer that should only be submitted once |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1318 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1319 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1320 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1321 | FAIL() << "Did not receive Error 'CB (0xaddress) was created w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set...'"; |
| 1322 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1323 | } |
| 1324 | } |
| 1325 | |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1326 | TEST_F(VkLayerTest, BindPipelineNoRenderPass) |
| 1327 | { |
| 1328 | // Initiate Draw w/o a PSO bound |
| 1329 | VkResult err; |
| 1330 | |
| 1331 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1332 | "vkCmdBindPipeline: This call must be issued inside an active render pass"); |
| 1333 | |
| 1334 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1335 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1336 | |
| 1337 | VkDescriptorPoolSize ds_type_count = {}; |
| 1338 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1339 | ds_type_count.descriptorCount = 1; |
| 1340 | |
| 1341 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1342 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1343 | ds_pool_ci.pNext = NULL; |
| 1344 | ds_pool_ci.maxSets = 1; |
| 1345 | ds_pool_ci.poolSizeCount = 1; |
| 1346 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1347 | |
| 1348 | VkDescriptorPool ds_pool; |
| 1349 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1350 | ASSERT_VK_SUCCESS(err); |
| 1351 | |
| 1352 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1353 | dsl_binding.binding = 0; |
| 1354 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1355 | dsl_binding.descriptorCount = 1; |
| 1356 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1357 | dsl_binding.pImmutableSamplers = NULL; |
| 1358 | |
| 1359 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1360 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1361 | ds_layout_ci.pNext = NULL; |
| 1362 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1363 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 7463593 | 2015-12-18 15:35:38 -0700 | [diff] [blame] | 1364 | |
| 1365 | VkDescriptorSetLayout ds_layout; |
| 1366 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 1367 | ASSERT_VK_SUCCESS(err); |
| 1368 | |
| 1369 | VkDescriptorSet descriptorSet; |
| 1370 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 1371 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 1372 | alloc_info.setLayoutCount = 1; |
| 1373 | alloc_info.descriptorPool = ds_pool; |
| 1374 | alloc_info.pSetLayouts = &ds_layout; |
| 1375 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 1376 | ASSERT_VK_SUCCESS(err); |
| 1377 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 1378 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 1379 | pipe_ms_state_ci.pNext = NULL; |
| 1380 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 1381 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 1382 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 1383 | pipe_ms_state_ci.pSampleMask = NULL; |
| 1384 | |
| 1385 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1386 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1387 | pipeline_layout_ci.pNext = NULL; |
| 1388 | pipeline_layout_ci.setLayoutCount = 1; |
| 1389 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1390 | VkPipelineLayout pipeline_layout; |
| 1391 | |
| 1392 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 1393 | ASSERT_VK_SUCCESS(err); |
| 1394 | |
| 1395 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1396 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
| 1397 | // but add it to be able to run on more devices |
| 1398 | VkPipelineObj pipe(m_device); |
| 1399 | pipe.AddShader(&vs); |
| 1400 | pipe.AddShader(&fs); |
| 1401 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 1402 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 1403 | |
| 1404 | // Calls AllocateCommandBuffers |
| 1405 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 1406 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1407 | memset(&cmd_buf_info, 0, sizeof(VkCommandBufferBeginInfo)); |
| 1408 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1409 | cmd_buf_info.pNext = NULL; |
| 1410 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 1411 | |
| 1412 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 1413 | vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1414 | |
| 1415 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1416 | FAIL() << "Did not receive Error 'vkCmdBindPipeline: This call must be issued inside an active render pass'"; |
| 1417 | m_errorMonitor->DumpFailureMsgs(); |
| 1418 | } |
| 1419 | |
| 1420 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1421 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1422 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1423 | } |
| 1424 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1425 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) |
| 1426 | { |
| 1427 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1428 | VkResult err; |
| 1429 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1430 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1431 | "Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
| 1432 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1433 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1434 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1435 | |
| 1436 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1437 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1438 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1439 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1440 | |
| 1441 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1442 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1443 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1444 | ds_pool_ci.flags = 0; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1445 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1446 | ds_pool_ci.poolSizeCount = 1; |
| 1447 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1448 | |
| 1449 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1450 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1451 | ASSERT_VK_SUCCESS(err); |
| 1452 | |
| 1453 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1454 | dsl_binding.binding = 0; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1455 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1456 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1457 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1458 | dsl_binding.pImmutableSamplers = NULL; |
| 1459 | |
| 1460 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1461 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1462 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1463 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1464 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1465 | |
| 1466 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1467 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1468 | ASSERT_VK_SUCCESS(err); |
| 1469 | |
| 1470 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1471 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1472 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1473 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1474 | alloc_info.descriptorPool = ds_pool; |
| 1475 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1476 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1477 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1478 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1479 | FAIL() << "Did not receive Error 'Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER...'"; |
| 1480 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1481 | } |
| 1482 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1483 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1484 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1485 | } |
| 1486 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1487 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) |
| 1488 | { |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1489 | VkResult err; |
| 1490 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1491 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1492 | "It is invalid to call vkFreeDescriptorSets() with a pool created without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
| 1493 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1494 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1495 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1496 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1497 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1498 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1499 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1500 | |
| 1501 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1502 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1503 | ds_pool_ci.pNext = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1504 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1505 | ds_pool_ci.poolSizeCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1506 | ds_pool_ci.flags = 0; |
| 1507 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1508 | // app can only call vkResetDescriptorPool on this pool.; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1509 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1510 | |
| 1511 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1512 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1513 | ASSERT_VK_SUCCESS(err); |
| 1514 | |
| 1515 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1516 | dsl_binding.binding = 0; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1517 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1518 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1519 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1520 | dsl_binding.pImmutableSamplers = NULL; |
| 1521 | |
| 1522 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1523 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1524 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1525 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1526 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1527 | |
| 1528 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1529 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1530 | ASSERT_VK_SUCCESS(err); |
| 1531 | |
| 1532 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1533 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1534 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1535 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1536 | alloc_info.descriptorPool = ds_pool; |
| 1537 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1538 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1539 | ASSERT_VK_SUCCESS(err); |
| 1540 | |
| 1541 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1542 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1543 | FAIL() << "Did not receive Error 'It is invalid to call vkFreeDescriptorSets() with a pool created with...'"; |
| 1544 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1545 | } |
| 1546 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1547 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1548 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1549 | } |
| 1550 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1551 | TEST_F(VkLayerTest, InvalidDescriptorPool) |
| 1552 | { |
| 1553 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1554 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1555 | // Attempt to clear DS Pool with bad object |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1556 | /* |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1557 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1558 | "Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call"); |
| 1559 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1560 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1561 | vkResetDescriptorPool(device(), badPool); |
| 1562 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1563 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1564 | FAIL() << "Did not receive Error 'Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1565 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1566 | }*/ |
| 1567 | } |
| 1568 | |
| 1569 | TEST_F(VkLayerTest, InvalidDescriptorSet) |
| 1570 | { |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1571 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1572 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1573 | // Create a valid cmd buffer |
| 1574 | // call vkCmdBindDescriptorSets w/ false DS |
| 1575 | } |
| 1576 | |
| 1577 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) |
| 1578 | { |
| 1579 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1580 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1581 | } |
| 1582 | |
| 1583 | TEST_F(VkLayerTest, InvalidPipeline) |
| 1584 | { |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1585 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1586 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1587 | // Create a valid cmd buffer |
| 1588 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1589 | // |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1590 | // m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1591 | // "Attempt to bind Pipeline "); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1592 | // |
| 1593 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1594 | // VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1595 | // BeginCommandBuffer(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1596 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1597 | // vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1598 | // |
| 1599 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 1600 | // FAIL() << "Did not receive Error 'Attempt to bind Pipeline 0xbaadb1be that doesn't exist!'"; |
| 1601 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1602 | // } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1603 | } |
| 1604 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1605 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1606 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1607 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on CommandBuffer |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1608 | VkResult err; |
| 1609 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1610 | // TODO: verify that this matches layer |
| 1611 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARN_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1612 | " bound but it was never updated. "); |
| 1613 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1614 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1615 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1616 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1617 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1618 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1619 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1620 | |
| 1621 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1622 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1623 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1624 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1625 | ds_pool_ci.poolSizeCount = 1; |
| 1626 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1627 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1628 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1629 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1630 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1631 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1632 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1633 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1634 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1635 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1636 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1637 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1638 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1639 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1640 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1641 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1642 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1643 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1644 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1645 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1646 | ASSERT_VK_SUCCESS(err); |
| 1647 | |
| 1648 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1649 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1650 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1651 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1652 | alloc_info.descriptorPool = ds_pool; |
| 1653 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1654 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1655 | ASSERT_VK_SUCCESS(err); |
| 1656 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1657 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1658 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1659 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1660 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1661 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1662 | |
| 1663 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1664 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1665 | ASSERT_VK_SUCCESS(err); |
| 1666 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1667 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1668 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 1669 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1670 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1671 | VkPipelineObj pipe(m_device); |
| 1672 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1673 | pipe.AddShader(&fs); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1674 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1675 | |
| 1676 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1677 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1678 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1679 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1680 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1681 | FAIL() << "Did not recieve Warning 'DS <blah> bound but it was never updated. You may want to either update it or not bind it.'"; |
| 1682 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1683 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1684 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1685 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1686 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1687 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1688 | } |
| 1689 | |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1690 | TEST_F(VkLayerTest, InvalidBufferViewObject) |
| 1691 | { |
| 1692 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
| 1693 | VkResult err; |
| 1694 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1695 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1696 | "Attempt to update descriptor with invalid bufferView "); |
| 1697 | |
| 1698 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1699 | VkDescriptorPoolSize ds_type_count = {}; |
| 1700 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1701 | ds_type_count.descriptorCount = 1; |
| 1702 | |
| 1703 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1704 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1705 | ds_pool_ci.pNext = NULL; |
| 1706 | ds_pool_ci.maxSets = 1; |
| 1707 | ds_pool_ci.poolSizeCount = 1; |
| 1708 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1709 | |
| 1710 | VkDescriptorPool ds_pool; |
| 1711 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1712 | ASSERT_VK_SUCCESS(err); |
| 1713 | |
| 1714 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1715 | dsl_binding.binding = 0; |
| 1716 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1717 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1718 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1719 | dsl_binding.pImmutableSamplers = NULL; |
| 1720 | |
| 1721 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1722 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1723 | ds_layout_ci.pNext = NULL; |
| 1724 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1725 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1726 | VkDescriptorSetLayout ds_layout; |
| 1727 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 1728 | ASSERT_VK_SUCCESS(err); |
| 1729 | |
| 1730 | VkDescriptorSet descriptorSet; |
| 1731 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1732 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1733 | alloc_info.setLayoutCount = 1; |
| 1734 | alloc_info.descriptorPool = ds_pool; |
| 1735 | alloc_info.pSetLayouts = &ds_layout; |
| 1736 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 1737 | ASSERT_VK_SUCCESS(err); |
| 1738 | |
| 1739 | VkBufferView view = (VkBufferView) 0xbaadbeef; // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1740 | VkWriteDescriptorSet descriptor_write; |
| 1741 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1742 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1743 | descriptor_write.dstSet = descriptorSet; |
| 1744 | descriptor_write.dstBinding = 0; |
| 1745 | descriptor_write.descriptorCount = 1; |
| 1746 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1747 | descriptor_write.pTexelBufferView = &view; |
| 1748 | |
| 1749 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1750 | |
| 1751 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | 9d80c2d | 2015-11-05 10:27:49 -0700 | [diff] [blame] | 1752 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid bufferView'"; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1753 | m_errorMonitor->DumpFailureMsgs(); |
| 1754 | } |
| 1755 | |
| 1756 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1757 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1758 | } |
| 1759 | |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1760 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1761 | { |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1762 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error cases: |
| 1763 | // 1. No dynamicOffset supplied |
| 1764 | // 2. Too many dynamicOffsets supplied |
| 1765 | // 3. Dynamic offset oversteps buffer being updated |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1766 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1767 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1768 | " requires 1 dynamicOffsets, but only 0 dynamicOffsets are left in pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1769 | |
| 1770 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1771 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1772 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1773 | |
| 1774 | VkDescriptorPoolSize ds_type_count = {}; |
| 1775 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1776 | ds_type_count.descriptorCount = 1; |
| 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 = 1; |
| 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 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1790 | dsl_binding.binding = 0; |
| 1791 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
Jon Ashburn | 4f23258 | 2015-11-06 15:31:44 -0700 | [diff] [blame] | 1792 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1793 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1794 | dsl_binding.pImmutableSamplers = NULL; |
| 1795 | |
| 1796 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1797 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1798 | ds_layout_ci.pNext = NULL; |
| 1799 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1800 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1801 | VkDescriptorSetLayout ds_layout; |
| 1802 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 1803 | ASSERT_VK_SUCCESS(err); |
| 1804 | |
| 1805 | VkDescriptorSet descriptorSet; |
| 1806 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1807 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1808 | alloc_info.setLayoutCount = 1; |
| 1809 | alloc_info.descriptorPool = ds_pool; |
| 1810 | alloc_info.pSetLayouts = &ds_layout; |
| 1811 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 1812 | ASSERT_VK_SUCCESS(err); |
| 1813 | |
| 1814 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1815 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1816 | pipeline_layout_ci.pNext = NULL; |
| 1817 | pipeline_layout_ci.setLayoutCount = 1; |
| 1818 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1819 | |
| 1820 | VkPipelineLayout pipeline_layout; |
| 1821 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 1822 | ASSERT_VK_SUCCESS(err); |
| 1823 | |
| 1824 | // Create a buffer to update the descriptor with |
| 1825 | uint32_t qfi = 0; |
| 1826 | VkBufferCreateInfo buffCI = {}; |
| 1827 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1828 | buffCI.size = 1024; |
| 1829 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1830 | buffCI.queueFamilyIndexCount = 1; |
| 1831 | buffCI.pQueueFamilyIndices = &qfi; |
| 1832 | |
| 1833 | VkBuffer dyub; |
| 1834 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 1835 | ASSERT_VK_SUCCESS(err); |
| 1836 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 1837 | VkDescriptorBufferInfo buffInfo = {}; |
| 1838 | buffInfo.buffer = dyub; |
| 1839 | buffInfo.offset = 0; |
| 1840 | buffInfo.range = 1024; |
| 1841 | |
| 1842 | VkWriteDescriptorSet descriptor_write; |
| 1843 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1844 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1845 | descriptor_write.dstSet = descriptorSet; |
| 1846 | descriptor_write.dstBinding = 0; |
| 1847 | descriptor_write.descriptorCount = 1; |
| 1848 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1849 | descriptor_write.pBufferInfo = &buffInfo; |
| 1850 | |
| 1851 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1852 | |
| 1853 | BeginCommandBuffer(); |
| 1854 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1855 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1856 | FAIL() << "Error received was not 'descriptorSet #0 (0x<ADDR>) requires 1 dynamicOffsets, but only 0 dynamicOffsets are left in pDynamicOffsets array...'"; |
| 1857 | m_errorMonitor->DumpFailureMsgs(); |
| 1858 | } |
| 1859 | uint32_t pDynOff[2] = {512, 756}; |
| 1860 | // Now cause error b/c too many dynOffsets in array for # of dyn descriptors |
| 1861 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1862 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
| 1863 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptorSet, 2, pDynOff); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1864 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1865 | FAIL() << "Error received was not 'Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but dynamicOffsetCount is 0...'"; |
| 1866 | m_errorMonitor->DumpFailureMsgs(); |
| 1867 | } |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1868 | // Finally cause error due to dynamicOffset being too big |
| 1869 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1870 | " from its update, this oversteps its buffer ("); |
| 1871 | // Create PSO to be used for draw-time errors below |
| 1872 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1873 | "#version 400\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1874 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 1875 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 1876 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1877 | "out gl_PerVertex { \n" |
| 1878 | " vec4 gl_Position;\n" |
| 1879 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1880 | "void main(){\n" |
| 1881 | " gl_Position = vec4(1);\n" |
| 1882 | "}\n"; |
| 1883 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1884 | "#version 400\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1885 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 1886 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 1887 | "\n" |
| 1888 | "layout(location=0) out vec4 x;\n" |
| 1889 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 1890 | "void main(){\n" |
| 1891 | " x = vec4(bar.y);\n" |
| 1892 | "}\n"; |
| 1893 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1894 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 1895 | VkPipelineObj pipe(m_device); |
| 1896 | pipe.AddShader(&vs); |
| 1897 | pipe.AddShader(&fs); |
| 1898 | pipe.AddColorAttachment(); |
| 1899 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 1900 | |
| 1901 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1902 | // This update should succeed, but offset size of 512 will overstep buffer /w range 1024 & size 1024 |
| 1903 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptorSet, 1, pDynOff); |
| 1904 | Draw(1, 0, 0, 0); |
| 1905 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1906 | FAIL() << "Error received was not 'VkDescriptorSet (0x<ADDR>) bound as set #0 has dynamic offset 512. Combined with offet 0 and range 1024 from its update, this oversteps...'"; |
| 1907 | m_errorMonitor->DumpFailureMsgs(); |
| 1908 | } |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1909 | |
| 1910 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1911 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1912 | } |
| 1913 | |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1914 | TEST_F(VkLayerTest, DescriptorSetCompatibility) |
| 1915 | { |
| 1916 | // Test various desriptorSet errors with bad binding combinations |
| 1917 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1918 | |
| 1919 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1920 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1921 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1922 | |
| 1923 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 1924 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
| 1925 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1926 | ds_type_count[0].descriptorCount = 10; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1927 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 1928 | ds_type_count[1].descriptorCount = 2; |
| 1929 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 1930 | ds_type_count[2].descriptorCount = 2; |
| 1931 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1932 | ds_type_count[3].descriptorCount = 5; |
| 1933 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT type |
| 1934 | //ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 1935 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 1936 | ds_type_count[4].descriptorCount = 2; |
| 1937 | |
| 1938 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1939 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1940 | ds_pool_ci.pNext = NULL; |
| 1941 | ds_pool_ci.maxSets = 1; |
| 1942 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 1943 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 1944 | |
| 1945 | VkDescriptorPool ds_pool; |
| 1946 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1947 | ASSERT_VK_SUCCESS(err); |
| 1948 | |
| 1949 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 1950 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
| 1951 | dsl_binding[0].binding = 0; |
| 1952 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1953 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1954 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 1955 | dsl_binding[0].pImmutableSamplers = NULL; |
| 1956 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1957 | // Create layout identical to set0 layout but w/ different stageFlags |
| 1958 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
| 1959 | dsl_fs_stage_only.binding = 0; |
| 1960 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1961 | dsl_fs_stage_only.descriptorCount = 5; |
| 1962 | dsl_fs_stage_only.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at bind time |
| 1963 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1964 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1965 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1966 | ds_layout_ci.pNext = NULL; |
| 1967 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1968 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1969 | static const uint32_t NUM_LAYOUTS = 4; |
| 1970 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1971 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
| 1972 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only layout for error case |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1973 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[0]); |
| 1974 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1975 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1976 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout_fs_only); |
| 1977 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1978 | dsl_binding[0].binding = 0; |
| 1979 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1980 | dsl_binding[0].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1981 | dsl_binding[0].binding = 1; |
| 1982 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1983 | dsl_binding[0].descriptorCount = 2; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1984 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1985 | ds_layout_ci.bindingCount = 2; |
| 1986 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[1]); |
| 1987 | ASSERT_VK_SUCCESS(err); |
| 1988 | dsl_binding[0].binding = 0; |
| 1989 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1990 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1991 | ds_layout_ci.bindingCount = 1; |
| 1992 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[2]); |
| 1993 | ASSERT_VK_SUCCESS(err); |
| 1994 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1995 | dsl_binding[0].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1996 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[3]); |
| 1997 | ASSERT_VK_SUCCESS(err); |
| 1998 | |
| 1999 | static const uint32_t NUM_SETS = 4; |
| 2000 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 2001 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2002 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2003 | alloc_info.setLayoutCount = NUM_LAYOUTS; |
| 2004 | alloc_info.descriptorPool = ds_pool; |
| 2005 | alloc_info.pSetLayouts = ds_layout; |
| 2006 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, descriptorSet); |
| 2007 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2008 | VkDescriptorSet ds0_fs_only = {}; |
| 2009 | alloc_info.setLayoutCount = 1; |
| 2010 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
| 2011 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
| 2012 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2013 | |
| 2014 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2015 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2016 | pipeline_layout_ci.pNext = NULL; |
| 2017 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 2018 | pipeline_layout_ci.pSetLayouts = ds_layout; |
| 2019 | |
| 2020 | VkPipelineLayout pipeline_layout; |
| 2021 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 2022 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2023 | // Create pipelineLayout with only one setLayout |
| 2024 | pipeline_layout_ci.setLayoutCount = 1; |
| 2025 | VkPipelineLayout single_pipe_layout; |
| 2026 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &single_pipe_layout); |
| 2027 | ASSERT_VK_SUCCESS(err); |
| 2028 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 2029 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 2030 | VkPipelineLayout pipe_layout_one_desc; |
| 2031 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipe_layout_one_desc); |
| 2032 | ASSERT_VK_SUCCESS(err); |
| 2033 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 2034 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 2035 | VkPipelineLayout pipe_layout_five_samp; |
| 2036 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipe_layout_five_samp); |
| 2037 | ASSERT_VK_SUCCESS(err); |
| 2038 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 2039 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 2040 | VkPipelineLayout pipe_layout_fs_only; |
| 2041 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipe_layout_fs_only); |
| 2042 | ASSERT_VK_SUCCESS(err); |
| 2043 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 2044 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 2045 | pl_bad_s0[0] = ds_layout_fs_only; |
| 2046 | pl_bad_s0[1] = ds_layout[1]; |
| 2047 | pipeline_layout_ci.setLayoutCount = 2; |
| 2048 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 2049 | VkPipelineLayout pipe_layout_bad_set0; |
| 2050 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipe_layout_bad_set0); |
| 2051 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2052 | |
| 2053 | // Create a buffer to update the descriptor with |
| 2054 | uint32_t qfi = 0; |
| 2055 | VkBufferCreateInfo buffCI = {}; |
| 2056 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2057 | buffCI.size = 1024; |
| 2058 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 2059 | buffCI.queueFamilyIndexCount = 1; |
| 2060 | buffCI.pQueueFamilyIndices = &qfi; |
| 2061 | |
| 2062 | VkBuffer dyub; |
| 2063 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 2064 | ASSERT_VK_SUCCESS(err); |
| 2065 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 2066 | static const uint32_t NUM_BUFFS = 5; |
| 2067 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
| 2068 | for (uint32_t i=0; i<NUM_BUFFS; ++i) { |
| 2069 | buffInfo[i].buffer = dyub; |
| 2070 | buffInfo[i].offset = 0; |
| 2071 | buffInfo[i].range = 1024; |
| 2072 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2073 | VkImage image; |
| 2074 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2075 | const int32_t tex_width = 32; |
| 2076 | const int32_t tex_height = 32; |
| 2077 | VkImageCreateInfo image_create_info = {}; |
| 2078 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2079 | image_create_info.pNext = NULL; |
| 2080 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2081 | image_create_info.format = tex_format; |
| 2082 | image_create_info.extent.width = tex_width; |
| 2083 | image_create_info.extent.height = tex_height; |
| 2084 | image_create_info.extent.depth = 1; |
| 2085 | image_create_info.mipLevels = 1; |
| 2086 | image_create_info.arrayLayers = 1; |
| 2087 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2088 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2089 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2090 | image_create_info.flags = 0; |
| 2091 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 2092 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2093 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2094 | VkImageViewCreateInfo image_view_create_info = {}; |
| 2095 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2096 | image_view_create_info.image = image; |
| 2097 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2098 | image_view_create_info.format = tex_format; |
| 2099 | image_view_create_info.subresourceRange.layerCount = 1; |
| 2100 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 2101 | image_view_create_info.subresourceRange.levelCount = 1; |
| 2102 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2103 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2104 | VkImageView view; |
| 2105 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
| 2106 | ASSERT_VK_SUCCESS(err); |
| 2107 | VkDescriptorImageInfo imageInfo[2] = {}; |
| 2108 | imageInfo[0].imageView = view; |
| 2109 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2110 | imageInfo[1].imageView = view; |
| 2111 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2112 | |
| 2113 | static const uint32_t NUM_SET_UPDATES = 3; |
| 2114 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 2115 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2116 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 2117 | descriptor_write[0].dstBinding = 0; |
| 2118 | descriptor_write[0].descriptorCount = 5; |
| 2119 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2120 | descriptor_write[0].pBufferInfo = buffInfo; |
| 2121 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2122 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 2123 | descriptor_write[1].dstBinding = 0; |
| 2124 | descriptor_write[1].descriptorCount = 2; |
| 2125 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 2126 | descriptor_write[1].pImageInfo = imageInfo; |
| 2127 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2128 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 2129 | descriptor_write[2].dstBinding = 1; |
| 2130 | descriptor_write[2].descriptorCount = 2; |
| 2131 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 2132 | descriptor_write[2].pImageInfo = imageInfo; |
| 2133 | |
| 2134 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2135 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2136 | // Create PSO to be used for draw-time errors below |
| 2137 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2138 | "#version 400\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2139 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 2140 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 2141 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2142 | "out gl_PerVertex {\n" |
| 2143 | " vec4 gl_Position;\n" |
| 2144 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2145 | "void main(){\n" |
| 2146 | " gl_Position = vec4(1);\n" |
| 2147 | "}\n"; |
| 2148 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2149 | "#version 400\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2150 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 2151 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 2152 | "\n" |
| 2153 | "layout(location=0) out vec4 x;\n" |
| 2154 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 2155 | "void main(){\n" |
| 2156 | " x = vec4(bar.y);\n" |
| 2157 | "}\n"; |
| 2158 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2159 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2160 | VkPipelineObj pipe(m_device); |
| 2161 | pipe.AddShader(&vs); |
| 2162 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2163 | pipe.AddColorAttachment(); |
| 2164 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2165 | |
| 2166 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2167 | |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2168 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2169 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding of PSO |
| 2170 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of cmd_pipeline.c |
| 2171 | // due to the fact that cmd_alloc_dset_data() has not been called in cmd_bind_graphics_pipeline() |
| 2172 | // TODO : Want to cause various binding incompatibility issues here to test DrawState |
| 2173 | // First cause various verify_layout_compatibility() fails |
| 2174 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2175 | // verify_set_layout_compatibility fail cases: |
| 2176 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2177 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " due to: invalid VkPipelineLayout "); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2178 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, (VkPipelineLayout)0xbaadb1be, 0, 1, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2179 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2180 | FAIL() << "Did not receive correct error msg when attempting to bind descriptorSets with invalid VkPipelineLayout."; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2181 | m_errorMonitor->DumpFailureMsgs(); |
| 2182 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2183 | // 2. layoutIndex exceeds # of layouts in layout |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2184 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " attempting to bind set to index 1"); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2185 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2186 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2187 | FAIL() << "Did not receive correct error msg when attempting to bind descriptorSet to index 1 when pipelineLayout only has index 0."; |
| 2188 | m_errorMonitor->DumpFailureMsgs(); |
| 2189 | } |
| 2190 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
| 2191 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 descriptors |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2192 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, ", but corresponding set being bound has 5 descriptors."); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2193 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
| 2194 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2195 | FAIL() << "Did not receive correct error msg when attempting to bind descriptorSet w/ 5 descriptors to pipelineLayout with only 2 descriptors."; |
| 2196 | m_errorMonitor->DumpFailureMsgs(); |
| 2197 | } |
| 2198 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 2199 | // 4. same # of descriptors but mismatch in type |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2200 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " descriptor from pipelineLayout is type 'VK_DESCRIPTOR_TYPE_SAMPLER'"); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2201 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
| 2202 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2203 | FAIL() << "Did not receive correct error msg when attempting to bind UNIFORM_BUFFER descriptorSet to pipelineLayout with overlapping SAMPLER type."; |
| 2204 | m_errorMonitor->DumpFailureMsgs(); |
| 2205 | } |
| 2206 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 2207 | // 5. same # of descriptors but mismatch in stageFlags |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2208 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " descriptor from pipelineLayout has stageFlags "); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2209 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
| 2210 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2211 | FAIL() << "Did not receive correct error msg when attempting to bind UNIFORM_BUFFER descriptorSet with ALL stageFlags to pipelineLayout with FS-only stageFlags."; |
| 2212 | m_errorMonitor->DumpFailureMsgs(); |
| 2213 | } |
| 2214 | // Cause INFO messages due to disturbing previously bound Sets |
| 2215 | // First bind sets 0 & 1 |
| 2216 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2217 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2218 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERF_WARN_BIT_EXT, " previously bound as set #0 was disturbed "); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2219 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 2220 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2221 | FAIL() << "Did not receive correct info msg when binding Set1 w/ pipelineLayout that should disturb Set0."; |
| 2222 | m_errorMonitor->DumpFailureMsgs(); |
| 2223 | } |
| 2224 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
| 2225 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2226 | // 2. Disturb set after last bound set |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2227 | 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 | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2228 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
| 2229 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2230 | FAIL() << "Did not receive correct info msg when re-binding Set0 w/ pipelineLayout that should disturb Set1."; |
| 2231 | m_errorMonitor->DumpFailureMsgs(); |
| 2232 | } |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2233 | |
| 2234 | // Cause draw-time errors due to PSO incompatibilities |
| 2235 | // 1. Error due to not binding required set (we actually use same code as above to disturb set0) |
| 2236 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2237 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2238 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2239 | Draw(1, 0, 0, 0); |
| 2240 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2241 | FAIL() << "Did not receive correct error msg when attempting draw requiring Set0 but Set0 is not bound."; |
| 2242 | m_errorMonitor->DumpFailureMsgs(); |
| 2243 | } |
| 2244 | // 2. Error due to bound set not being compatible with PSO's VkPipelineLayout (diff stageFlags in this case) |
| 2245 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, &descriptorSet[0], 0, NULL); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2246 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2247 | Draw(1, 0, 0, 0); |
| 2248 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2249 | FAIL() << "Did not receive correct error msg when attempted draw where bound Set0 layout is not compatible PSO Set0 layout."; |
| 2250 | m_errorMonitor->DumpFailureMsgs(); |
| 2251 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2252 | // Remaining clean-up |
| 2253 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
| 2254 | for (uint32_t i=0; i<NUM_LAYOUTS; ++i) { |
| 2255 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 2256 | } |
| 2257 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
| 2258 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, descriptorSet); |
| 2259 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2260 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2261 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2262 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2263 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2264 | TEST_F(VkLayerTest, NoBeginCommandBuffer) |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2265 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2266 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2267 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2268 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2269 | |
| 2270 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2271 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2272 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2273 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2274 | |
| 2275 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2276 | FAIL() << "Did not recieve Error 'You must call vkBeginCommandBuffer() before this call to vkEndCommandBuffer()'"; |
| 2277 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2278 | } |
| 2279 | } |
| 2280 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2281 | TEST_F(VkLayerTest, PrimaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2282 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2283 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2284 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2285 | "may not specify framebuffer or renderpass parameters"); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2286 | |
| 2287 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2288 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2289 | // Calls AllocateCommandBuffers |
| 2290 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2291 | |
| 2292 | // Force the failure by setting the Renderpass and Framebuffer fields with (fake) data |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2293 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 2294 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2295 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2296 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2297 | cmd_buf_info.renderPass = (VkRenderPass)0xcadecade; |
| 2298 | cmd_buf_info.framebuffer = (VkFramebuffer)0xcadecade; |
| 2299 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2300 | |
| 2301 | // The error should be caught by validation of the BeginCommandBuffer call |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2302 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2303 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2304 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2305 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Primary Command Buffer may not specify framebuffer or renderpass parameters'"; |
| 2306 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2307 | } |
| 2308 | } |
| 2309 | |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 2310 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2311 | { |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2312 | VkResult err; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2313 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2314 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2315 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 2316 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2317 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2318 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2319 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2320 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2321 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2322 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2323 | cmd.commandPool = m_commandPool; |
| 2324 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2325 | cmd.bufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2326 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2327 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2328 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2329 | |
| 2330 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2331 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 2332 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2333 | cmd_buf_info.pNext = NULL; |
Tobin Ehlis | 651d9b0 | 2015-12-16 05:01:22 -0700 | [diff] [blame] | 2334 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2335 | |
| 2336 | // The error should be caught by validation of the BeginCommandBuffer call |
| 2337 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 2338 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2339 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 2340 | FAIL() << "Did not receive Error 'vkBeginCommandBuffer(): Secondary Command Buffers (0x<ADDR>) must specify a valid renderpass parameter.'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2341 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2342 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2343 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2344 | } |
| 2345 | |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2346 | TEST_F(VkLayerTest, CommandBufferResetErrors) |
| 2347 | { |
| 2348 | // Cause error due to Begin while recording CB |
| 2349 | // Then cause 2 errors for attempting to reset CB w/o having |
| 2350 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 2351 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2352 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2353 | "Cannot call Begin on CB"); |
| 2354 | |
| 2355 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2356 | |
| 2357 | // Calls AllocateCommandBuffers |
| 2358 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 2359 | |
| 2360 | // Force the failure by setting the Renderpass and Framebuffer fields with (fake) data |
| 2361 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 2362 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2363 | cmd_buf_info.pNext = NULL; |
| 2364 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 2365 | |
| 2366 | // Begin CB to transition to recording state |
| 2367 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2368 | // Can't re-begin. This should trigger error |
| 2369 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2370 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2371 | FAIL() << "Did not receive Error 'Cannot call Begin on CB (0x<ADDR>) in the RECORDING state...'"; |
| 2372 | m_errorMonitor->DumpFailureMsgs(); |
| 2373 | } |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2374 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2375 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 2376 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 2377 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
| 2378 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2379 | FAIL() << "Did not receive Error 'Attempt to reset command buffer (0x<ADDR>) created from command pool...'"; |
| 2380 | m_errorMonitor->DumpFailureMsgs(); |
| 2381 | } |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2382 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2383 | // Transition CB to RECORDED state |
| 2384 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 2385 | // Now attempting to Begin will implicitly reset, which triggers error |
| 2386 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2387 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2388 | FAIL() << "Did not receive Error 'Call to vkBeginCommandBuffer() on command buffer (0x<ADDR>) attempts to implicitly reset...'"; |
| 2389 | m_errorMonitor->DumpFailureMsgs(); |
| 2390 | } |
| 2391 | } |
| 2392 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2393 | TEST_F(VkLayerTest, InvalidPipelineCreateState) |
| 2394 | { |
| 2395 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2396 | VkResult err; |
| 2397 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2398 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2399 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 2400 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2401 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2402 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2403 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2404 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2405 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2406 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2407 | |
| 2408 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2409 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2410 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2411 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2412 | ds_pool_ci.poolSizeCount = 1; |
| 2413 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2414 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2415 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2416 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2417 | ASSERT_VK_SUCCESS(err); |
| 2418 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2419 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2420 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2421 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2422 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2423 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2424 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2425 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2426 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2427 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2428 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2429 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2430 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2431 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2432 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2433 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2434 | ASSERT_VK_SUCCESS(err); |
| 2435 | |
| 2436 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2437 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2438 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2439 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2440 | alloc_info.descriptorPool = ds_pool; |
| 2441 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2442 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2443 | ASSERT_VK_SUCCESS(err); |
| 2444 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2445 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2446 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2447 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2448 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2449 | |
| 2450 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2451 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2452 | ASSERT_VK_SUCCESS(err); |
| 2453 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2454 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2455 | VkRect2D sc = {}; // dummy scissor to point to |
| 2456 | |
| 2457 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2458 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2459 | vp_state_ci.scissorCount = 1; |
| 2460 | vp_state_ci.pScissors = ≻ |
| 2461 | vp_state_ci.viewportCount = 1; |
| 2462 | vp_state_ci.pViewports = &vp; |
| 2463 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2464 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2465 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2466 | gp_ci.pViewportState = &vp_state_ci; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2467 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2468 | gp_ci.layout = pipeline_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2469 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2470 | |
| 2471 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2472 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 2473 | pc_ci.initialDataSize = 0; |
| 2474 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2475 | |
| 2476 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2477 | VkPipelineCache pipelineCache; |
| 2478 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2479 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2480 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2481 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2482 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2483 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2484 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: Vtx Shader required'"; |
| 2485 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2486 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2487 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2488 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2489 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2490 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2491 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2492 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2493 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 2494 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 2495 | { |
| 2496 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2497 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2498 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2499 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2500 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive "); |
| 2501 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2502 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2503 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2504 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2505 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2506 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2507 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2508 | |
| 2509 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2510 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2511 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2512 | ds_pool_ci.poolSizeCount = 1; |
| 2513 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2514 | |
| 2515 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2516 | err = vkCreateDescriptorPool(m_device->device(), VK_DESCRIPTOR_POOL_USAGE_NON_FREE, 1, &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2517 | ASSERT_VK_SUCCESS(err); |
| 2518 | |
| 2519 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2520 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2521 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2522 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2523 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2524 | dsl_binding.pImmutableSamplers = NULL; |
| 2525 | |
| 2526 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2527 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2528 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2529 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2530 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2531 | |
| 2532 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2533 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2534 | ASSERT_VK_SUCCESS(err); |
| 2535 | |
| 2536 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2537 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2538 | ASSERT_VK_SUCCESS(err); |
| 2539 | |
| 2540 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2541 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2542 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2543 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2544 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2545 | |
| 2546 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2547 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2548 | ASSERT_VK_SUCCESS(err); |
| 2549 | |
| 2550 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 2551 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 2552 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2553 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2554 | // Just using VS txt for Tess shaders as we don't care about functionality |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2555 | VkShaderObj tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 2556 | VkShaderObj te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2557 | |
| 2558 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2559 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2560 | shaderStages[0].shader = vs.handle(); |
| 2561 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2562 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2563 | shaderStages[1].shader = tc.handle(); |
| 2564 | shaderStages[2].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2565 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2566 | shaderStages[2].shader = te.handle(); |
| 2567 | |
| 2568 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
| 2569 | iaCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2570 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2571 | |
| 2572 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 2573 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 2574 | tsCI.patchControlPoints = 0; // This will cause an error |
| 2575 | |
| 2576 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2577 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2578 | gp_ci.pNext = NULL; |
| 2579 | gp_ci.stageCount = 3; |
| 2580 | gp_ci.pStages = shaderStages; |
| 2581 | gp_ci.pVertexInputState = NULL; |
| 2582 | gp_ci.pInputAssemblyState = &iaCI; |
| 2583 | gp_ci.pTessellationState = &tsCI; |
| 2584 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2585 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2586 | gp_ci.pMultisampleState = NULL; |
| 2587 | gp_ci.pDepthStencilState = NULL; |
| 2588 | gp_ci.pColorBlendState = NULL; |
| 2589 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2590 | gp_ci.layout = pipeline_layout; |
| 2591 | gp_ci.renderPass = renderPass(); |
| 2592 | |
| 2593 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2594 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2595 | pc_ci.pNext = NULL; |
| 2596 | pc_ci.initialSize = 0; |
| 2597 | pc_ci.initialData = 0; |
| 2598 | pc_ci.maxSize = 0; |
| 2599 | |
| 2600 | VkPipeline pipeline; |
| 2601 | VkPipelineCache pipelineCache; |
| 2602 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2603 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2604 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2605 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2606 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2607 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2608 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive...'"; |
| 2609 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2610 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2611 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2612 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2613 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2614 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2615 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2616 | } |
| 2617 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2618 | // Set scissor and viewport counts to different numbers |
| 2619 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) |
| 2620 | { |
| 2621 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2622 | VkResult err; |
| 2623 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2624 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2625 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2626 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2627 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2628 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2629 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2630 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2631 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2632 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2633 | |
| 2634 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2635 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2636 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2637 | ds_pool_ci.poolSizeCount = 1; |
| 2638 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2639 | |
| 2640 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2641 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2642 | ASSERT_VK_SUCCESS(err); |
| 2643 | |
| 2644 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2645 | dsl_binding.binding = 0; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2646 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2647 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2648 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2649 | |
| 2650 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2651 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2652 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2653 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2654 | |
| 2655 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2656 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2657 | ASSERT_VK_SUCCESS(err); |
| 2658 | |
| 2659 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2660 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2661 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2662 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2663 | alloc_info.descriptorPool = ds_pool; |
| 2664 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2665 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2666 | ASSERT_VK_SUCCESS(err); |
| 2667 | |
| 2668 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2669 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2670 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2671 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2672 | |
| 2673 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2674 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2675 | ASSERT_VK_SUCCESS(err); |
| 2676 | |
| 2677 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2678 | |
| 2679 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2680 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2681 | vp_state_ci.scissorCount = 0; |
| 2682 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2683 | vp_state_ci.pViewports = &vp; |
| 2684 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2685 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2686 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2687 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2688 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2689 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2690 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2691 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2692 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2693 | |
| 2694 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2695 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2696 | gp_ci.stageCount = 2; |
| 2697 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2698 | gp_ci.pViewportState = &vp_state_ci; |
| 2699 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2700 | gp_ci.layout = pipeline_layout; |
| 2701 | gp_ci.renderPass = renderPass(); |
| 2702 | |
| 2703 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2704 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2705 | |
| 2706 | VkPipeline pipeline; |
| 2707 | VkPipelineCache pipelineCache; |
| 2708 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2709 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2710 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2711 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2712 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2713 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2714 | FAIL() << "Did not receive Error 'Gfx Pipeline viewport count (1) must match scissor count (0).'"; |
| 2715 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2716 | } |
| 2717 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2718 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2719 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2720 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2721 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2722 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2723 | // Don't set viewport state in PSO. This is an error b/c we always need this state |
| 2724 | // for the counts even if the data is going to be set dynamically. |
| 2725 | TEST_F(VkLayerTest, PSOViewportStateNotSet) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2726 | { |
| 2727 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2728 | VkResult err; |
| 2729 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2730 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2731 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2732 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2733 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2734 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2735 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2736 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2737 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2738 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2739 | |
| 2740 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2741 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2742 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2743 | ds_pool_ci.poolSizeCount = 1; |
| 2744 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2745 | |
| 2746 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2747 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2748 | ASSERT_VK_SUCCESS(err); |
| 2749 | |
| 2750 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2751 | dsl_binding.binding = 0; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2752 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2753 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2754 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2755 | |
| 2756 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2757 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2758 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2759 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2760 | |
| 2761 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2762 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2763 | ASSERT_VK_SUCCESS(err); |
| 2764 | |
| 2765 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2766 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2767 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2768 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2769 | alloc_info.descriptorPool = ds_pool; |
| 2770 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2771 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2772 | ASSERT_VK_SUCCESS(err); |
| 2773 | |
| 2774 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2775 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2776 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2777 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2778 | |
| 2779 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2780 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2781 | ASSERT_VK_SUCCESS(err); |
| 2782 | |
| 2783 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2784 | // Set scissor as dynamic to avoid second error |
| 2785 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2786 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2787 | dyn_state_ci.dynamicStateCount = 1; |
| 2788 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2789 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2790 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2791 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2792 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2793 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2794 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2795 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2796 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2797 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2798 | |
| 2799 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2800 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2801 | gp_ci.stageCount = 2; |
| 2802 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2803 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state should cause validation error |
| 2804 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2805 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2806 | gp_ci.layout = pipeline_layout; |
| 2807 | gp_ci.renderPass = renderPass(); |
| 2808 | |
| 2809 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2810 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2811 | |
| 2812 | VkPipeline pipeline; |
| 2813 | VkPipelineCache pipelineCache; |
| 2814 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2815 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2816 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2817 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2818 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2819 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2820 | FAIL() << "Did not receive Error 'Gfx Pipeline pViewportState is null. Even if...'"; |
| 2821 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2822 | } |
| 2823 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2824 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2825 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2826 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2827 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2828 | } |
| 2829 | // Create PSO w/o non-zero viewportCount but no viewport data |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2830 | // Then run second test where dynamic scissor count doesn't match PSO scissor count |
| 2831 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2832 | { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2833 | VkResult err; |
| 2834 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2835 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2836 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 2837 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2838 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2839 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2840 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2841 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2842 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2843 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2844 | |
| 2845 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2846 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2847 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2848 | ds_pool_ci.poolSizeCount = 1; |
| 2849 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2850 | |
| 2851 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2852 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2853 | ASSERT_VK_SUCCESS(err); |
| 2854 | |
| 2855 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2856 | dsl_binding.binding = 0; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2857 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2858 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2859 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2860 | |
| 2861 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2862 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2863 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2864 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2865 | |
| 2866 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2867 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2868 | ASSERT_VK_SUCCESS(err); |
| 2869 | |
| 2870 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2871 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2872 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2873 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2874 | alloc_info.descriptorPool = ds_pool; |
| 2875 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2876 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2877 | ASSERT_VK_SUCCESS(err); |
| 2878 | |
| 2879 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2880 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2881 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2882 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2883 | |
| 2884 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2885 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2886 | ASSERT_VK_SUCCESS(err); |
| 2887 | |
| 2888 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2889 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2890 | vp_state_ci.viewportCount = 1; |
| 2891 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2892 | vp_state_ci.scissorCount = 1; |
| 2893 | vp_state_ci.pScissors = NULL; // Scissor is dynamic (below) so this won't cause error |
| 2894 | |
| 2895 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2896 | // Set scissor as dynamic to avoid that error |
| 2897 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2898 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2899 | dyn_state_ci.dynamicStateCount = 1; |
| 2900 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2901 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2902 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2903 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2904 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2905 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2906 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2907 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2908 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2909 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2910 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2911 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2912 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2913 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2914 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2915 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2916 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2917 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2918 | |
| 2919 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2920 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2921 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2922 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2923 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2924 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2925 | rs_ci.pNext = nullptr; |
| 2926 | |
| 2927 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2928 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2929 | cb_ci.pNext = nullptr; |
| 2930 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2931 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2932 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2933 | gp_ci.stageCount = 2; |
| 2934 | gp_ci.pStages = shaderStages; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2935 | gp_ci.pVertexInputState = &vi_ci; |
| 2936 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2937 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2938 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2939 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2940 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2941 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2942 | gp_ci.layout = pipeline_layout; |
| 2943 | gp_ci.renderPass = renderPass(); |
| 2944 | |
| 2945 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2946 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2947 | |
| 2948 | VkPipeline pipeline; |
| 2949 | VkPipelineCache pipelineCache; |
| 2950 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2951 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2952 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2953 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2954 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2955 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2956 | FAIL() << "Did not recieve Error 'Gfx Pipeline viewportCount is 1, but pViewports is NULL...'"; |
| 2957 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2958 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2959 | |
| 2960 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2961 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2962 | // First need to successfully create the PSO from above by setting pViewports |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2963 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2964 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1. These counts must match."); |
| 2965 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2966 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2967 | vp_state_ci.pViewports = &vp; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2968 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2969 | ASSERT_VK_SUCCESS(err); |
| 2970 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2971 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2972 | VkRect2D scissors[2] = {}; // don't care about data |
| 2973 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 2974 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2975 | Draw(1, 0, 0, 0); |
| 2976 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2977 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2978 | FAIL() << "Did not receive Error 'Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1...'"; |
| 2979 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2980 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2981 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2982 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2983 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2984 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2985 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2986 | } |
| 2987 | // Create PSO w/o non-zero scissorCount but no scissor data |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2988 | // Then run second test where dynamic viewportCount doesn't match PSO viewportCount |
| 2989 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2990 | { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2991 | VkResult err; |
| 2992 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2993 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2994 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 2995 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2996 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2997 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2998 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2999 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3000 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3001 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3002 | |
| 3003 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3004 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3005 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3006 | ds_pool_ci.poolSizeCount = 1; |
| 3007 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3008 | |
| 3009 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3010 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3011 | ASSERT_VK_SUCCESS(err); |
| 3012 | |
| 3013 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3014 | dsl_binding.binding = 0; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3015 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3016 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3017 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3018 | |
| 3019 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3020 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3021 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3022 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3023 | |
| 3024 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3025 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3026 | ASSERT_VK_SUCCESS(err); |
| 3027 | |
| 3028 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3029 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3030 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3031 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3032 | alloc_info.descriptorPool = ds_pool; |
| 3033 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3034 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3035 | ASSERT_VK_SUCCESS(err); |
| 3036 | |
| 3037 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3038 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3039 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3040 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3041 | |
| 3042 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3043 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3044 | ASSERT_VK_SUCCESS(err); |
| 3045 | |
| 3046 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 3047 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3048 | vp_state_ci.scissorCount = 1; |
| 3049 | vp_state_ci.pScissors = NULL; // Null scissor w/ count of 1 should cause error |
| 3050 | vp_state_ci.viewportCount = 1; |
| 3051 | vp_state_ci.pViewports = NULL; // vp is dynamic (below) so this won't cause error |
| 3052 | |
| 3053 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 3054 | // Set scissor as dynamic to avoid that error |
| 3055 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 3056 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3057 | dyn_state_ci.dynamicStateCount = 1; |
| 3058 | dyn_state_ci.pDynamicStates = &vp_state; |
| 3059 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3060 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 3061 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3062 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3063 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3064 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3065 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3066 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3067 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3068 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3069 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 3070 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 3071 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3072 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3073 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3074 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3075 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 3076 | |
| 3077 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 3078 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 3079 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 3080 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3081 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3082 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3083 | rs_ci.pNext = nullptr; |
| 3084 | |
| 3085 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 3086 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 3087 | cb_ci.pNext = nullptr; |
| 3088 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3089 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 3090 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3091 | gp_ci.stageCount = 2; |
| 3092 | gp_ci.pStages = shaderStages; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3093 | gp_ci.pVertexInputState = &vi_ci; |
| 3094 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3095 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3096 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3097 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3098 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3099 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3100 | gp_ci.layout = pipeline_layout; |
| 3101 | gp_ci.renderPass = renderPass(); |
| 3102 | |
| 3103 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 3104 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3105 | |
| 3106 | VkPipeline pipeline; |
| 3107 | VkPipelineCache pipelineCache; |
| 3108 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3109 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3110 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3111 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3112 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3113 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3114 | FAIL() << "Did not recieve Error 'Gfx Pipeline scissorCount is 1, but pScissors is NULL...'"; |
| 3115 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3116 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3117 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3118 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 3119 | // First need to successfully create the PSO from above by setting pViewports |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3120 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3121 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1. These counts must match."); |
| 3122 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3123 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 3124 | vp_state_ci.pScissors = ≻ |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3125 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3126 | ASSERT_VK_SUCCESS(err); |
| 3127 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3128 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3129 | VkViewport viewports[2] = {}; // don't care about data |
| 3130 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 3131 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3132 | Draw(1, 0, 0, 0); |
| 3133 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3134 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3135 | FAIL() << "Did not receive Error 'Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1...'"; |
| 3136 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3137 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3138 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3139 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3140 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3141 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3142 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3143 | } |
| 3144 | |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3145 | TEST_F(VkLayerTest, NullRenderPass) |
| 3146 | { |
| 3147 | // Bind a NULL RenderPass |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3148 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3149 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3150 | |
| 3151 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3152 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3153 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3154 | BeginCommandBuffer(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3155 | // Don't care about RenderPass handle b/c error should be flagged before that |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3156 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3157 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3158 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3159 | FAIL() << "Did not receive Error 'You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()'"; |
| 3160 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3161 | } |
| 3162 | } |
| 3163 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3164 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) |
| 3165 | { |
| 3166 | // Bind a BeginRenderPass within an active RenderPass |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3167 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3168 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3169 | |
| 3170 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3171 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3172 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3173 | BeginCommandBuffer(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3174 | // Just create a dummy Renderpass that's non-NULL so we can get to the proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3175 | VkRenderPassBeginInfo rp_begin = {}; |
| 3176 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 3177 | rp_begin.pNext = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3178 | rp_begin.renderPass = renderPass(); |
| 3179 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3180 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3181 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3182 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3183 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3184 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3185 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3186 | } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3187 | } |
| 3188 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3189 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) |
| 3190 | { |
| 3191 | // Call CmdFillBuffer within an active renderpass |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3192 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3193 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3194 | |
| 3195 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3196 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3197 | |
| 3198 | // Renderpass is started here |
| 3199 | BeginCommandBuffer(); |
| 3200 | |
| 3201 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3202 | vk_testing::Buffer dstBuffer; |
| 3203 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3204 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3205 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3206 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3207 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3208 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3209 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3210 | } |
| 3211 | } |
| 3212 | |
| 3213 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) |
| 3214 | { |
| 3215 | // Call CmdUpdateBuffer within an active renderpass |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3216 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3217 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3218 | |
| 3219 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3220 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3221 | |
| 3222 | // Renderpass is started here |
| 3223 | BeginCommandBuffer(); |
| 3224 | |
| 3225 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3226 | vk_testing::Buffer dstBuffer; |
| 3227 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3228 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3229 | VkDeviceSize dstOffset = 0; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3230 | VkDeviceSize dataSize = 1024; |
| 3231 | const uint32_t *pData = NULL; |
| 3232 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3233 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3234 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3235 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3236 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3237 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3238 | } |
| 3239 | } |
| 3240 | |
| 3241 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) |
| 3242 | { |
| 3243 | // Call CmdClearColorImage within an active RenderPass |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3244 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3245 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3246 | |
| 3247 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3248 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3249 | |
| 3250 | // Renderpass is started here |
| 3251 | BeginCommandBuffer(); |
| 3252 | |
| 3253 | VkClearColorValue clear_color = {0}; |
| 3254 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 3255 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3256 | const int32_t tex_width = 32; |
| 3257 | const int32_t tex_height = 32; |
| 3258 | VkImageCreateInfo image_create_info = {}; |
| 3259 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3260 | image_create_info.pNext = NULL; |
| 3261 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3262 | image_create_info.format = tex_format; |
| 3263 | image_create_info.extent.width = tex_width; |
| 3264 | image_create_info.extent.height = tex_height; |
| 3265 | image_create_info.extent.depth = 1; |
| 3266 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3267 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3268 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3269 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3270 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3271 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3272 | vk_testing::Image dstImage; |
| 3273 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3274 | |
| 3275 | const VkImageSubresourceRange range = |
| 3276 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 3277 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3278 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), |
| 3279 | dstImage.handle(), |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3280 | VK_IMAGE_LAYOUT_GENERAL, |
| 3281 | &clear_color, |
| 3282 | 1, |
| 3283 | &range); |
| 3284 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3285 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3286 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3287 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3288 | } |
| 3289 | } |
| 3290 | |
| 3291 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) |
| 3292 | { |
| 3293 | // Call CmdClearDepthStencilImage within an active RenderPass |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3294 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3295 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3296 | |
| 3297 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3298 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3299 | |
| 3300 | // Renderpass is started here |
| 3301 | BeginCommandBuffer(); |
| 3302 | |
| 3303 | VkClearDepthStencilValue clear_value = {0}; |
| 3304 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 3305 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 3306 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3307 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3308 | image_create_info.extent.width = 64; |
| 3309 | image_create_info.extent.height = 64; |
| 3310 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3311 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 3312 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3313 | vk_testing::Image dstImage; |
| 3314 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3315 | |
| 3316 | const VkImageSubresourceRange range = |
| 3317 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 3318 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3319 | vkCmdClearDepthStencilImage(m_commandBuffer->GetBufferHandle(), |
| 3320 | dstImage.handle(), |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3321 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, |
| 3322 | &clear_value, |
| 3323 | 1, |
| 3324 | &range); |
| 3325 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3326 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3327 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3328 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3329 | } |
| 3330 | } |
| 3331 | |
| 3332 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) |
| 3333 | { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3334 | // Call CmdClearAttachmentss outside of an active RenderPass |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3335 | VkResult err; |
| 3336 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3337 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3338 | "vkCmdClearAttachments: This call must be issued inside an active render pass"); |
| 3339 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3340 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3341 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3342 | |
| 3343 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3344 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3345 | ASSERT_VK_SUCCESS(err); |
| 3346 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3347 | VkClearAttachment color_attachment; |
| 3348 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3349 | color_attachment.clearValue.color.float32[0] = 0; |
| 3350 | color_attachment.clearValue.color.float32[1] = 0; |
| 3351 | color_attachment.clearValue.color.float32[2] = 0; |
| 3352 | color_attachment.clearValue.color.float32[3] = 0; |
| 3353 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3354 | VkClearRect clear_rect = { { { 0, 0 }, { 32, 32 } } }; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3355 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3356 | 1, &color_attachment, |
| 3357 | 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3358 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3359 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3360 | FAIL() << "Did not receive Error 'vkCmdClearAttachments: This call must be issued inside an active render pass.'"; |
| 3361 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3362 | } |
| 3363 | } |
| 3364 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3365 | TEST_F(VkLayerTest, InvalidDynamicStateObject) |
| 3366 | { |
| 3367 | // Create a valid cmd buffer |
| 3368 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3369 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 3370 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3371 | } |
Tobin Ehlis | 1056d45 | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 3372 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3373 | TEST_F(VkLayerTest, IdxBufferAlignmentError) |
| 3374 | { |
| 3375 | // Bind a BeginRenderPass within an active RenderPass |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3376 | VkResult err; |
| 3377 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3378 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3379 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 3380 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3381 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3382 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3383 | uint32_t qfi = 0; |
| 3384 | VkBufferCreateInfo buffCI = {}; |
| 3385 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3386 | buffCI.size = 1024; |
| 3387 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3388 | buffCI.queueFamilyIndexCount = 1; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3389 | buffCI.pQueueFamilyIndices = &qfi; |
| 3390 | |
| 3391 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3392 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3393 | ASSERT_VK_SUCCESS(err); |
| 3394 | |
| 3395 | BeginCommandBuffer(); |
| 3396 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3397 | //vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3398 | // Should error before calling to driver so don't care about actual data |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3399 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3400 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3401 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3402 | FAIL() << "Did not receive Error 'vkCmdBindIndexBuffer() offset (0x7) does not fall on ...'"; |
| 3403 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3404 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3405 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3406 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3407 | } |
| 3408 | |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3409 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) |
| 3410 | { |
| 3411 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3412 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3413 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3414 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3415 | |
| 3416 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3417 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3418 | |
| 3419 | BeginCommandBuffer(); |
| 3420 | //ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3421 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 3422 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3423 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3424 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3425 | FAIL() << "Did not receive Error 'vkCmdExecuteCommands() called w/ Primary Cmd Buffer '"; |
| 3426 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3427 | } |
| 3428 | } |
| 3429 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3430 | TEST_F(VkLayerTest, DSTypeMismatch) |
| 3431 | { |
| 3432 | // Create DS w/ layout of one type and attempt Update w/ mis-matched type |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3433 | VkResult err; |
| 3434 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3435 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3436 | "Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match "); |
| 3437 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3438 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3439 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3440 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3441 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3442 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3443 | |
| 3444 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3445 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3446 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3447 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3448 | ds_pool_ci.poolSizeCount = 1; |
| 3449 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3450 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3451 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3452 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3453 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3454 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3455 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3456 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3457 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3458 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3459 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3460 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3461 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3462 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3463 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3464 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3465 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3466 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3467 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3468 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3469 | ASSERT_VK_SUCCESS(err); |
| 3470 | |
| 3471 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3472 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3473 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3474 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3475 | alloc_info.descriptorPool = ds_pool; |
| 3476 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3477 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3478 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3479 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3480 | VkSamplerCreateInfo sampler_ci = {}; |
| 3481 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3482 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3483 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3484 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3485 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3486 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3487 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3488 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3489 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | ddc8db5 | 2015-12-14 14:59:20 -0700 | [diff] [blame] | 3490 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3491 | sampler_ci.maxAnisotropy = 1; |
| 3492 | sampler_ci.compareEnable = VK_FALSE; |
| 3493 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3494 | sampler_ci.minLod = 1.0; |
| 3495 | sampler_ci.maxLod = 1.0; |
| 3496 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3497 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3498 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3499 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3500 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3501 | ASSERT_VK_SUCCESS(err); |
| 3502 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3503 | VkDescriptorImageInfo info = {}; |
| 3504 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3505 | |
| 3506 | VkWriteDescriptorSet descriptor_write; |
| 3507 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3508 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3509 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3510 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3511 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3512 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3513 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3514 | |
| 3515 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3516 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3517 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3518 | FAIL() << "Did not receive Error 'Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match...'"; |
| 3519 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3520 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3521 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3522 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3523 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3524 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3525 | } |
| 3526 | |
| 3527 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) |
| 3528 | { |
| 3529 | // For overlapping Update, have arrayIndex exceed that of layout |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3530 | VkResult err; |
| 3531 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3532 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3533 | "Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding"); |
| 3534 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3535 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3536 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3537 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3538 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3539 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3540 | |
| 3541 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3542 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3543 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3544 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3545 | ds_pool_ci.poolSizeCount = 1; |
| 3546 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3547 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3548 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3549 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3550 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3551 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3552 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3553 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3554 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3555 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3556 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3557 | dsl_binding.pImmutableSamplers = NULL; |
| 3558 | |
| 3559 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3560 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3561 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3562 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3563 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3564 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3565 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3566 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3567 | ASSERT_VK_SUCCESS(err); |
| 3568 | |
| 3569 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3570 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3571 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3572 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3573 | alloc_info.descriptorPool = ds_pool; |
| 3574 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3575 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3576 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3577 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3578 | VkSamplerCreateInfo sampler_ci = {}; |
| 3579 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3580 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3581 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3582 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3583 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3584 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3585 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3586 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3587 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | ddc8db5 | 2015-12-14 14:59:20 -0700 | [diff] [blame] | 3588 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3589 | sampler_ci.maxAnisotropy = 1; |
| 3590 | sampler_ci.compareEnable = VK_FALSE; |
| 3591 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3592 | sampler_ci.minLod = 1.0; |
| 3593 | sampler_ci.maxLod = 1.0; |
| 3594 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3595 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3596 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3597 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3598 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3599 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3600 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3601 | VkDescriptorImageInfo info = {}; |
| 3602 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3603 | |
| 3604 | VkWriteDescriptorSet descriptor_write; |
| 3605 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3606 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3607 | descriptor_write.dstSet = descriptorSet; |
| 3608 | descriptor_write.dstArrayElement = 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3609 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3610 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3611 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3612 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3613 | |
| 3614 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3615 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3616 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3617 | FAIL() << "Did not receive Error 'Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding...'"; |
| 3618 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3619 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3620 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3621 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3622 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3623 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3624 | } |
| 3625 | |
| 3626 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) |
| 3627 | { |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3628 | // Create layout w/ count of 1 and attempt update to that layout w/ binding index 2 |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3629 | VkResult err; |
| 3630 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3631 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3632 | " does not have binding to match update binding "); |
| 3633 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3634 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3635 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3636 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3637 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3638 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3639 | |
| 3640 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3641 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3642 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3643 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3644 | ds_pool_ci.poolSizeCount = 1; |
| 3645 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3646 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3647 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3648 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3649 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3650 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3651 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3652 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3653 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3654 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3655 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3656 | dsl_binding.pImmutableSamplers = NULL; |
| 3657 | |
| 3658 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3659 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3660 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3661 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3662 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3663 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3664 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3665 | ASSERT_VK_SUCCESS(err); |
| 3666 | |
| 3667 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3668 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3669 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3670 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3671 | alloc_info.descriptorPool = ds_pool; |
| 3672 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3673 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3674 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3675 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3676 | VkSamplerCreateInfo sampler_ci = {}; |
| 3677 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3678 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3679 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3680 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3681 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3682 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3683 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3684 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3685 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | ddc8db5 | 2015-12-14 14:59:20 -0700 | [diff] [blame] | 3686 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3687 | sampler_ci.maxAnisotropy = 1; |
| 3688 | sampler_ci.compareEnable = VK_FALSE; |
| 3689 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3690 | sampler_ci.minLod = 1.0; |
| 3691 | sampler_ci.maxLod = 1.0; |
| 3692 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3693 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3694 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3695 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3696 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3697 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3698 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3699 | VkDescriptorImageInfo info = {}; |
| 3700 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3701 | |
| 3702 | VkWriteDescriptorSet descriptor_write; |
| 3703 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3704 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3705 | descriptor_write.dstSet = descriptorSet; |
| 3706 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3707 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3708 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3709 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3710 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3711 | |
| 3712 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3713 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3714 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3715 | FAIL() << "Did not receive Error 'Descriptor Set <blah> does not have binding to match update binding '"; |
| 3716 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3717 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3718 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3719 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3720 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3721 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3722 | } |
| 3723 | |
| 3724 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) |
| 3725 | { |
| 3726 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* types |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3727 | VkResult err; |
| 3728 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3729 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3730 | "Unexpected UPDATE struct of type "); |
| 3731 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3732 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3733 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3734 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3735 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3736 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3737 | |
| 3738 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3739 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3740 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3741 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3742 | ds_pool_ci.poolSizeCount = 1; |
| 3743 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3744 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3745 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3746 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3747 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3748 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3749 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3750 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3751 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3752 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3753 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3754 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3755 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3756 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3757 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3758 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3759 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3760 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3761 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3762 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3763 | ASSERT_VK_SUCCESS(err); |
| 3764 | |
| 3765 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3766 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3767 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3768 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3769 | alloc_info.descriptorPool = ds_pool; |
| 3770 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3771 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3772 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3773 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3774 | VkSamplerCreateInfo sampler_ci = {}; |
| 3775 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3776 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3777 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3778 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3779 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3780 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3781 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3782 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3783 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | ddc8db5 | 2015-12-14 14:59:20 -0700 | [diff] [blame] | 3784 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3785 | sampler_ci.maxAnisotropy = 1; |
| 3786 | sampler_ci.compareEnable = VK_FALSE; |
| 3787 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3788 | sampler_ci.minLod = 1.0; |
| 3789 | sampler_ci.maxLod = 1.0; |
| 3790 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3791 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3792 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3793 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3794 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3795 | |
| 3796 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3797 | VkDescriptorImageInfo info = {}; |
| 3798 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3799 | |
| 3800 | VkWriteDescriptorSet descriptor_write; |
| 3801 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3802 | descriptor_write.sType = (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3803 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3804 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3805 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3806 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3807 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3808 | |
| 3809 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3810 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3811 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3812 | FAIL() << "Did not receive Error 'Unexpected UPDATE struct of type '"; |
| 3813 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3814 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3815 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3816 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3817 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3818 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3819 | } |
| 3820 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3821 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) |
| 3822 | { |
| 3823 | // Create a single Sampler descriptor and send it an invalid Sampler |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3824 | VkResult err; |
| 3825 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3826 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3827 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 3828 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3829 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3830 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3831 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3832 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3833 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3834 | |
| 3835 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3836 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3837 | ds_pool_ci.pNext = NULL; |
| 3838 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3839 | ds_pool_ci.poolSizeCount = 1; |
| 3840 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3841 | |
| 3842 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3843 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3844 | ASSERT_VK_SUCCESS(err); |
| 3845 | |
| 3846 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3847 | dsl_binding.binding = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3848 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3849 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3850 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3851 | dsl_binding.pImmutableSamplers = NULL; |
| 3852 | |
| 3853 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3854 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3855 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3856 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3857 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3858 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3859 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3860 | ASSERT_VK_SUCCESS(err); |
| 3861 | |
| 3862 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3863 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3864 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3865 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3866 | alloc_info.descriptorPool = ds_pool; |
| 3867 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3868 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3869 | ASSERT_VK_SUCCESS(err); |
| 3870 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3871 | VkSampler sampler = (VkSampler) 0xbaadbeef; // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3872 | |
| 3873 | VkDescriptorImageInfo descriptor_info; |
| 3874 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3875 | descriptor_info.sampler = sampler; |
| 3876 | |
| 3877 | VkWriteDescriptorSet descriptor_write; |
| 3878 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3879 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3880 | descriptor_write.dstSet = descriptorSet; |
| 3881 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3882 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3883 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3884 | descriptor_write.pImageInfo = &descriptor_info; |
| 3885 | |
| 3886 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3887 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3888 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3889 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid sampler...'"; |
| 3890 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3891 | } |
| 3892 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3893 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3894 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3895 | } |
| 3896 | |
| 3897 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) |
| 3898 | { |
| 3899 | // Create a single combined Image/Sampler descriptor and send it an invalid imageView |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3900 | VkResult err; |
| 3901 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3902 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3903 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 3904 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3905 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3906 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3907 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3908 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3909 | |
| 3910 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3911 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3912 | ds_pool_ci.pNext = NULL; |
| 3913 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3914 | ds_pool_ci.poolSizeCount = 1; |
| 3915 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3916 | |
| 3917 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3918 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3919 | ASSERT_VK_SUCCESS(err); |
| 3920 | |
| 3921 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3922 | dsl_binding.binding = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3923 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3924 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3925 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3926 | dsl_binding.pImmutableSamplers = NULL; |
| 3927 | |
| 3928 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3929 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3930 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3931 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3932 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3933 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3934 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3935 | ASSERT_VK_SUCCESS(err); |
| 3936 | |
| 3937 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3938 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3939 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3940 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3941 | alloc_info.descriptorPool = ds_pool; |
| 3942 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3943 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3944 | ASSERT_VK_SUCCESS(err); |
| 3945 | |
| 3946 | VkSamplerCreateInfo sampler_ci = {}; |
| 3947 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3948 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3949 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3950 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3951 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3952 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3953 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3954 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3955 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | ddc8db5 | 2015-12-14 14:59:20 -0700 | [diff] [blame] | 3956 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3957 | sampler_ci.maxAnisotropy = 1; |
| 3958 | sampler_ci.compareEnable = VK_FALSE; |
| 3959 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3960 | sampler_ci.minLod = 1.0; |
| 3961 | sampler_ci.maxLod = 1.0; |
| 3962 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3963 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3964 | |
| 3965 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3966 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3967 | ASSERT_VK_SUCCESS(err); |
| 3968 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3969 | VkImageView view = (VkImageView) 0xbaadbeef; // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3970 | |
| 3971 | VkDescriptorImageInfo descriptor_info; |
| 3972 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3973 | descriptor_info.sampler = sampler; |
| 3974 | descriptor_info.imageView = view; |
| 3975 | |
| 3976 | VkWriteDescriptorSet descriptor_write; |
| 3977 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3978 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3979 | descriptor_write.dstSet = descriptorSet; |
| 3980 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3981 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3982 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3983 | descriptor_write.pImageInfo = &descriptor_info; |
| 3984 | |
| 3985 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3986 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3987 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3988 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid imageView...'"; |
| 3989 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3990 | } |
| 3991 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3992 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3993 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3994 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3995 | } |
| 3996 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3997 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) |
| 3998 | { |
| 3999 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update into the other |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4000 | VkResult err; |
| 4001 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4002 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4003 | "Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER "); |
| 4004 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4005 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4006 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4007 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4008 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4009 | ds_type_count[0].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4010 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4011 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4012 | |
| 4013 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4014 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4015 | ds_pool_ci.pNext = NULL; |
| 4016 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4017 | ds_pool_ci.poolSizeCount = 2; |
| 4018 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4019 | |
| 4020 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4021 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4022 | ASSERT_VK_SUCCESS(err); |
| 4023 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4024 | dsl_binding[0].binding = 0; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4025 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4026 | dsl_binding[0].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4027 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4028 | dsl_binding[0].pImmutableSamplers = NULL; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4029 | dsl_binding[1].binding = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4030 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4031 | dsl_binding[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4032 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 4033 | dsl_binding[1].pImmutableSamplers = NULL; |
| 4034 | |
| 4035 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4036 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4037 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4038 | ds_layout_ci.bindingCount = 2; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4039 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4040 | |
| 4041 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4042 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4043 | ASSERT_VK_SUCCESS(err); |
| 4044 | |
| 4045 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4046 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4047 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4048 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4049 | alloc_info.descriptorPool = ds_pool; |
| 4050 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4051 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4052 | ASSERT_VK_SUCCESS(err); |
| 4053 | |
| 4054 | VkSamplerCreateInfo sampler_ci = {}; |
| 4055 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4056 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 4057 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4058 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4059 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 4060 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4061 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4062 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4063 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | ddc8db5 | 2015-12-14 14:59:20 -0700 | [diff] [blame] | 4064 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4065 | sampler_ci.maxAnisotropy = 1; |
| 4066 | sampler_ci.compareEnable = VK_FALSE; |
| 4067 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4068 | sampler_ci.minLod = 1.0; |
| 4069 | sampler_ci.maxLod = 1.0; |
| 4070 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4071 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 4072 | |
| 4073 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4074 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4075 | ASSERT_VK_SUCCESS(err); |
| 4076 | |
| 4077 | VkDescriptorImageInfo info = {}; |
| 4078 | info.sampler = sampler; |
| 4079 | |
| 4080 | VkWriteDescriptorSet descriptor_write; |
| 4081 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 4082 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4083 | descriptor_write.dstSet = descriptorSet; |
| 4084 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4085 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4086 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4087 | descriptor_write.pImageInfo = &info; |
| 4088 | // This write update should succeed |
| 4089 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4090 | // Now perform a copy update that fails due to type mismatch |
| 4091 | VkCopyDescriptorSet copy_ds_update; |
| 4092 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4093 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4094 | copy_ds_update.srcSet = descriptorSet; |
| 4095 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4096 | copy_ds_update.dstSet = descriptorSet; |
| 4097 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4098 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4099 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4100 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4101 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4102 | FAIL() << "Did not receive Error 'Copy descriptor update index 0, update count #1, has src update descriptor type_DESCRIPTOR_TYPE_SAMPLER'"; |
| 4103 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4104 | } |
| 4105 | // Now perform a copy update that fails due to binding out of bounds |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4106 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4107 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4108 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4109 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4110 | copy_ds_update.srcSet = descriptorSet; |
| 4111 | copy_ds_update.srcBinding = 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4112 | copy_ds_update.dstSet = descriptorSet; |
| 4113 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4114 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4115 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4116 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4117 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4118 | FAIL() << "Did not receive Error 'Copy descriptor update 0 has srcBinding 3 which is out of bounds...'"; |
| 4119 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4120 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4121 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4122 | // Now perform a copy update that fails due to binding out of bounds |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4123 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4124 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 4125 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4126 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4127 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4128 | copy_ds_update.srcSet = descriptorSet; |
| 4129 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4130 | copy_ds_update.dstSet = descriptorSet; |
| 4131 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4132 | copy_ds_update.descriptorCount = 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4133 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4134 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4135 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4136 | FAIL() << "Did not receive Error 'Copy descriptor src update is out of bounds for matching binding 1...'"; |
| 4137 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4138 | } |
| 4139 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4140 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4141 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4142 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4143 | } |
| 4144 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4145 | TEST_F(VkLayerTest, NumSamplesMismatch) |
| 4146 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4147 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4148 | VkResult err; |
| 4149 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4150 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4151 | "Num samples mismatch! "); |
| 4152 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4153 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4154 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4155 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4156 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4157 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4158 | |
| 4159 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4160 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4161 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4162 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4163 | ds_pool_ci.poolSizeCount = 1; |
| 4164 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4165 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4166 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4167 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4168 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4169 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4170 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4171 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4172 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4173 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4174 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4175 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4176 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4177 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4178 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4179 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4180 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4181 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4182 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4183 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4184 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4185 | ASSERT_VK_SUCCESS(err); |
| 4186 | |
| 4187 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4188 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4189 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4190 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4191 | alloc_info.descriptorPool = ds_pool; |
| 4192 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4193 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4194 | ASSERT_VK_SUCCESS(err); |
| 4195 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4196 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4197 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4198 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4199 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4200 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4201 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 4202 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4203 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4204 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4205 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4206 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4207 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4208 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4209 | |
| 4210 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4211 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4212 | ASSERT_VK_SUCCESS(err); |
| 4213 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4214 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4215 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4216 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4217 | VkPipelineObj pipe(m_device); |
| 4218 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4219 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4220 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4221 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4222 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4223 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4224 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4225 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4226 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4227 | FAIL() << "Did not recieve Error 'Num samples mismatch!...'"; |
| 4228 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4229 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4230 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4231 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4232 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4233 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4234 | } |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4235 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4236 | TEST_F(VkLayerTest, ClearCmdNoDraw) |
| 4237 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4238 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior to issuing a Draw |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4239 | VkResult err; |
| 4240 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4241 | // TODO: verify that this matches layer |
| 4242 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARN_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4243 | "vkCmdClearAttachments() issued on CB object "); |
| 4244 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4245 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4246 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4247 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4248 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4249 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4250 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4251 | |
| 4252 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4253 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4254 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4255 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4256 | ds_pool_ci.poolSizeCount = 1; |
| 4257 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4258 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4259 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4260 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4261 | ASSERT_VK_SUCCESS(err); |
| 4262 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4263 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4264 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4265 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4266 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4267 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4268 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4269 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4270 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4271 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4272 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4273 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4274 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4275 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4276 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4277 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4278 | ASSERT_VK_SUCCESS(err); |
| 4279 | |
| 4280 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4281 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4282 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4283 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4284 | alloc_info.descriptorPool = ds_pool; |
| 4285 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4286 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4287 | ASSERT_VK_SUCCESS(err); |
| 4288 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4289 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4290 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4291 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4292 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4293 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4294 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 4295 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4296 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4297 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4298 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4299 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4300 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4301 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4302 | |
| 4303 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4304 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4305 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4306 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4307 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4308 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 4309 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4310 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4311 | VkPipelineObj pipe(m_device); |
| 4312 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4313 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4314 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4315 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4316 | |
| 4317 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4318 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4319 | // Main thing we care about for this test is that the VkImage obj we're clearing matches Color Attachment of FB |
| 4320 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4321 | VkClearAttachment color_attachment; |
| 4322 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4323 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 4324 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 4325 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 4326 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 4327 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4328 | VkClearRect clear_rect = { { { 0, 0 }, { (int)m_width, (int)m_height } } }; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4329 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4330 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4331 | |
| 4332 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4333 | FAIL() << "Did not receive Error 'vkCommandClearAttachments() issued on CB object...'"; |
| 4334 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4335 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4336 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4337 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4338 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4339 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4340 | } |
| 4341 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4342 | TEST_F(VkLayerTest, VtxBufferBadIndex) |
| 4343 | { |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4344 | VkResult err; |
| 4345 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4346 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERF_WARN_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 4347 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4348 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4349 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4350 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4351 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4352 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4353 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4354 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4355 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4356 | |
| 4357 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4358 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4359 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4360 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4361 | ds_pool_ci.poolSizeCount = 1; |
| 4362 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4363 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4364 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4365 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4366 | ASSERT_VK_SUCCESS(err); |
| 4367 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4368 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4369 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4370 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4371 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4372 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4373 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4374 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4375 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4376 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4377 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4378 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4379 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4380 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4381 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4382 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4383 | ASSERT_VK_SUCCESS(err); |
| 4384 | |
| 4385 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4386 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4387 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4388 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4389 | alloc_info.descriptorPool = ds_pool; |
| 4390 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4391 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4392 | ASSERT_VK_SUCCESS(err); |
| 4393 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4394 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4395 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4396 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4397 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4398 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4399 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 4400 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4401 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4402 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4403 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4404 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4405 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4406 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4407 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4408 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4409 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4410 | ASSERT_VK_SUCCESS(err); |
| 4411 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4412 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4413 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4414 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4415 | VkPipelineObj pipe(m_device); |
| 4416 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4417 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4418 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4419 | pipe.SetViewport(m_viewports); |
| 4420 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4421 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4422 | |
| 4423 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4424 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4425 | // Don't care about actual data, just need to get to draw to flag error |
| 4426 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
| 4427 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data); |
| 4428 | BindVertexBuffer(&vbo, (VkDeviceSize)0, 1); // VBO idx 1, but no VBO in PSO |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 4429 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4430 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4431 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4432 | FAIL() << "Did not receive Error 'Vtx Buffer Index 0 was bound, but no vtx buffers are attached to PSO.'"; |
| 4433 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4434 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4435 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4436 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4437 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4438 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4439 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4440 | #endif // DRAW_STATE_TESTS |
| 4441 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 4442 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4443 | #if GTEST_IS_THREADSAFE |
| 4444 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4445 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4446 | VkEvent event; |
| 4447 | bool bailout; |
| 4448 | }; |
| 4449 | |
| 4450 | extern "C" void *AddToCommandBuffer(void *arg) |
| 4451 | { |
| 4452 | struct thread_data_struct *data = (struct thread_data_struct *) arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4453 | |
| 4454 | for (int i = 0; i<10000; i++) { |
Chia-I Wu | 89d0f94 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4455 | vkCmdSetEvent(data->commandBuffer, data->event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4456 | if (data->bailout) { |
| 4457 | break; |
| 4458 | } |
| 4459 | } |
| 4460 | return NULL; |
| 4461 | } |
| 4462 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4463 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4464 | { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4465 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4466 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4467 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4468 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4469 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4470 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4471 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4472 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4473 | // Calls AllocateCommandBuffers |
| 4474 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4475 | |
| 4476 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4477 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4478 | |
| 4479 | VkEventCreateInfo event_info; |
| 4480 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4481 | VkResult err; |
| 4482 | |
| 4483 | memset(&event_info, 0, sizeof(event_info)); |
| 4484 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 4485 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4486 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4487 | ASSERT_VK_SUCCESS(err); |
| 4488 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4489 | err = vkResetEvent(device(), event); |
| 4490 | ASSERT_VK_SUCCESS(err); |
| 4491 | |
| 4492 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4493 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4494 | data.event = event; |
| 4495 | data.bailout = false; |
| 4496 | m_errorMonitor->SetBailout(&data.bailout); |
| 4497 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4498 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4499 | // Add many entries to command buffer from this thread at the same time. |
| 4500 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4501 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4502 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4503 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4504 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4505 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4506 | FAIL() << "Did not receive Error 'THREADING ERROR' from using one VkCommandBufferObj in two threads"; |
| 4507 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4508 | } |
| 4509 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4510 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4511 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4512 | #endif // GTEST_IS_THREADSAFE |
| 4513 | #endif // THREADING_TESTS |
| 4514 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4515 | #if SHADER_CHECKER_TESTS |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4516 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) |
| 4517 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4518 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4519 | "Shader is not SPIR-V"); |
| 4520 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4521 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4522 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4523 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4524 | VkShaderModule module; |
| 4525 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4526 | struct icd_spv_header spv; |
| 4527 | |
| 4528 | spv.magic = ICD_SPV_MAGIC; |
| 4529 | spv.version = ICD_SPV_VERSION; |
| 4530 | spv.gen_magic = 0; |
| 4531 | |
| 4532 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4533 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4534 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4535 | moduleCreateInfo.codeSize = 4; |
| 4536 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4537 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4538 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4539 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4540 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4541 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4542 | } |
| 4543 | } |
| 4544 | |
| 4545 | TEST_F(VkLayerTest, InvalidSPIRVMagic) |
| 4546 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4547 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4548 | "Shader is not SPIR-V"); |
| 4549 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4550 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4551 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4552 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4553 | VkShaderModule module; |
| 4554 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4555 | struct icd_spv_header spv; |
| 4556 | |
| 4557 | spv.magic = ~ICD_SPV_MAGIC; |
| 4558 | spv.version = ICD_SPV_VERSION; |
| 4559 | spv.gen_magic = 0; |
| 4560 | |
| 4561 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4562 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4563 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4564 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4565 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4566 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4567 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4568 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4569 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4570 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4571 | } |
| 4572 | } |
| 4573 | |
| 4574 | TEST_F(VkLayerTest, InvalidSPIRVVersion) |
| 4575 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4576 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4577 | "Shader is not SPIR-V"); |
| 4578 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4579 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4580 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4581 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4582 | VkShaderModule module; |
| 4583 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4584 | struct icd_spv_header spv; |
| 4585 | |
| 4586 | spv.magic = ICD_SPV_MAGIC; |
| 4587 | spv.version = ~ICD_SPV_VERSION; |
| 4588 | spv.gen_magic = 0; |
| 4589 | |
| 4590 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4591 | moduleCreateInfo.pNext = NULL; |
| 4592 | |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4593 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4594 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4595 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4596 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4597 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4598 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4599 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4600 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4601 | } |
| 4602 | } |
| 4603 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4604 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) |
| 4605 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4606 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERF_WARN_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4607 | "not consumed by fragment shader"); |
| 4608 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4609 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4610 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4611 | |
| 4612 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4613 | "#version 400\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4614 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4615 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4616 | "\n" |
| 4617 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4618 | "out gl_PerVertex {\n" |
| 4619 | " vec4 gl_Position;\n" |
| 4620 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4621 | "void main(){\n" |
| 4622 | " gl_Position = vec4(1);\n" |
| 4623 | " x = 0;\n" |
| 4624 | "}\n"; |
| 4625 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4626 | "#version 400\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4627 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4628 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4629 | "\n" |
| 4630 | "layout(location=0) out vec4 color;\n" |
| 4631 | "void main(){\n" |
| 4632 | " color = vec4(1);\n" |
| 4633 | "}\n"; |
| 4634 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4635 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4636 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4637 | |
| 4638 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4639 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4640 | pipe.AddShader(&vs); |
| 4641 | pipe.AddShader(&fs); |
| 4642 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4643 | VkDescriptorSetObj descriptorSet(m_device); |
| 4644 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4645 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4646 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4647 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4648 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4649 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4650 | FAIL() << "Did not receive Warning 'not consumed by fragment shader'"; |
| 4651 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4652 | } |
| 4653 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4654 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4655 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) |
| 4656 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4657 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4658 | "not written by vertex shader"); |
| 4659 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4660 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4661 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4662 | |
| 4663 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4664 | "#version 400\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4665 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4666 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4667 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4668 | "out gl_PerVertex {\n" |
| 4669 | " vec4 gl_Position;\n" |
| 4670 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4671 | "void main(){\n" |
| 4672 | " gl_Position = vec4(1);\n" |
| 4673 | "}\n"; |
| 4674 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4675 | "#version 400\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4676 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4677 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4678 | "\n" |
| 4679 | "layout(location=0) in float x;\n" |
| 4680 | "layout(location=0) out vec4 color;\n" |
| 4681 | "void main(){\n" |
| 4682 | " color = vec4(x);\n" |
| 4683 | "}\n"; |
| 4684 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4685 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4686 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4687 | |
| 4688 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4689 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4690 | pipe.AddShader(&vs); |
| 4691 | pipe.AddShader(&fs); |
| 4692 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4693 | VkDescriptorSetObj descriptorSet(m_device); |
| 4694 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4695 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4696 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4697 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4698 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4699 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4700 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 4701 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4702 | } |
| 4703 | } |
| 4704 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4705 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) |
| 4706 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4707 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4708 | "Type mismatch on location 0"); |
| 4709 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4710 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4711 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4712 | |
| 4713 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4714 | "#version 400\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4715 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4716 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4717 | "\n" |
| 4718 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4719 | "out gl_PerVertex {\n" |
| 4720 | " vec4 gl_Position;\n" |
| 4721 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4722 | "void main(){\n" |
| 4723 | " x = 0;\n" |
| 4724 | " gl_Position = vec4(1);\n" |
| 4725 | "}\n"; |
| 4726 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4727 | "#version 400\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4728 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4729 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4730 | "\n" |
| 4731 | "layout(location=0) in float x;\n" /* VS writes int */ |
| 4732 | "layout(location=0) out vec4 color;\n" |
| 4733 | "void main(){\n" |
| 4734 | " color = vec4(x);\n" |
| 4735 | "}\n"; |
| 4736 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4737 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4738 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4739 | |
| 4740 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4741 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4742 | pipe.AddShader(&vs); |
| 4743 | pipe.AddShader(&fs); |
| 4744 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4745 | VkDescriptorSetObj descriptorSet(m_device); |
| 4746 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4747 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4748 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4749 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4750 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4751 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4752 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 4753 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4754 | } |
| 4755 | } |
| 4756 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4757 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) |
| 4758 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4759 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERF_WARN_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4760 | "location 0 not consumed by VS"); |
| 4761 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4762 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4763 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4764 | |
| 4765 | VkVertexInputBindingDescription input_binding; |
| 4766 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4767 | |
| 4768 | VkVertexInputAttributeDescription input_attrib; |
| 4769 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4770 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4771 | |
| 4772 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4773 | "#version 400\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4774 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4775 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4776 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4777 | "out gl_PerVertex {\n" |
| 4778 | " vec4 gl_Position;\n" |
| 4779 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4780 | "void main(){\n" |
| 4781 | " gl_Position = vec4(1);\n" |
| 4782 | "}\n"; |
| 4783 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4784 | "#version 400\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4785 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4786 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4787 | "\n" |
| 4788 | "layout(location=0) out vec4 color;\n" |
| 4789 | "void main(){\n" |
| 4790 | " color = vec4(1);\n" |
| 4791 | "}\n"; |
| 4792 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4793 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4794 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4795 | |
| 4796 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4797 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4798 | pipe.AddShader(&vs); |
| 4799 | pipe.AddShader(&fs); |
| 4800 | |
| 4801 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4802 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4803 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4804 | VkDescriptorSetObj descriptorSet(m_device); |
| 4805 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4806 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4807 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4808 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4809 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4810 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4811 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 4812 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4813 | } |
| 4814 | } |
| 4815 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4816 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) |
| 4817 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4818 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4819 | "VS consumes input at location 0 but not provided"); |
| 4820 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4821 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4822 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4823 | |
| 4824 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4825 | "#version 400\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4826 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4827 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4828 | "\n" |
| 4829 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4830 | "out gl_PerVertex {\n" |
| 4831 | " vec4 gl_Position;\n" |
| 4832 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4833 | "void main(){\n" |
| 4834 | " gl_Position = x;\n" |
| 4835 | "}\n"; |
| 4836 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4837 | "#version 400\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 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 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4846 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4847 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4848 | |
| 4849 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4850 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4851 | pipe.AddShader(&vs); |
| 4852 | pipe.AddShader(&fs); |
| 4853 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4854 | VkDescriptorSetObj descriptorSet(m_device); |
| 4855 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4856 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4857 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4858 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4859 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4860 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4861 | FAIL() << "Did not receive Error 'VS consumes input at location 0 but not provided'"; |
| 4862 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4863 | } |
| 4864 | } |
| 4865 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4866 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) |
| 4867 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4868 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4869 | "location 0 does not match VS input type"); |
| 4870 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4871 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4872 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4873 | |
| 4874 | VkVertexInputBindingDescription input_binding; |
| 4875 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4876 | |
| 4877 | VkVertexInputAttributeDescription input_attrib; |
| 4878 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4879 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4880 | |
| 4881 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4882 | "#version 400\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4883 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4884 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4885 | "\n" |
| 4886 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4887 | "out gl_PerVertex {\n" |
| 4888 | " vec4 gl_Position;\n" |
| 4889 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4890 | "void main(){\n" |
| 4891 | " gl_Position = vec4(x);\n" |
| 4892 | "}\n"; |
| 4893 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4894 | "#version 400\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4895 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4896 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4897 | "\n" |
| 4898 | "layout(location=0) out vec4 color;\n" |
| 4899 | "void main(){\n" |
| 4900 | " color = vec4(1);\n" |
| 4901 | "}\n"; |
| 4902 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4903 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4904 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4905 | |
| 4906 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4907 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4908 | pipe.AddShader(&vs); |
| 4909 | pipe.AddShader(&fs); |
| 4910 | |
| 4911 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4912 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4913 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4914 | VkDescriptorSetObj descriptorSet(m_device); |
| 4915 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4916 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4917 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4918 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4919 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4920 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4921 | FAIL() << "Did not receive Error 'location 0 does not match VS input type'"; |
| 4922 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4923 | } |
| 4924 | } |
| 4925 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 4926 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) |
| 4927 | { |
| 4928 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 4929 | |
| 4930 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4931 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4932 | |
| 4933 | VkVertexInputBindingDescription input_binding; |
| 4934 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4935 | |
| 4936 | VkVertexInputAttributeDescription input_attribs[2]; |
| 4937 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 4938 | |
| 4939 | for (int i = 0; i < 2; i++) { |
| 4940 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 4941 | input_attribs[i].location = i; |
| 4942 | } |
| 4943 | |
| 4944 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4945 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 4946 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4947 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4948 | "\n" |
| 4949 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4950 | "out gl_PerVertex {\n" |
| 4951 | " vec4 gl_Position;\n" |
| 4952 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 4953 | "void main(){\n" |
| 4954 | " gl_Position = x[0] + x[1];\n" |
| 4955 | "}\n"; |
| 4956 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4957 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 4958 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4959 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4960 | "\n" |
| 4961 | "layout(location=0) out vec4 color;\n" |
| 4962 | "void main(){\n" |
| 4963 | " color = vec4(1);\n" |
| 4964 | "}\n"; |
| 4965 | |
| 4966 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4967 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4968 | |
| 4969 | VkPipelineObj pipe(m_device); |
| 4970 | pipe.AddColorAttachment(); |
| 4971 | pipe.AddShader(&vs); |
| 4972 | pipe.AddShader(&fs); |
| 4973 | |
| 4974 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4975 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 4976 | |
| 4977 | VkDescriptorSetObj descriptorSet(m_device); |
| 4978 | descriptorSet.AppendDummy(); |
| 4979 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 4980 | |
| 4981 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4982 | |
| 4983 | /* expect success */ |
| 4984 | if (m_errorMonitor->DesiredMsgFound()) { |
| 4985 | FAIL() << "Expected to succeed but: " << m_errorMonitor->GetFailureMsg(); |
| 4986 | m_errorMonitor->DumpFailureMsgs(); |
| 4987 | } |
| 4988 | } |
| 4989 | |
| 4990 | /* |
| 4991 | * Would work, but not supported by glslang! This is similar to the matrix case above. |
| 4992 | * |
| 4993 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 4994 | { |
| 4995 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 4996 | |
| 4997 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4998 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4999 | |
| 5000 | VkVertexInputBindingDescription input_binding; |
| 5001 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5002 | |
| 5003 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5004 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5005 | |
| 5006 | for (int i = 0; i < 2; i++) { |
| 5007 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5008 | input_attribs[i].location = i; |
| 5009 | } |
| 5010 | |
| 5011 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5012 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5013 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5014 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5015 | "\n" |
| 5016 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5017 | "out gl_PerVertex {\n" |
| 5018 | " vec4 gl_Position;\n" |
| 5019 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5020 | "void main(){\n" |
| 5021 | " gl_Position = x[0] + x[1];\n" |
| 5022 | "}\n"; |
| 5023 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5024 | "#version 400\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5025 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5026 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5027 | "\n" |
| 5028 | "layout(location=0) out vec4 color;\n" |
| 5029 | "void main(){\n" |
| 5030 | " color = vec4(1);\n" |
| 5031 | "}\n"; |
| 5032 | |
| 5033 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5034 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5035 | |
| 5036 | VkPipelineObj pipe(m_device); |
| 5037 | pipe.AddColorAttachment(); |
| 5038 | pipe.AddShader(&vs); |
| 5039 | pipe.AddShader(&fs); |
| 5040 | |
| 5041 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5042 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5043 | |
| 5044 | VkDescriptorSetObj descriptorSet(m_device); |
| 5045 | descriptorSet.AppendDummy(); |
| 5046 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5047 | |
| 5048 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5049 | |
| 5050 | if (m_errorMonitor->DesiredMsgFound()) { |
| 5051 | FAIL() << "Expected to succeed but: " << m_errorMonitor->GetFailureMsg(); |
| 5052 | m_errorMonitor->DumpFailureMsgs(); |
| 5053 | } |
| 5054 | } |
| 5055 | */ |
| 5056 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5057 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) |
| 5058 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5059 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5060 | "Duplicate vertex input binding descriptions for binding 0"); |
| 5061 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5062 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5063 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5064 | |
| 5065 | /* Two binding descriptions for binding 0 */ |
| 5066 | VkVertexInputBindingDescription input_bindings[2]; |
| 5067 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 5068 | |
| 5069 | VkVertexInputAttributeDescription input_attrib; |
| 5070 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5071 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5072 | |
| 5073 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5074 | "#version 400\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5075 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5076 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5077 | "\n" |
| 5078 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5079 | "out gl_PerVertex {\n" |
| 5080 | " vec4 gl_Position;\n" |
| 5081 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5082 | "void main(){\n" |
| 5083 | " gl_Position = vec4(x);\n" |
| 5084 | "}\n"; |
| 5085 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5086 | "#version 400\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5087 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5088 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5089 | "\n" |
| 5090 | "layout(location=0) out vec4 color;\n" |
| 5091 | "void main(){\n" |
| 5092 | " color = vec4(1);\n" |
| 5093 | "}\n"; |
| 5094 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5095 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5096 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5097 | |
| 5098 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5099 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5100 | pipe.AddShader(&vs); |
| 5101 | pipe.AddShader(&fs); |
| 5102 | |
| 5103 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 5104 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5105 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5106 | VkDescriptorSetObj descriptorSet(m_device); |
| 5107 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5108 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5109 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5110 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5111 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5112 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5113 | FAIL() << "Did not receive Error 'Duplicate vertex input binding descriptions for binding 0'"; |
| 5114 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5115 | } |
| 5116 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 5117 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5118 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) |
| 5119 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5120 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5121 | "Attachment 0 not written by FS"); |
| 5122 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5123 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5124 | |
| 5125 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5126 | "#version 400\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5127 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5128 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5129 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5130 | "out gl_PerVertex {\n" |
| 5131 | " vec4 gl_Position;\n" |
| 5132 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5133 | "void main(){\n" |
| 5134 | " gl_Position = vec4(1);\n" |
| 5135 | "}\n"; |
| 5136 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5137 | "#version 400\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5138 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5139 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5140 | "\n" |
| 5141 | "void main(){\n" |
| 5142 | "}\n"; |
| 5143 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5144 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5145 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5146 | |
| 5147 | VkPipelineObj pipe(m_device); |
| 5148 | pipe.AddShader(&vs); |
| 5149 | pipe.AddShader(&fs); |
| 5150 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5151 | /* set up CB 0, not written */ |
| 5152 | pipe.AddColorAttachment(); |
| 5153 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5154 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5155 | VkDescriptorSetObj descriptorSet(m_device); |
| 5156 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5157 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5158 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5159 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5160 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5161 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5162 | FAIL() << "Did not receive Error 'Attachment 0 not written by FS'"; |
| 5163 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5164 | } |
| 5165 | } |
| 5166 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5167 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) |
| 5168 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5169 | // TODO: verify that this matches layer |
| 5170 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARN_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5171 | "FS writes to output location 1 with no matching attachment"); |
| 5172 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5173 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5174 | |
| 5175 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5176 | "#version 400\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5177 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5178 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5179 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5180 | "out gl_PerVertex {\n" |
| 5181 | " vec4 gl_Position;\n" |
| 5182 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5183 | "void main(){\n" |
| 5184 | " gl_Position = vec4(1);\n" |
| 5185 | "}\n"; |
| 5186 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5187 | "#version 400\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5188 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5189 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5190 | "\n" |
| 5191 | "layout(location=0) out vec4 x;\n" |
| 5192 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
| 5193 | "void main(){\n" |
| 5194 | " x = vec4(1);\n" |
| 5195 | " y = vec4(1);\n" |
| 5196 | "}\n"; |
| 5197 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5198 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5199 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5200 | |
| 5201 | VkPipelineObj pipe(m_device); |
| 5202 | pipe.AddShader(&vs); |
| 5203 | pipe.AddShader(&fs); |
| 5204 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5205 | /* set up CB 0, not written */ |
| 5206 | pipe.AddColorAttachment(); |
| 5207 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5208 | /* FS writes CB 1, but we don't configure it */ |
| 5209 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5210 | VkDescriptorSetObj descriptorSet(m_device); |
| 5211 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5212 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5213 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5214 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5215 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5216 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5217 | FAIL() << "Did not receive Error 'FS writes to output location 1 with no matching attachment'"; |
| 5218 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5219 | } |
| 5220 | } |
| 5221 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5222 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) |
| 5223 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5224 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5225 | "does not match FS output type"); |
| 5226 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5227 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5228 | |
| 5229 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5230 | "#version 400\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5231 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5232 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5233 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5234 | "out gl_PerVertex {\n" |
| 5235 | " vec4 gl_Position;\n" |
| 5236 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5237 | "void main(){\n" |
| 5238 | " gl_Position = vec4(1);\n" |
| 5239 | "}\n"; |
| 5240 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5241 | "#version 400\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5242 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5243 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5244 | "\n" |
| 5245 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
| 5246 | "void main(){\n" |
| 5247 | " x = ivec4(1);\n" |
| 5248 | "}\n"; |
| 5249 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5250 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5251 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5252 | |
| 5253 | VkPipelineObj pipe(m_device); |
| 5254 | pipe.AddShader(&vs); |
| 5255 | pipe.AddShader(&fs); |
| 5256 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5257 | /* set up CB 0; type is UNORM by default */ |
| 5258 | pipe.AddColorAttachment(); |
| 5259 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5260 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5261 | VkDescriptorSetObj descriptorSet(m_device); |
| 5262 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5263 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5264 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5265 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5266 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5267 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5268 | FAIL() << "Did not receive Error 'does not match FS output type'"; |
| 5269 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5270 | } |
| 5271 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 5272 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5273 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) |
| 5274 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5275 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5276 | "not declared in pipeline layout"); |
| 5277 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5278 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5279 | |
| 5280 | char const *vsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5281 | "#version 400\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5282 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5283 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5284 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5285 | "out gl_PerVertex {\n" |
| 5286 | " vec4 gl_Position;\n" |
| 5287 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5288 | "void main(){\n" |
| 5289 | " gl_Position = vec4(1);\n" |
| 5290 | "}\n"; |
| 5291 | char const *fsSource = |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5292 | "#version 400\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5293 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5294 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5295 | "\n" |
| 5296 | "layout(location=0) out vec4 x;\n" |
| 5297 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5298 | "void main(){\n" |
| 5299 | " x = vec4(bar.y);\n" |
| 5300 | "}\n"; |
| 5301 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5302 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5303 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5304 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5305 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5306 | VkPipelineObj pipe(m_device); |
| 5307 | pipe.AddShader(&vs); |
| 5308 | pipe.AddShader(&fs); |
| 5309 | |
| 5310 | /* set up CB 0; type is UNORM by default */ |
| 5311 | pipe.AddColorAttachment(); |
| 5312 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5313 | |
| 5314 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5315 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5316 | |
| 5317 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5318 | |
| 5319 | /* should have generated an error -- pipeline layout does not |
| 5320 | * provide a uniform buffer in 0.0 |
| 5321 | */ |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5322 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5323 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 5324 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5325 | } |
| 5326 | } |
| 5327 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5328 | #endif // SHADER_CHECKER_TESTS |
| 5329 | |
| 5330 | #if DEVICE_LIMITS_TESTS |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5331 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) |
| 5332 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5333 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5334 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5335 | |
| 5336 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5337 | |
| 5338 | // Create an image |
| 5339 | VkImage image; |
| 5340 | |
| 5341 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5342 | const int32_t tex_width = 32; |
| 5343 | const int32_t tex_height = 32; |
| 5344 | |
| 5345 | VkImageCreateInfo image_create_info = {}; |
| 5346 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5347 | image_create_info.pNext = NULL; |
| 5348 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5349 | image_create_info.format = tex_format; |
| 5350 | image_create_info.extent.width = tex_width; |
| 5351 | image_create_info.extent.height = tex_height; |
| 5352 | image_create_info.extent.depth = 1; |
| 5353 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5354 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5355 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5356 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5357 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5358 | image_create_info.flags = 0; |
| 5359 | |
| 5360 | // Introduce error by sending down a bogus width extent |
| 5361 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5362 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5363 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5364 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5365 | FAIL() << "Did not receive Error 'CreateImage extents exceed allowable limits for format'"; |
| 5366 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5367 | } |
| 5368 | } |
| 5369 | |
| 5370 | TEST_F(VkLayerTest, CreateImageResourceSizeViolation) |
| 5371 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5372 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5373 | "CreateImage resource size exceeds allowable maximum"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5374 | |
| 5375 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5376 | |
| 5377 | // Create an image |
| 5378 | VkImage image; |
| 5379 | |
| 5380 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5381 | const int32_t tex_width = 32; |
| 5382 | const int32_t tex_height = 32; |
| 5383 | |
| 5384 | VkImageCreateInfo image_create_info = {}; |
| 5385 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5386 | image_create_info.pNext = NULL; |
| 5387 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5388 | image_create_info.format = tex_format; |
| 5389 | image_create_info.extent.width = tex_width; |
| 5390 | image_create_info.extent.height = tex_height; |
| 5391 | image_create_info.extent.depth = 1; |
| 5392 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5393 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5394 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5395 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5396 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5397 | image_create_info.flags = 0; |
| 5398 | |
| 5399 | // Introduce error by sending down individually allowable values that result in a surface size |
| 5400 | // exceeding the device maximum |
| 5401 | image_create_info.extent.width = 8192; |
| 5402 | image_create_info.extent.height = 8192; |
| 5403 | image_create_info.extent.depth = 16; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5404 | image_create_info.arrayLayers = 4; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5405 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5406 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5407 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5408 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5409 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5410 | FAIL() << "Did not receive Error 'CreateImage resource size exceeds allowable maximum'"; |
| 5411 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5412 | } |
| 5413 | } |
| 5414 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5415 | TEST_F(VkLayerTest, UpdateBufferAlignment) |
| 5416 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5417 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 5418 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5419 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5420 | "dstOffset, is not a multiple of 4"); |
| 5421 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5422 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5423 | |
| 5424 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5425 | vk_testing::Buffer buffer; |
| 5426 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 5427 | |
| 5428 | BeginCommandBuffer(); |
| 5429 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5430 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5431 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5432 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 5433 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5434 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5435 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5436 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5437 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5438 | "dataSize, is not a multiple of 4"); |
| 5439 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5440 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5441 | |
| 5442 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5443 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dataSize, is not a multiple of 4'"; |
| 5444 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5445 | } |
| 5446 | EndCommandBuffer(); |
| 5447 | } |
| 5448 | |
| 5449 | TEST_F(VkLayerTest, FillBufferAlignment) |
| 5450 | { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5451 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5452 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5453 | |
| 5454 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5455 | |
| 5456 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5457 | vk_testing::Buffer buffer; |
| 5458 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 5459 | |
| 5460 | BeginCommandBuffer(); |
| 5461 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5462 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5463 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5464 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 5465 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5466 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5467 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5468 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5469 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5470 | "size, is not a multiple of 4"); |
| 5471 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5472 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5473 | |
| 5474 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5475 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize size, is not a multiple of 4'"; |
| 5476 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5477 | } |
| 5478 | EndCommandBuffer(); |
| 5479 | } |
| 5480 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5481 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5482 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5483 | #if IMAGE_TESTS |
| 5484 | TEST_F(VkLayerTest, InvalidImageView) |
| 5485 | { |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5486 | VkResult err; |
| 5487 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5488 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5489 | "vkCreateImageView called with baseMipLevel 10 "); |
| 5490 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5491 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5492 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5493 | // Create an image and try to create a view with bad baseMipLevel |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5494 | VkImage image; |
| 5495 | |
| 5496 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5497 | const int32_t tex_width = 32; |
| 5498 | const int32_t tex_height = 32; |
| 5499 | |
| 5500 | VkImageCreateInfo image_create_info = {}; |
| 5501 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5502 | image_create_info.pNext = NULL; |
| 5503 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5504 | image_create_info.format = tex_format; |
| 5505 | image_create_info.extent.width = tex_width; |
| 5506 | image_create_info.extent.height = tex_height; |
| 5507 | image_create_info.extent.depth = 1; |
| 5508 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5509 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5510 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5511 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5512 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5513 | image_create_info.flags = 0; |
| 5514 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5515 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5516 | ASSERT_VK_SUCCESS(err); |
| 5517 | |
| 5518 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5519 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5520 | image_view_create_info.image = image; |
| 5521 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5522 | image_view_create_info.format = tex_format; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5523 | image_view_create_info.subresourceRange.layerCount = 1; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5524 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5525 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5526 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5527 | |
| 5528 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5529 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5530 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5531 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5532 | FAIL() << "Did not receive Error 'vkCreateImageView called with baseMipLevel 10...'"; |
| 5533 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5534 | } |
| 5535 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5536 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5537 | TEST_F(VkLayerTest, InvalidImageViewAspect) |
| 5538 | { |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5539 | VkResult err; |
| 5540 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5541 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5542 | "vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set"); |
| 5543 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5544 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5545 | |
| 5546 | // Create an image and try to create a view with an invalid aspectMask |
| 5547 | VkImage image; |
| 5548 | |
| 5549 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5550 | const int32_t tex_width = 32; |
| 5551 | const int32_t tex_height = 32; |
| 5552 | |
| 5553 | VkImageCreateInfo image_create_info = {}; |
| 5554 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5555 | image_create_info.pNext = NULL; |
| 5556 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5557 | image_create_info.format = tex_format; |
| 5558 | image_create_info.extent.width = tex_width; |
| 5559 | image_create_info.extent.height = tex_height; |
| 5560 | image_create_info.extent.depth = 1; |
| 5561 | image_create_info.mipLevels = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5562 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5563 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5564 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5565 | image_create_info.flags = 0; |
| 5566 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5567 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5568 | ASSERT_VK_SUCCESS(err); |
| 5569 | |
| 5570 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5571 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5572 | image_view_create_info.image = image; |
| 5573 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5574 | image_view_create_info.format = tex_format; |
| 5575 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5576 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5577 | // Cause an error by setting an invalid image aspect |
| 5578 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 5579 | |
| 5580 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5581 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5582 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5583 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5584 | FAIL() << "Did not receive Error 'VkCreateImageView: Color image formats must have ...'"; |
| 5585 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5586 | } |
| 5587 | } |
| 5588 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5589 | TEST_F(VkLayerTest, CopyImageTypeMismatch) |
| 5590 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5591 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5592 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5593 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5594 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5595 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 5596 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5597 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5598 | |
| 5599 | // Create two images of different types and try to copy between them |
| 5600 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5601 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5602 | VkDeviceMemory srcMem; |
| 5603 | VkDeviceMemory destMem; |
| 5604 | VkMemoryRequirements memReqs; |
| 5605 | |
| 5606 | VkImageCreateInfo image_create_info = {}; |
| 5607 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5608 | image_create_info.pNext = NULL; |
| 5609 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5610 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5611 | image_create_info.extent.width = 32; |
| 5612 | image_create_info.extent.height = 32; |
| 5613 | image_create_info.extent.depth = 1; |
| 5614 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5615 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5616 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5617 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5618 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5619 | image_create_info.flags = 0; |
| 5620 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5621 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5622 | ASSERT_VK_SUCCESS(err); |
| 5623 | |
| 5624 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5625 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5626 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5627 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5628 | ASSERT_VK_SUCCESS(err); |
| 5629 | |
| 5630 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5631 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5632 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5633 | memAlloc.pNext = NULL; |
| 5634 | memAlloc.allocationSize = 0; |
| 5635 | memAlloc.memoryTypeIndex = 0; |
| 5636 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5637 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5638 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5639 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5640 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5641 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5642 | ASSERT_VK_SUCCESS(err); |
| 5643 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5644 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5645 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5646 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5647 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5648 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5649 | ASSERT_VK_SUCCESS(err); |
| 5650 | |
| 5651 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5652 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5653 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5654 | ASSERT_VK_SUCCESS(err); |
| 5655 | |
| 5656 | BeginCommandBuffer(); |
| 5657 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5658 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5659 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5660 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5661 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5662 | copyRegion.srcOffset.x = 0; |
| 5663 | copyRegion.srcOffset.y = 0; |
| 5664 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5665 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5666 | copyRegion.dstSubresource.mipLevel = 0; |
| 5667 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5668 | copyRegion.dstSubresource.layerCount = 0; |
| 5669 | copyRegion.dstOffset.x = 0; |
| 5670 | copyRegion.dstOffset.y = 0; |
| 5671 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5672 | copyRegion.extent.width = 1; |
| 5673 | copyRegion.extent.height = 1; |
| 5674 | copyRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5675 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5676 | EndCommandBuffer(); |
| 5677 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5678 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5679 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5680 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5681 | } |
| 5682 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5683 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5684 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5685 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5686 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5687 | } |
| 5688 | |
| 5689 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) |
| 5690 | { |
| 5691 | // TODO : Create two images with different format sizes and vkCmdCopyImage between them |
| 5692 | } |
| 5693 | |
| 5694 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) |
| 5695 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5696 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5697 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5698 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5699 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5700 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 5701 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5702 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5703 | |
| 5704 | // Create two images of different types and try to copy between them |
| 5705 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5706 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5707 | VkDeviceMemory srcMem; |
| 5708 | VkDeviceMemory destMem; |
| 5709 | VkMemoryRequirements memReqs; |
| 5710 | |
| 5711 | VkImageCreateInfo image_create_info = {}; |
| 5712 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5713 | image_create_info.pNext = NULL; |
| 5714 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5715 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5716 | image_create_info.extent.width = 32; |
| 5717 | image_create_info.extent.height = 32; |
| 5718 | image_create_info.extent.depth = 1; |
| 5719 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5720 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5721 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5722 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5723 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5724 | image_create_info.flags = 0; |
| 5725 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5726 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5727 | ASSERT_VK_SUCCESS(err); |
| 5728 | |
| 5729 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5730 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5731 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5732 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5733 | ASSERT_VK_SUCCESS(err); |
| 5734 | |
| 5735 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5736 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5737 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5738 | memAlloc.pNext = NULL; |
| 5739 | memAlloc.allocationSize = 0; |
| 5740 | memAlloc.memoryTypeIndex = 0; |
| 5741 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5742 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5743 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5744 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5745 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5746 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5747 | ASSERT_VK_SUCCESS(err); |
| 5748 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5749 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5750 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5751 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5752 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5753 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5754 | ASSERT_VK_SUCCESS(err); |
| 5755 | |
| 5756 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5757 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5758 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5759 | ASSERT_VK_SUCCESS(err); |
| 5760 | |
| 5761 | BeginCommandBuffer(); |
| 5762 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5763 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5764 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5765 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5766 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5767 | copyRegion.srcOffset.x = 0; |
| 5768 | copyRegion.srcOffset.y = 0; |
| 5769 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5770 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5771 | copyRegion.dstSubresource.mipLevel = 0; |
| 5772 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5773 | copyRegion.dstSubresource.layerCount = 0; |
| 5774 | copyRegion.dstOffset.x = 0; |
| 5775 | copyRegion.dstOffset.y = 0; |
| 5776 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5777 | copyRegion.extent.width = 1; |
| 5778 | copyRegion.extent.height = 1; |
| 5779 | copyRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5780 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5781 | EndCommandBuffer(); |
| 5782 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5783 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5784 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5785 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5786 | } |
| 5787 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5788 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5789 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5790 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5791 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5792 | } |
| 5793 | |
| 5794 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) |
| 5795 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5796 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5797 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5798 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5799 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5800 | "vkCmdResolveImage called with source sample count less than 2."); |
| 5801 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5802 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5803 | |
| 5804 | // Create two images of sample count 1 and try to Resolve between them |
| 5805 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5806 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5807 | VkDeviceMemory srcMem; |
| 5808 | VkDeviceMemory destMem; |
| 5809 | VkMemoryRequirements memReqs; |
| 5810 | |
| 5811 | VkImageCreateInfo image_create_info = {}; |
| 5812 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5813 | image_create_info.pNext = NULL; |
| 5814 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5815 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5816 | image_create_info.extent.width = 32; |
| 5817 | image_create_info.extent.height = 1; |
| 5818 | image_create_info.extent.depth = 1; |
| 5819 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5820 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5821 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5822 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5823 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5824 | image_create_info.flags = 0; |
| 5825 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5826 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5827 | ASSERT_VK_SUCCESS(err); |
| 5828 | |
| 5829 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5830 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5831 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5832 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5833 | ASSERT_VK_SUCCESS(err); |
| 5834 | |
| 5835 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5836 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5837 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5838 | memAlloc.pNext = NULL; |
| 5839 | memAlloc.allocationSize = 0; |
| 5840 | memAlloc.memoryTypeIndex = 0; |
| 5841 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5842 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5843 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5844 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5845 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5846 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5847 | ASSERT_VK_SUCCESS(err); |
| 5848 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5849 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5850 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5851 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5852 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5853 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5854 | ASSERT_VK_SUCCESS(err); |
| 5855 | |
| 5856 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5857 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5858 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5859 | ASSERT_VK_SUCCESS(err); |
| 5860 | |
| 5861 | BeginCommandBuffer(); |
| 5862 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5863 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5864 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5865 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5866 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5867 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5868 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5869 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5870 | resolveRegion.srcOffset.x = 0; |
| 5871 | resolveRegion.srcOffset.y = 0; |
| 5872 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5873 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5874 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5875 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5876 | resolveRegion.dstSubresource.layerCount = 0; |
| 5877 | resolveRegion.dstOffset.x = 0; |
| 5878 | resolveRegion.dstOffset.y = 0; |
| 5879 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5880 | resolveRegion.extent.width = 1; |
| 5881 | resolveRegion.extent.height = 1; |
| 5882 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5883 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5884 | EndCommandBuffer(); |
| 5885 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5886 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5887 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with source sample count less than 2.'"; |
| 5888 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5889 | } |
| 5890 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5891 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5892 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5893 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5894 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5895 | } |
| 5896 | |
| 5897 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) |
| 5898 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5899 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5900 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5901 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5902 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5903 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 5904 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5905 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5906 | |
| 5907 | // Create two images of sample count 2 and try to Resolve between them |
| 5908 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5909 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5910 | VkDeviceMemory srcMem; |
| 5911 | VkDeviceMemory destMem; |
| 5912 | VkMemoryRequirements memReqs; |
| 5913 | |
| 5914 | VkImageCreateInfo image_create_info = {}; |
| 5915 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5916 | image_create_info.pNext = NULL; |
| 5917 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5918 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5919 | image_create_info.extent.width = 32; |
| 5920 | image_create_info.extent.height = 1; |
| 5921 | image_create_info.extent.depth = 1; |
| 5922 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5923 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5924 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5925 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5926 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5927 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5928 | image_create_info.flags = 0; |
| 5929 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5930 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5931 | ASSERT_VK_SUCCESS(err); |
| 5932 | |
| 5933 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5934 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5935 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5936 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5937 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5938 | ASSERT_VK_SUCCESS(err); |
| 5939 | |
| 5940 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5941 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5942 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5943 | memAlloc.pNext = NULL; |
| 5944 | memAlloc.allocationSize = 0; |
| 5945 | memAlloc.memoryTypeIndex = 0; |
| 5946 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5947 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5948 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5949 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5950 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5951 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5952 | ASSERT_VK_SUCCESS(err); |
| 5953 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5954 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5955 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5956 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5957 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5958 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5959 | ASSERT_VK_SUCCESS(err); |
| 5960 | |
| 5961 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5962 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5963 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5964 | ASSERT_VK_SUCCESS(err); |
| 5965 | |
| 5966 | BeginCommandBuffer(); |
| 5967 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5968 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5969 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5970 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5971 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5972 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5973 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5974 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5975 | resolveRegion.srcOffset.x = 0; |
| 5976 | resolveRegion.srcOffset.y = 0; |
| 5977 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5978 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5979 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5980 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5981 | resolveRegion.dstSubresource.layerCount = 0; |
| 5982 | resolveRegion.dstOffset.x = 0; |
| 5983 | resolveRegion.dstOffset.y = 0; |
| 5984 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5985 | resolveRegion.extent.width = 1; |
| 5986 | resolveRegion.extent.height = 1; |
| 5987 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5988 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5989 | EndCommandBuffer(); |
| 5990 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5991 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5992 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with dest sample count greater than 1.'"; |
| 5993 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5994 | } |
| 5995 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5996 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5997 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5998 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5999 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6000 | } |
| 6001 | |
| 6002 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) |
| 6003 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6004 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6005 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6006 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6007 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6008 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 6009 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6010 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6011 | |
| 6012 | // Create two images of different types and try to copy between them |
| 6013 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6014 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6015 | VkDeviceMemory srcMem; |
| 6016 | VkDeviceMemory destMem; |
| 6017 | VkMemoryRequirements memReqs; |
| 6018 | |
| 6019 | VkImageCreateInfo image_create_info = {}; |
| 6020 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6021 | image_create_info.pNext = NULL; |
| 6022 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6023 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6024 | image_create_info.extent.width = 32; |
| 6025 | image_create_info.extent.height = 1; |
| 6026 | image_create_info.extent.depth = 1; |
| 6027 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 6028 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6029 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6030 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 6031 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6032 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6033 | image_create_info.flags = 0; |
| 6034 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6035 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6036 | ASSERT_VK_SUCCESS(err); |
| 6037 | |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 6038 | // Set format to something other than source image |
| 6039 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 6040 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6041 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6042 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6043 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6044 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6045 | ASSERT_VK_SUCCESS(err); |
| 6046 | |
| 6047 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6048 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6049 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6050 | memAlloc.pNext = NULL; |
| 6051 | memAlloc.allocationSize = 0; |
| 6052 | memAlloc.memoryTypeIndex = 0; |
| 6053 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6054 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6055 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6056 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 6057 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6058 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6059 | ASSERT_VK_SUCCESS(err); |
| 6060 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6061 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6062 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6063 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 6064 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6065 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6066 | ASSERT_VK_SUCCESS(err); |
| 6067 | |
| 6068 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6069 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6070 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6071 | ASSERT_VK_SUCCESS(err); |
| 6072 | |
| 6073 | BeginCommandBuffer(); |
| 6074 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 6075 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6076 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 6077 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6078 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6079 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6080 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6081 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6082 | resolveRegion.srcOffset.x = 0; |
| 6083 | resolveRegion.srcOffset.y = 0; |
| 6084 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6085 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6086 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6087 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6088 | resolveRegion.dstSubresource.layerCount = 0; |
| 6089 | resolveRegion.dstOffset.x = 0; |
| 6090 | resolveRegion.dstOffset.y = 0; |
| 6091 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6092 | resolveRegion.extent.width = 1; |
| 6093 | resolveRegion.extent.height = 1; |
| 6094 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6095 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6096 | EndCommandBuffer(); |
| 6097 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6098 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6099 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest formats.'"; |
| 6100 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6101 | } |
| 6102 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6103 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6104 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6105 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6106 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6107 | } |
| 6108 | |
| 6109 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) |
| 6110 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6111 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6112 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6113 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6114 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6115 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 6116 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6117 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6118 | |
| 6119 | // Create two images of different types and try to copy between them |
| 6120 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6121 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6122 | VkDeviceMemory srcMem; |
| 6123 | VkDeviceMemory destMem; |
| 6124 | VkMemoryRequirements memReqs; |
| 6125 | |
| 6126 | VkImageCreateInfo image_create_info = {}; |
| 6127 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6128 | image_create_info.pNext = NULL; |
| 6129 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6130 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6131 | image_create_info.extent.width = 32; |
| 6132 | image_create_info.extent.height = 1; |
| 6133 | image_create_info.extent.depth = 1; |
| 6134 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 6135 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6136 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6137 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 6138 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6139 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6140 | image_create_info.flags = 0; |
| 6141 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6142 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6143 | ASSERT_VK_SUCCESS(err); |
| 6144 | |
| 6145 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 6146 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6147 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6148 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6149 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6150 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6151 | ASSERT_VK_SUCCESS(err); |
| 6152 | |
| 6153 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6154 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6155 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6156 | memAlloc.pNext = NULL; |
| 6157 | memAlloc.allocationSize = 0; |
| 6158 | memAlloc.memoryTypeIndex = 0; |
| 6159 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6160 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6161 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6162 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 6163 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6164 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6165 | ASSERT_VK_SUCCESS(err); |
| 6166 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6167 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6168 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6169 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 6170 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6171 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6172 | ASSERT_VK_SUCCESS(err); |
| 6173 | |
| 6174 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6175 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6176 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6177 | ASSERT_VK_SUCCESS(err); |
| 6178 | |
| 6179 | BeginCommandBuffer(); |
| 6180 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 6181 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6182 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 6183 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6184 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6185 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6186 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6187 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6188 | resolveRegion.srcOffset.x = 0; |
| 6189 | resolveRegion.srcOffset.y = 0; |
| 6190 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6191 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6192 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6193 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6194 | resolveRegion.dstSubresource.layerCount = 0; |
| 6195 | resolveRegion.dstOffset.x = 0; |
| 6196 | resolveRegion.dstOffset.y = 0; |
| 6197 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6198 | resolveRegion.extent.width = 1; |
| 6199 | resolveRegion.extent.height = 1; |
| 6200 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6201 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6202 | EndCommandBuffer(); |
| 6203 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6204 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6205 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest image types.'"; |
| 6206 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6207 | } |
| 6208 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6209 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6210 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6211 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6212 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6213 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6214 | |
| 6215 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) |
| 6216 | { |
| 6217 | // Create a single Image descriptor and cause it to first hit an error due |
| 6218 | // to using a DS format, then cause it to hit error due to COLOR_BIT not set in aspect |
| 6219 | // The image format check comes 2nd in validation so we trigger it first, |
| 6220 | // then when we cause aspect fail next, bad format check will be preempted |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6221 | VkResult err; |
| 6222 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6223 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6224 | "Combination depth/stencil image formats can have only the "); |
| 6225 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6226 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6227 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6228 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6229 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6230 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6231 | |
| 6232 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6233 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6234 | ds_pool_ci.pNext = NULL; |
| 6235 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6236 | ds_pool_ci.poolSizeCount = 1; |
| 6237 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6238 | |
| 6239 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6240 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6241 | ASSERT_VK_SUCCESS(err); |
| 6242 | |
| 6243 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6244 | dsl_binding.binding = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6245 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6246 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6247 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6248 | dsl_binding.pImmutableSamplers = NULL; |
| 6249 | |
| 6250 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6251 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6252 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6253 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6254 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6255 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6256 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6257 | ASSERT_VK_SUCCESS(err); |
| 6258 | |
| 6259 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6260 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6261 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6262 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6263 | alloc_info.descriptorPool = ds_pool; |
| 6264 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6265 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6266 | ASSERT_VK_SUCCESS(err); |
| 6267 | |
| 6268 | VkImage image_bad; |
| 6269 | VkImage image_good; |
| 6270 | // One bad format and one good format for Color attachment |
| 6271 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 6272 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
| 6273 | const int32_t tex_width = 32; |
| 6274 | const int32_t tex_height = 32; |
| 6275 | |
| 6276 | VkImageCreateInfo image_create_info = {}; |
| 6277 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6278 | image_create_info.pNext = NULL; |
| 6279 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6280 | image_create_info.format = tex_format_bad; |
| 6281 | image_create_info.extent.width = tex_width; |
| 6282 | image_create_info.extent.height = tex_height; |
| 6283 | image_create_info.extent.depth = 1; |
| 6284 | image_create_info.mipLevels = 1; |
| 6285 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6286 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6287 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6288 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 6289 | image_create_info.flags = 0; |
| 6290 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6291 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6292 | ASSERT_VK_SUCCESS(err); |
| 6293 | image_create_info.format = tex_format_good; |
| 6294 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6295 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6296 | ASSERT_VK_SUCCESS(err); |
| 6297 | |
| 6298 | VkImageViewCreateInfo image_view_create_info = {}; |
| 6299 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6300 | image_view_create_info.image = image_bad; |
| 6301 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6302 | image_view_create_info.format = tex_format_bad; |
| 6303 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 6304 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6305 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6306 | image_view_create_info.subresourceRange.levelCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6307 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6308 | |
| 6309 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6310 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6311 | |
| 6312 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6313 | FAIL() << "Did not receive Error 'Combination depth-stencil image formats can have only the....'"; |
| 6314 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6315 | } |
| 6316 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6317 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 6318 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6319 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6320 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6321 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6322 | #endif // IMAGE_TESTS |
| 6323 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 6324 | int main(int argc, char **argv) { |
| 6325 | int result; |
| 6326 | |
| 6327 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 6328 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 6329 | |
| 6330 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 6331 | |
| 6332 | result = RUN_ALL_TESTS(); |
| 6333 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 6334 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 6335 | return result; |
| 6336 | } |