Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1 | /* |
2 | * Copyright (c) 2015-2016 The Khronos Group Inc. | ||||
3 | * Copyright (c) 2015-2016 Valve Corporation | ||||
4 | * Copyright (c) 2015-2016 LunarG, Inc. | ||||
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5 | * Copyright (c) 2015-2016 Google, Inc. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | * you may not use this file except in compliance with the License. | ||||
9 | * You may obtain a copy of the License at | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12 | * |
13 | * Author: Chia-I Wu <olvaffe@gmail.com> | ||||
14 | * Author: Chris Forbes <chrisf@ijw.co.nz> | ||||
15 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> | ||||
16 | * Author: Mark Lobodzinski <mark@lunarg.com> | ||||
17 | * Author: Mike Stroyan <mike@LunarG.com> | ||||
18 | * Author: Tobin Ehlis <tobine@google.com> | ||||
19 | * Author: Tony Barbour <tony@LunarG.com> | ||||
20 | */ | ||||
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 21 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 22 | #ifdef ANDROID |
23 | #include "vulkan_wrapper.h" | ||||
24 | #else | ||||
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 25 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 26 | #endif |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 27 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 28 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 29 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 30 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 31 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 32 | #define GLM_FORCE_RADIANS |
33 | #include "glm/glm.hpp" | ||||
34 | #include <glm/gtc/matrix_transform.hpp> | ||||
35 | |||||
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 36 | #define PARAMETER_VALIDATION_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 37 | #define MEM_TRACKER_TESTS 1 |
38 | #define OBJ_TRACKER_TESTS 1 | ||||
39 | #define DRAW_STATE_TESTS 1 | ||||
40 | #define THREADING_TESTS 1 | ||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 41 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 42 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 43 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | //-------------------------------------------------------------------------------------- |
46 | // Mesh and VertexFormat Data | ||||
47 | //-------------------------------------------------------------------------------------- | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 48 | struct Vertex { |
49 | float posX, posY, posZ, posW; // Position data | ||||
50 | float r, g, b, a; // Color | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 51 | }; |
52 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 53 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 54 | |
55 | typedef enum _BsoFailSelect { | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 56 | BsoFailNone = 0x00000000, |
57 | BsoFailLineWidth = 0x00000001, | ||||
58 | BsoFailDepthBias = 0x00000002, | ||||
59 | BsoFailViewport = 0x00000004, | ||||
60 | BsoFailScissor = 0x00000008, | ||||
61 | BsoFailBlend = 0x00000010, | ||||
62 | BsoFailDepthBounds = 0x00000020, | ||||
63 | BsoFailStencilReadMask = 0x00000040, | ||||
64 | BsoFailStencilWriteMask = 0x00000080, | ||||
65 | BsoFailStencilReference = 0x00000100, | ||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 66 | BsoFailCmdClearAttachments = 0x00000200, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 67 | } BsoFailSelect; |
68 | |||||
69 | struct vktriangle_vs_uniform { | ||||
70 | // Must start with MVP | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 71 | float mvp[4][4]; |
72 | float position[3][4]; | ||||
73 | float color[3][4]; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 74 | }; |
75 | |||||
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 76 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 77 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 78 | "vec2 vertices[3];\n" |
79 | "out gl_PerVertex {\n" | ||||
80 | " vec4 gl_Position;\n" | ||||
81 | "};\n" | ||||
82 | "void main() {\n" | ||||
83 | " vertices[0] = vec2(-1.0, -1.0);\n" | ||||
84 | " vertices[1] = vec2( 1.0, -1.0);\n" | ||||
85 | " vertices[2] = vec2( 0.0, 1.0);\n" | ||||
86 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" | ||||
87 | "}\n"; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 88 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 89 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 90 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 91 | "\n" |
92 | "layout(location = 0) out vec4 uFragColor;\n" | ||||
93 | "void main(){\n" | ||||
94 | " uFragColor = vec4(0,1,0,1);\n" | ||||
95 | "}\n"; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 96 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 97 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
98 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, | ||||
99 | uint64_t srcObject, size_t location, int32_t msgCode, | ||||
100 | const char *pLayerPrefix, const char *pMsg, void *pUserData); | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 101 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 102 | // ******************************************************** |
103 | // ErrorMonitor Usage: | ||||
104 | // | ||||
105 | // Call SetDesiredFailureMsg with a string to be compared against all | ||||
106 | // encountered log messages. Passing NULL will match all log messages. | ||||
107 | // logMsg will return true for skipCall only if msg is matched or NULL. | ||||
108 | // | ||||
109 | // Call DesiredMsgFound to determine if the desired failure message | ||||
110 | // was encountered. | ||||
111 | |||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 112 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 113 | public: |
114 | ErrorMonitor() { | ||||
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 115 | test_platform_thread_create_mutex(&m_mutex); |
116 | test_platform_thread_lock_mutex(&m_mutex); | ||||
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 117 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 118 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 119 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 120 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 121 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 122 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
123 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 124 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 125 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 126 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 127 | m_failureMsg.clear(); |
128 | m_otherMsgs.clear(); | ||||
129 | m_desiredMsg = msgString; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 130 | m_msgFound = VK_FALSE; |
131 | m_msgFlags = msgFlags; | ||||
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 132 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 133 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 134 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 135 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 136 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 137 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 138 | if (m_bailout != NULL) { |
139 | *m_bailout = true; | ||||
140 | } | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 141 | string errorString(msgString); |
142 | if (msgFlags & m_msgFlags) { | ||||
143 | if (errorString.find(m_desiredMsg) != string::npos) { | ||||
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 144 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
145 | m_otherMsgs.push_back(m_failureMsg); | ||||
146 | } | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 147 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 148 | m_msgFound = VK_TRUE; |
149 | result = VK_TRUE; | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 150 | } else { |
151 | m_otherMsgs.push_back(errorString); | ||||
152 | } | ||||
153 | } | ||||
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 154 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 155 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 156 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 158 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 159 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 160 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 161 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 162 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 163 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 164 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 165 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 166 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 167 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
168 | cout << "Other error messages logged for this test were:" << endl; | ||||
169 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { | ||||
170 | cout << " " << *iter << endl; | ||||
171 | } | ||||
172 | } | ||||
173 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 174 | /* helpers */ |
175 | |||||
176 | void ExpectSuccess() { | ||||
177 | // match anything | ||||
178 | SetDesiredFailureMsg(~0u, ""); | ||||
179 | } | ||||
180 | |||||
181 | void VerifyFound() { | ||||
182 | // Not seeing the desired message is a failure. /Before/ throwing, dump | ||||
183 | // any other messages. | ||||
184 | if (!DesiredMsgFound()) { | ||||
185 | DumpFailureMsgs(); | ||||
186 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; | ||||
187 | } | ||||
188 | } | ||||
189 | |||||
190 | void VerifyNotFound() { | ||||
191 | // ExpectSuccess() configured us to match anything. Any error is a | ||||
192 | // failure. | ||||
193 | if (DesiredMsgFound()) { | ||||
194 | DumpFailureMsgs(); | ||||
195 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); | ||||
196 | } | ||||
197 | } | ||||
198 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 199 | private: |
200 | VkFlags m_msgFlags; | ||||
201 | string m_desiredMsg; | ||||
202 | string m_failureMsg; | ||||
203 | vector<string> m_otherMsgs; | ||||
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 204 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 205 | bool *m_bailout; |
206 | VkBool32 m_msgFound; | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 207 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 208 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 209 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
210 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, | ||||
211 | uint64_t srcObject, size_t location, int32_t msgCode, | ||||
212 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { | ||||
213 | if (msgFlags & | ||||
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 214 | (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 215 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 216 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 217 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 218 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 219 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 220 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 221 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 222 | class VkLayerTest : public VkRenderFramework { |
223 | public: | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 224 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
225 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 226 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
227 | BsoFailSelect failMask); | ||||
228 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, | ||||
229 | VkPipelineObj &pipelineobj, | ||||
230 | VkDescriptorSetObj &descriptorSet, | ||||
231 | BsoFailSelect failMask); | ||||
232 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, | ||||
233 | VkDescriptorSetObj &descriptorSet, | ||||
234 | BsoFailSelect failMask) { | ||||
235 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, | ||||
236 | failMask); | ||||
237 | } | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 238 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 239 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 240 | VkResult BeginCommandBuffer() { |
241 | return BeginCommandBuffer(*m_commandBuffer); | ||||
242 | } | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 243 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 244 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
245 | uint32_t firstVertex, uint32_t firstInstance) { | ||||
246 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, | ||||
247 | firstInstance); | ||||
248 | } | ||||
249 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, | ||||
250 | uint32_t firstIndex, int32_t vertexOffset, | ||||
251 | uint32_t firstInstance) { | ||||
252 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, | ||||
253 | vertexOffset, firstInstance); | ||||
254 | } | ||||
Mark Mueller | dfe3755 | 2016-07-07 14:47:42 -0600 | [diff] [blame] | 255 | void QueueCommandBuffer(bool checkSuccess = true) { |
256 | m_commandBuffer->QueueCommandBuffer(checkSuccess); } | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 257 | void QueueCommandBuffer(const VkFence &fence) { |
258 | m_commandBuffer->QueueCommandBuffer(fence); | ||||
259 | } | ||||
260 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, | ||||
261 | VkDeviceSize offset, uint32_t binding) { | ||||
262 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); | ||||
263 | } | ||||
264 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { | ||||
265 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); | ||||
266 | } | ||||
267 | |||||
268 | protected: | ||||
269 | ErrorMonitor *m_errorMonitor; | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 270 | bool m_enableWSI; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 271 | |
272 | virtual void SetUp() { | ||||
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 273 | std::vector<const char *> instance_layer_names; |
274 | std::vector<const char *> device_layer_names; | ||||
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 275 | std::vector<const char *> instance_extension_names; |
276 | std::vector<const char *> device_extension_names; | ||||
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 277 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 278 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 279 | /* |
280 | * Since CreateDbgMsgCallback is an instance level extension call | ||||
281 | * any extension / layer that utilizes that feature also needs | ||||
282 | * to be enabled at create instance time. | ||||
283 | */ | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 284 | // Use Threading layer first to protect others from |
285 | // ThreadCommandBufferCollision test | ||||
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 290 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 291 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 292 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 293 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 296 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 297 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 298 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 299 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 300 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 301 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 302 | if (m_enableWSI) { |
303 | instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME); | ||||
304 | device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); | ||||
305 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM | ||||
306 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) | ||||
307 | instance_extension_names.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); | ||||
308 | #endif // VK_USE_PLATFORM_ANDROID_KHR | ||||
309 | #if defined(VK_USE_PLATFORM_MIR_KHR) | ||||
310 | instance_extension_names.push_back(VK_KHR_MIR_SURFACE_EXTENSION_NAME); | ||||
311 | #endif // VK_USE_PLATFORM_MIR_KHR | ||||
312 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) | ||||
313 | instance_extension_names.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); | ||||
314 | #endif // VK_USE_PLATFORM_WAYLAND_KHR | ||||
315 | #if defined(VK_USE_PLATFORM_WIN32_KHR) | ||||
316 | instance_extension_names.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); | ||||
317 | #endif // VK_USE_PLATFORM_WIN32_KHR | ||||
318 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM | ||||
319 | #if defined(VK_USE_PLATFORM_XCB_KHR) | ||||
320 | instance_extension_names.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); | ||||
321 | #elif defined(VK_USE_PLATFORM_XLIB_KHR) | ||||
322 | instance_extension_names.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); | ||||
323 | #endif // VK_USE_PLATFORM_XLIB_KHR | ||||
324 | } | ||||
325 | |||||
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 326 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 327 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 328 | this->app_info.pApplicationName = "layer_tests"; |
329 | this->app_info.applicationVersion = 1; | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 330 | this->app_info.pEngineName = "unittest"; |
331 | this->app_info.engineVersion = 1; | ||||
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 332 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 333 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 334 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 335 | InitFramework(instance_layer_names, device_layer_names, |
336 | instance_extension_names, device_extension_names, | ||||
337 | myDbgFunc, m_errorMonitor); | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 338 | } |
339 | |||||
340 | virtual void TearDown() { | ||||
341 | // Clean up resources before we reset | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 342 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 343 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 344 | } |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 345 | |
346 | VkLayerTest() { | ||||
347 | m_enableWSI = false; | ||||
348 | } | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 349 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 350 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 351 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 352 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 353 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 354 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 355 | |
356 | /* | ||||
357 | * For render test all drawing happens in a single render pass | ||||
358 | * on a single command buffer. | ||||
359 | */ | ||||
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 360 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 361 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 362 | } |
363 | |||||
364 | return result; | ||||
365 | } | ||||
366 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 367 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 368 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 369 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 370 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 371 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 372 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 373 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 374 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 375 | |
376 | return result; | ||||
377 | } | ||||
378 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 379 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
380 | const char *fragShaderText, | ||||
381 | BsoFailSelect failMask) { | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 382 | // Create identity matrix |
383 | int i; | ||||
384 | struct vktriangle_vs_uniform data; | ||||
385 | |||||
386 | glm::mat4 Projection = glm::mat4(1.0f); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 387 | glm::mat4 View = glm::mat4(1.0f); |
388 | glm::mat4 Model = glm::mat4(1.0f); | ||||
389 | glm::mat4 MVP = Projection * View * Model; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 390 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 391 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 392 | |
393 | memcpy(&data.mvp, &MVP[0][0], matrixSize); | ||||
394 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 395 | static const Vertex tri_data[] = { |
396 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, | ||||
397 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, | ||||
398 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 399 | }; |
400 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 401 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 402 | data.position[i][0] = tri_data[i].posX; |
403 | data.position[i][1] = tri_data[i].posY; | ||||
404 | data.position[i][2] = tri_data[i].posZ; | ||||
405 | data.position[i][3] = tri_data[i].posW; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 406 | data.color[i][0] = tri_data[i].r; |
407 | data.color[i][1] = tri_data[i].g; | ||||
408 | data.color[i][2] = tri_data[i].b; | ||||
409 | data.color[i][3] = tri_data[i].a; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 410 | } |
411 | |||||
412 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
413 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
414 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 415 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
416 | (const void *)&data); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 417 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 418 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
419 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
420 | this); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 421 | |
422 | VkPipelineObj pipelineobj(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 423 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 424 | pipelineobj.AddShader(&vs); |
425 | pipelineobj.AddShader(&ps); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 426 | if (failMask & BsoFailLineWidth) { |
427 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 428 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
429 | ia_state.sType = | ||||
430 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
431 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; | ||||
432 | pipelineobj.SetInputAssembly(&ia_state); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 433 | } |
434 | if (failMask & BsoFailDepthBias) { | ||||
435 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 436 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
437 | rs_state.sType = | ||||
438 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
439 | rs_state.depthBiasEnable = VK_TRUE; | ||||
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 440 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 441 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 442 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 443 | // Viewport and scissors must stay in synch or other errors will occur than |
444 | // the ones we want | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 445 | if (failMask & BsoFailViewport) { |
446 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 447 | m_viewports.clear(); |
448 | m_scissors.clear(); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 449 | } |
450 | if (failMask & BsoFailScissor) { | ||||
451 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 452 | m_scissors.clear(); |
453 | m_viewports.clear(); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 454 | } |
455 | if (failMask & BsoFailBlend) { | ||||
456 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 457 | VkPipelineColorBlendAttachmentState att_state = {}; |
458 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; | ||||
459 | att_state.blendEnable = VK_TRUE; | ||||
460 | pipelineobj.AddColorAttachment(0, &att_state); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 461 | } |
462 | if (failMask & BsoFailDepthBounds) { | ||||
463 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); | ||||
464 | } | ||||
465 | if (failMask & BsoFailStencilReadMask) { | ||||
466 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); | ||||
467 | } | ||||
468 | if (failMask & BsoFailStencilWriteMask) { | ||||
469 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); | ||||
470 | } | ||||
471 | if (failMask & BsoFailStencilReference) { | ||||
472 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); | ||||
473 | } | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 474 | |
475 | VkDescriptorSetObj descriptorSet(m_device); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 476 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
477 | constantBuffer); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 478 | |
479 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 480 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 481 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 482 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 483 | |
484 | // render triangle | ||||
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 485 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 486 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 487 | if (failMask & BsoFailCmdClearAttachments) { |
488 | VkClearAttachment color_attachment = {}; | ||||
489 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
490 | color_attachment.colorAttachment = 1; // Someone who knew what they were doing would use 0 for the index; | ||||
491 | VkClearRect clear_rect = {{{0, 0}, {static_cast<uint32_t>(m_width), static_cast<uint32_t>(m_height)}}, 0, 0}; | ||||
492 | |||||
493 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, | ||||
494 | &color_attachment, 1, &clear_rect); | ||||
495 | } | ||||
496 | |||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 497 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 498 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 499 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 500 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 501 | } |
502 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 503 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
504 | VkPipelineObj &pipelineobj, | ||||
505 | VkDescriptorSetObj &descriptorSet, | ||||
506 | BsoFailSelect failMask) { | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 507 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 508 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
509 | m_stencil_clear_color, m_depthStencil); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 510 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 511 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
512 | m_stencil_clear_color, NULL); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 513 | } |
514 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 515 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 516 | // Make sure depthWriteEnable is set so that Depth fail test will work |
517 | // correctly | ||||
518 | // Make sure stencilTestEnable is set so that Stencil fail test will work | ||||
519 | // correctly | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 520 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 521 | stencil.failOp = VK_STENCIL_OP_KEEP; |
522 | stencil.passOp = VK_STENCIL_OP_KEEP; | ||||
523 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; | ||||
524 | stencil.compareOp = VK_COMPARE_OP_NEVER; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 525 | |
526 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; | ||||
527 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 528 | ds_ci.pNext = NULL; |
529 | ds_ci.depthTestEnable = VK_FALSE; | ||||
530 | ds_ci.depthWriteEnable = VK_TRUE; | ||||
531 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; | ||||
532 | ds_ci.depthBoundsTestEnable = VK_FALSE; | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 533 | if (failMask & BsoFailDepthBounds) { |
534 | ds_ci.depthBoundsTestEnable = VK_TRUE; | ||||
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 535 | ds_ci.maxDepthBounds = 0.0f; |
536 | ds_ci.minDepthBounds = 0.0f; | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 537 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 538 | ds_ci.stencilTestEnable = VK_TRUE; |
539 | ds_ci.front = stencil; | ||||
540 | ds_ci.back = stencil; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 541 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 542 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 543 | pipelineobj.SetViewport(m_viewports); |
544 | pipelineobj.SetScissor(m_scissors); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 545 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 546 | VkResult err = pipelineobj.CreateVKPipeline( |
547 | descriptorSet.GetPipelineLayout(), renderPass()); | ||||
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 548 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 549 | commandBuffer->BindPipeline(pipelineobj); |
550 | commandBuffer->BindDescriptorSet(descriptorSet); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 551 | } |
552 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 553 | class VkWsiEnabledLayerTest : public VkLayerTest { |
554 | public: | ||||
555 | protected: | ||||
556 | VkWsiEnabledLayerTest() { | ||||
557 | m_enableWSI = true; | ||||
558 | } | ||||
559 | }; | ||||
560 | |||||
Mark Mueller | dfe3755 | 2016-07-07 14:47:42 -0600 | [diff] [blame] | 561 | class VkBufferTest { |
562 | public: | ||||
563 | enum eTestEnFlags { | ||||
564 | eDoubleDelete, | ||||
565 | eInvalidDeviceOffset, | ||||
566 | eInvalidMemoryOffset, | ||||
567 | eBindNullBuffer, | ||||
568 | eFreeInvalidHandle, | ||||
569 | }; | ||||
570 | |||||
571 | enum eTestConditions { | ||||
572 | eOffsetAlignment = 1 | ||||
573 | }; | ||||
574 | |||||
575 | static bool GetTestConditionValid(VkDeviceObj *aVulkanDevice, | ||||
576 | eTestEnFlags aTestFlag, | ||||
577 | VkBufferUsageFlags aBufferUsage = 0) { | ||||
578 | if (eInvalidDeviceOffset != aTestFlag && | ||||
579 | eInvalidMemoryOffset != aTestFlag) { | ||||
580 | return true; | ||||
581 | } | ||||
582 | VkDeviceSize offset_limit = 0; | ||||
583 | if (eInvalidMemoryOffset == aTestFlag) { | ||||
584 | VkBuffer vulkanBuffer; | ||||
585 | VkBufferCreateInfo buffer_create_info = {}; | ||||
586 | buffer_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
587 | buffer_create_info.size = 32; | ||||
588 | buffer_create_info.usage = aBufferUsage; | ||||
589 | |||||
590 | vkCreateBuffer(aVulkanDevice->device(), &buffer_create_info, nullptr, | ||||
591 | &vulkanBuffer); | ||||
592 | VkMemoryRequirements memory_reqs = {0}; | ||||
593 | |||||
594 | vkGetBufferMemoryRequirements(aVulkanDevice->device(), | ||||
595 | vulkanBuffer, &memory_reqs); | ||||
596 | vkDestroyBuffer(aVulkanDevice->device(), vulkanBuffer, nullptr); | ||||
597 | offset_limit = memory_reqs.alignment; | ||||
598 | } | ||||
599 | else if ((VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | | ||||
600 | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT) & aBufferUsage) { | ||||
601 | offset_limit = | ||||
602 | aVulkanDevice->props.limits.minTexelBufferOffsetAlignment; | ||||
603 | } else if (VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT & aBufferUsage) { | ||||
604 | offset_limit = | ||||
605 | aVulkanDevice->props.limits.minUniformBufferOffsetAlignment; | ||||
606 | } else if (VK_BUFFER_USAGE_STORAGE_BUFFER_BIT & aBufferUsage) { | ||||
607 | offset_limit = | ||||
608 | aVulkanDevice->props.limits.minStorageBufferOffsetAlignment; | ||||
609 | } | ||||
610 | if (eOffsetAlignment < offset_limit) { | ||||
611 | return true; | ||||
612 | } | ||||
613 | return false; | ||||
614 | } | ||||
615 | |||||
616 | // A constructor which performs validation tests within construction. | ||||
617 | VkBufferTest(VkDeviceObj *aVulkanDevice, | ||||
618 | VkBufferUsageFlags aBufferUsage, | ||||
619 | eTestEnFlags aTestFlag) | ||||
620 | : AllocateCurrent(false), BoundCurrent(false), | ||||
621 | CreateCurrent(false), VulkanDevice(aVulkanDevice->device()) { | ||||
622 | |||||
623 | if (eBindNullBuffer == aTestFlag) { | ||||
624 | VulkanMemory = 0; | ||||
625 | vkBindBufferMemory(VulkanDevice, VulkanBuffer, VulkanMemory, 0); | ||||
626 | } else { | ||||
627 | VkBufferCreateInfo buffer_create_info = {}; | ||||
628 | buffer_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
629 | buffer_create_info.size = 32; | ||||
630 | buffer_create_info.usage = aBufferUsage; | ||||
631 | |||||
632 | vkCreateBuffer(VulkanDevice, &buffer_create_info, nullptr, | ||||
633 | &VulkanBuffer); | ||||
634 | |||||
635 | CreateCurrent = true; | ||||
636 | |||||
637 | VkMemoryRequirements memory_requirements; | ||||
638 | vkGetBufferMemoryRequirements(VulkanDevice, VulkanBuffer, | ||||
639 | &memory_requirements); | ||||
640 | |||||
641 | VkMemoryAllocateInfo memory_allocate_info = {}; | ||||
642 | memory_allocate_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
643 | memory_allocate_info.allocationSize = memory_requirements.size; | ||||
644 | bool pass = aVulkanDevice->phy(). | ||||
645 | set_memory_type(memory_requirements.memoryTypeBits, | ||||
646 | &memory_allocate_info, | ||||
647 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
648 | if (!pass) { | ||||
649 | vkDestroyBuffer(VulkanDevice, VulkanBuffer, nullptr); | ||||
650 | return; | ||||
651 | } | ||||
652 | |||||
653 | vkAllocateMemory(VulkanDevice, &memory_allocate_info, NULL, | ||||
654 | &VulkanMemory); | ||||
655 | AllocateCurrent = true; | ||||
656 | // NB: 1 is intentionally an invalid offset value | ||||
657 | const bool offset_en = eInvalidDeviceOffset == aTestFlag || | ||||
658 | eInvalidMemoryOffset == aTestFlag; | ||||
659 | vkBindBufferMemory(VulkanDevice, VulkanBuffer, VulkanMemory, | ||||
660 | offset_en ? eOffsetAlignment : 0); | ||||
661 | BoundCurrent = true; | ||||
662 | |||||
663 | InvalidDeleteEn = (eFreeInvalidHandle == aTestFlag); | ||||
664 | } | ||||
665 | } | ||||
666 | |||||
667 | ~VkBufferTest() { | ||||
668 | if (CreateCurrent) { | ||||
669 | vkDestroyBuffer(VulkanDevice, VulkanBuffer, nullptr); | ||||
670 | } | ||||
671 | if (AllocateCurrent) { | ||||
672 | if (InvalidDeleteEn) { | ||||
673 | union { | ||||
674 | VkDeviceMemory device_memory; | ||||
675 | unsigned long long index_access; | ||||
676 | } bad_index; | ||||
677 | |||||
678 | bad_index.device_memory = VulkanMemory; | ||||
679 | bad_index.index_access++; | ||||
680 | |||||
681 | vkFreeMemory(VulkanDevice, | ||||
682 | bad_index.device_memory, | ||||
683 | nullptr); | ||||
684 | } | ||||
685 | vkFreeMemory(VulkanDevice, VulkanMemory, nullptr); | ||||
686 | } | ||||
687 | } | ||||
688 | |||||
689 | bool GetBufferCurrent() { | ||||
690 | return AllocateCurrent && BoundCurrent && CreateCurrent; | ||||
691 | } | ||||
692 | |||||
693 | const VkBuffer &GetBuffer() { | ||||
694 | return VulkanBuffer; | ||||
695 | } | ||||
696 | |||||
697 | void TestDoubleDestroy() { | ||||
698 | // Destroy the buffer but leave the flag set, which will cause | ||||
699 | // the buffer to be destroyed again in the destructor. | ||||
700 | vkDestroyBuffer(VulkanDevice, VulkanBuffer, nullptr); | ||||
701 | } | ||||
702 | |||||
703 | protected: | ||||
704 | bool AllocateCurrent; | ||||
705 | bool BoundCurrent; | ||||
706 | bool CreateCurrent; | ||||
707 | bool InvalidDeleteEn; | ||||
708 | |||||
709 | VkBuffer VulkanBuffer; | ||||
710 | VkDevice VulkanDevice; | ||||
711 | VkDeviceMemory VulkanMemory; | ||||
712 | |||||
713 | }; | ||||
714 | |||||
715 | class VkVerticesObj { | ||||
716 | public: | ||||
717 | VkVerticesObj(VkDeviceObj *aVulkanDevice, unsigned aAttributeCount, | ||||
718 | unsigned aBindingCount, unsigned aByteStride, | ||||
719 | VkDeviceSize aVertexCount, const float *aVerticies) | ||||
720 | : BoundCurrent(false), | ||||
721 | AttributeCount(aAttributeCount), | ||||
722 | BindingCount(aBindingCount), | ||||
723 | BindId(BindIdGenerator), | ||||
724 | PipelineVertexInputStateCreateInfo(), | ||||
725 | VulkanMemoryBuffer(aVulkanDevice, 1, | ||||
726 | static_cast<int>(aByteStride * aVertexCount), | ||||
727 | reinterpret_cast<const void *>(aVerticies), | ||||
728 | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT) { | ||||
729 | BindIdGenerator++; // NB: This can wrap w/misuse | ||||
730 | |||||
731 | VertexInputAttributeDescription = | ||||
732 | new VkVertexInputAttributeDescription[AttributeCount]; | ||||
733 | VertexInputBindingDescription = | ||||
734 | new VkVertexInputBindingDescription[BindingCount]; | ||||
735 | |||||
736 | PipelineVertexInputStateCreateInfo.pVertexAttributeDescriptions = | ||||
737 | VertexInputAttributeDescription; | ||||
738 | PipelineVertexInputStateCreateInfo.vertexAttributeDescriptionCount = | ||||
739 | AttributeCount; | ||||
740 | PipelineVertexInputStateCreateInfo.pVertexBindingDescriptions = | ||||
741 | VertexInputBindingDescription; | ||||
742 | PipelineVertexInputStateCreateInfo.vertexBindingDescriptionCount = | ||||
743 | BindingCount; | ||||
744 | PipelineVertexInputStateCreateInfo.sType = | ||||
745 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; | ||||
746 | |||||
747 | unsigned i = 0; | ||||
748 | do { | ||||
749 | VertexInputAttributeDescription[i].binding = BindId; | ||||
750 | VertexInputAttributeDescription[i].location = i; | ||||
751 | VertexInputAttributeDescription[i].format = | ||||
752 | VK_FORMAT_R32G32B32_SFLOAT; | ||||
753 | VertexInputAttributeDescription[i].offset = | ||||
754 | sizeof(float) * aByteStride; | ||||
755 | i++; | ||||
756 | } while (AttributeCount < i); | ||||
757 | |||||
758 | i = 0; | ||||
759 | do { | ||||
760 | VertexInputBindingDescription[i].binding = BindId; | ||||
761 | VertexInputBindingDescription[i].stride = aByteStride; | ||||
762 | VertexInputBindingDescription[i].inputRate = | ||||
763 | VK_VERTEX_INPUT_RATE_VERTEX; | ||||
764 | i++; | ||||
765 | } while (BindingCount < i); | ||||
766 | } | ||||
767 | |||||
768 | ~VkVerticesObj() { | ||||
769 | if (VertexInputAttributeDescription) { | ||||
770 | delete[] VertexInputAttributeDescription; | ||||
771 | } | ||||
772 | if (VertexInputBindingDescription) { | ||||
773 | delete[] VertexInputBindingDescription; | ||||
774 | } | ||||
775 | } | ||||
776 | |||||
777 | bool AddVertexInputToPipe(VkPipelineObj &aPipelineObj) { | ||||
778 | aPipelineObj.AddVertexInputAttribs(VertexInputAttributeDescription, | ||||
779 | AttributeCount); | ||||
780 | aPipelineObj.AddVertexInputBindings(VertexInputBindingDescription, | ||||
781 | BindingCount); | ||||
782 | return true; | ||||
783 | } | ||||
784 | |||||
785 | void BindVertexBuffers(VkCommandBuffer aCommandBuffer, | ||||
786 | unsigned aOffsetCount = 0, | ||||
787 | VkDeviceSize *aOffsetList = nullptr) { | ||||
788 | VkDeviceSize *offsetList; | ||||
789 | unsigned offsetCount; | ||||
790 | |||||
791 | if (aOffsetCount) { | ||||
792 | offsetList = aOffsetList; | ||||
793 | offsetCount = aOffsetCount; | ||||
794 | } else { | ||||
795 | offsetList = new VkDeviceSize[1](); | ||||
796 | offsetCount = 1; | ||||
797 | } | ||||
798 | |||||
799 | vkCmdBindVertexBuffers(aCommandBuffer, BindId, offsetCount, | ||||
800 | &VulkanMemoryBuffer.handle(), offsetList); | ||||
801 | BoundCurrent = true; | ||||
802 | |||||
803 | if (!aOffsetCount) { | ||||
804 | delete [] offsetList; | ||||
805 | } | ||||
806 | } | ||||
807 | |||||
808 | protected: | ||||
809 | static uint32_t BindIdGenerator; | ||||
810 | |||||
811 | bool BoundCurrent; | ||||
812 | unsigned AttributeCount; | ||||
813 | unsigned BindingCount; | ||||
814 | uint32_t BindId; | ||||
815 | |||||
816 | VkPipelineVertexInputStateCreateInfo PipelineVertexInputStateCreateInfo; | ||||
817 | VkVertexInputAttributeDescription *VertexInputAttributeDescription; | ||||
818 | VkVertexInputBindingDescription *VertexInputBindingDescription; | ||||
819 | VkConstantBufferObj VulkanMemoryBuffer; | ||||
820 | }; | ||||
821 | |||||
822 | uint32_t VkVerticesObj::BindIdGenerator; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 823 | // ******************************************************************************************************************** |
824 | // ******************************************************************************************************************** | ||||
825 | // ******************************************************************************************************************** | ||||
826 | // ******************************************************************************************************************** | ||||
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 827 | #if PARAMETER_VALIDATION_TESTS |
828 | TEST_F(VkLayerTest, RequiredParameter) { | ||||
829 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " | ||||
830 | "pointer, array, and array count parameters"); | ||||
831 | |||||
832 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
833 | |||||
834 | m_errorMonitor->SetDesiredFailureMsg( | ||||
835 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
836 | "required parameter pFeatures specified as NULL"); | ||||
837 | // Specify NULL for a pointer to a handle | ||||
838 | // Expected to trigger an error with | ||||
839 | // parameter_validation::validate_required_pointer | ||||
840 | vkGetPhysicalDeviceFeatures(gpu(), NULL); | ||||
841 | m_errorMonitor->VerifyFound(); | ||||
842 | |||||
843 | m_errorMonitor->SetDesiredFailureMsg( | ||||
844 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 845 | "required parameter pQueueFamilyPropertyCount specified as NULL"); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 846 | // Specify NULL for pointer to array count |
847 | // Expected to trigger an error with parameter_validation::validate_array | ||||
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 848 | vkGetPhysicalDeviceQueueFamilyProperties(gpu(), NULL, NULL); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 849 | m_errorMonitor->VerifyFound(); |
850 | |||||
851 | m_errorMonitor->SetDesiredFailureMsg( | ||||
852 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
853 | "parameter viewportCount must be greater than 0"); | ||||
854 | // Specify 0 for a required array count | ||||
855 | // Expected to trigger an error with parameter_validation::validate_array | ||||
856 | VkViewport view_port = {}; | ||||
857 | m_commandBuffer->SetViewport(0, 0, &view_port); | ||||
858 | m_errorMonitor->VerifyFound(); | ||||
859 | |||||
860 | m_errorMonitor->SetDesiredFailureMsg( | ||||
861 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
862 | "required parameter pViewports specified as NULL"); | ||||
863 | // Specify NULL for a required array | ||||
864 | // Expected to trigger an error with parameter_validation::validate_array | ||||
865 | m_commandBuffer->SetViewport(0, 1, NULL); | ||||
866 | m_errorMonitor->VerifyFound(); | ||||
867 | |||||
868 | m_errorMonitor->SetDesiredFailureMsg( | ||||
869 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
870 | "required parameter memory specified as VK_NULL_HANDLE"); | ||||
871 | // Specify VK_NULL_HANDLE for a required handle | ||||
872 | // Expected to trigger an error with | ||||
873 | // parameter_validation::validate_required_handle | ||||
874 | vkUnmapMemory(device(), VK_NULL_HANDLE); | ||||
875 | m_errorMonitor->VerifyFound(); | ||||
876 | |||||
877 | m_errorMonitor->SetDesiredFailureMsg( | ||||
878 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
879 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); | ||||
880 | // Specify VK_NULL_HANDLE for a required handle array entry | ||||
881 | // Expected to trigger an error with | ||||
882 | // parameter_validation::validate_required_handle_array | ||||
883 | VkFence fence = VK_NULL_HANDLE; | ||||
884 | vkResetFences(device(), 1, &fence); | ||||
885 | m_errorMonitor->VerifyFound(); | ||||
886 | |||||
887 | m_errorMonitor->SetDesiredFailureMsg( | ||||
888 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
889 | "required parameter pAllocateInfo specified as NULL"); | ||||
890 | // Specify NULL for a required struct pointer | ||||
891 | // Expected to trigger an error with | ||||
892 | // parameter_validation::validate_struct_type | ||||
893 | VkDeviceMemory memory = VK_NULL_HANDLE; | ||||
894 | vkAllocateMemory(device(), NULL, NULL, &memory); | ||||
895 | m_errorMonitor->VerifyFound(); | ||||
896 | |||||
897 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
898 | "value of faceMask must not be 0"); | ||||
899 | // Specify 0 for a required VkFlags parameter | ||||
900 | // Expected to trigger an error with parameter_validation::validate_flags | ||||
901 | m_commandBuffer->SetStencilReference(0, 0); | ||||
902 | m_errorMonitor->VerifyFound(); | ||||
903 | |||||
904 | m_errorMonitor->SetDesiredFailureMsg( | ||||
905 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
906 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); | ||||
907 | // Specify 0 for a required VkFlags array entry | ||||
908 | // Expected to trigger an error with | ||||
909 | // parameter_validation::validate_flags_array | ||||
910 | VkSemaphore semaphore = VK_NULL_HANDLE; | ||||
911 | VkPipelineStageFlags stageFlags = 0; | ||||
912 | VkSubmitInfo submitInfo = {}; | ||||
913 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
914 | submitInfo.waitSemaphoreCount = 1; | ||||
915 | submitInfo.pWaitSemaphores = &semaphore; | ||||
916 | submitInfo.pWaitDstStageMask = &stageFlags; | ||||
917 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); | ||||
918 | m_errorMonitor->VerifyFound(); | ||||
919 | } | ||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 920 | |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 921 | TEST_F(VkLayerTest, ReservedParameter) { |
922 | TEST_DESCRIPTION("Specify a non-zero value for a reserved parameter"); | ||||
923 | |||||
924 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
925 | |||||
926 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
927 | " must be 0"); | ||||
928 | // Specify 0 for a reserved VkFlags parameter | ||||
929 | // Expected to trigger an error with | ||||
930 | // parameter_validation::validate_reserved_flags | ||||
931 | VkEvent event_handle = VK_NULL_HANDLE; | ||||
932 | VkEventCreateInfo event_info = {}; | ||||
933 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
934 | event_info.flags = 1; | ||||
935 | vkCreateEvent(device(), &event_info, NULL, &event_handle); | ||||
936 | m_errorMonitor->VerifyFound(); | ||||
937 | } | ||||
938 | |||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 939 | TEST_F(VkLayerTest, InvalidStructSType) { |
940 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " | ||||
941 | "structure's sType field"); | ||||
942 | |||||
943 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
944 | |||||
945 | m_errorMonitor->SetDesiredFailureMsg( | ||||
946 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
947 | "parameter pAllocateInfo->sType must be"); | ||||
948 | // Zero struct memory, effectively setting sType to | ||||
949 | // VK_STRUCTURE_TYPE_APPLICATION_INFO | ||||
950 | // Expected to trigger an error with | ||||
951 | // parameter_validation::validate_struct_type | ||||
952 | VkMemoryAllocateInfo alloc_info = {}; | ||||
953 | VkDeviceMemory memory = VK_NULL_HANDLE; | ||||
954 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); | ||||
955 | m_errorMonitor->VerifyFound(); | ||||
956 | |||||
957 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
958 | "parameter pSubmits[0].sType must be"); | ||||
959 | // Zero struct memory, effectively setting sType to | ||||
960 | // VK_STRUCTURE_TYPE_APPLICATION_INFO | ||||
961 | // Expected to trigger an error with | ||||
962 | // parameter_validation::validate_struct_type_array | ||||
963 | VkSubmitInfo submit_info = {}; | ||||
964 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
965 | m_errorMonitor->VerifyFound(); | ||||
966 | } | ||||
967 | |||||
968 | TEST_F(VkLayerTest, InvalidStructPNext) { | ||||
969 | TEST_DESCRIPTION( | ||||
970 | "Specify an invalid value for a Vulkan structure's pNext field"); | ||||
971 | |||||
972 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
973 | |||||
974 | m_errorMonitor->SetDesiredFailureMsg( | ||||
975 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Karl Schultz | 38b5099 | 2016-07-11 16:09:09 -0600 | [diff] [blame] | 976 | "value of pCreateInfo->pNext must be NULL"); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 977 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be |
Karl Schultz | 38b5099 | 2016-07-11 16:09:09 -0600 | [diff] [blame] | 978 | // NULL. |
979 | // Need to pick a function that has no allowed pNext structure types. | ||||
980 | // Expected to trigger an error with | ||||
981 | // parameter_validation::validate_struct_pnext | ||||
982 | VkEvent event = VK_NULL_HANDLE; | ||||
Karl Schultz | 70db390 | 2016-07-11 16:22:10 -0600 | [diff] [blame] | 983 | VkEventCreateInfo event_alloc_info = {}; |
Karl Schultz | 38b5099 | 2016-07-11 16:09:09 -0600 | [diff] [blame] | 984 | // Zero-initialization will provide the correct sType |
985 | VkApplicationInfo app_info = {}; | ||||
986 | event_alloc_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
987 | event_alloc_info.pNext = &app_info; | ||||
988 | vkCreateEvent(device(), &event_alloc_info, NULL, &event); | ||||
989 | m_errorMonitor->VerifyFound(); | ||||
990 | |||||
991 | m_errorMonitor->SetDesiredFailureMsg( | ||||
992 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
993 | " chain includes a structure with unexpected VkStructureType "); | ||||
994 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, but use | ||||
995 | // a function that has allowed pNext structure types and specify | ||||
996 | // a structure type that is not allowed. | ||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 997 | // Expected to trigger an error with |
998 | // parameter_validation::validate_struct_pnext | ||||
999 | VkDeviceMemory memory = VK_NULL_HANDLE; | ||||
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 1000 | VkMemoryAllocateInfo memory_alloc_info = {}; |
1001 | memory_alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1002 | memory_alloc_info.pNext = &app_info; | ||||
1003 | vkAllocateMemory(device(), &memory_alloc_info, NULL, &memory); | ||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 1004 | m_errorMonitor->VerifyFound(); |
1005 | |||||
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 1006 | m_errorMonitor->SetDesiredFailureMsg( |
1007 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1008 | " chain includes a structure with unexpected VkStructureType "); | ||||
1009 | // Set VkGraphicsPipelineCreateInfo::VkPipelineRasterizationStateCreateInfo::pNext to an invalid structure, when pNext is allowed to be a non-NULL value | ||||
1010 | // Expected to trigger an error with | ||||
1011 | // parameter_validation::validate_struct_pnext | ||||
1012 | VkDescriptorPoolSize ds_type_count = {}; | ||||
1013 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
1014 | ds_type_count.descriptorCount = 1; | ||||
1015 | |||||
1016 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
1017 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
1018 | ds_pool_ci.pNext = NULL; | ||||
1019 | ds_pool_ci.maxSets = 1; | ||||
1020 | ds_pool_ci.poolSizeCount = 1; | ||||
1021 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
1022 | |||||
1023 | VkDescriptorPool ds_pool; | ||||
1024 | VkResult err = | ||||
1025 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
1026 | ASSERT_VK_SUCCESS(err); | ||||
1027 | |||||
1028 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
1029 | dsl_binding.binding = 0; | ||||
1030 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
1031 | dsl_binding.descriptorCount = 1; | ||||
1032 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
1033 | dsl_binding.pImmutableSamplers = NULL; | ||||
1034 | |||||
1035 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
1036 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
1037 | ds_layout_ci.pNext = NULL; | ||||
1038 | ds_layout_ci.bindingCount = 1; | ||||
1039 | ds_layout_ci.pBindings = &dsl_binding; | ||||
1040 | |||||
1041 | VkDescriptorSetLayout ds_layout; | ||||
1042 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
1043 | &ds_layout); | ||||
1044 | ASSERT_VK_SUCCESS(err); | ||||
1045 | |||||
1046 | VkDescriptorSet descriptorSet; | ||||
1047 | VkDescriptorSetAllocateInfo ds_alloc_info = {}; | ||||
1048 | ds_alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
1049 | ds_alloc_info.descriptorSetCount = 1; | ||||
1050 | ds_alloc_info.descriptorPool = ds_pool; | ||||
1051 | ds_alloc_info.pSetLayouts = &ds_layout; | ||||
1052 | err = vkAllocateDescriptorSets(m_device->device(), &ds_alloc_info, | ||||
1053 | &descriptorSet); | ||||
1054 | ASSERT_VK_SUCCESS(err); | ||||
1055 | |||||
1056 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
1057 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
1058 | pipeline_layout_ci.setLayoutCount = 1; | ||||
1059 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
1060 | |||||
1061 | VkPipelineLayout pipeline_layout; | ||||
1062 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
1063 | &pipeline_layout); | ||||
1064 | ASSERT_VK_SUCCESS(err); | ||||
1065 | |||||
1066 | VkViewport vp = {}; // Just need dummy vp to point to | ||||
1067 | VkRect2D sc = {}; // dummy scissor to point to | ||||
1068 | |||||
1069 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
1070 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; | ||||
1071 | vp_state_ci.scissorCount = 1; | ||||
1072 | vp_state_ci.pScissors = ≻ | ||||
1073 | vp_state_ci.viewportCount = 1; | ||||
1074 | vp_state_ci.pViewports = &vp; | ||||
1075 | |||||
1076 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; | ||||
1077 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
1078 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; | ||||
1079 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; | ||||
1080 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; | ||||
1081 | rs_state_ci.depthClampEnable = VK_FALSE; | ||||
1082 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; | ||||
1083 | rs_state_ci.depthBiasEnable = VK_FALSE; | ||||
1084 | |||||
1085 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
1086 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; | ||||
1087 | gp_ci.pViewportState = &vp_state_ci; | ||||
1088 | gp_ci.pRasterizationState = &rs_state_ci; | ||||
1089 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
1090 | gp_ci.layout = pipeline_layout; | ||||
1091 | gp_ci.renderPass = renderPass(); | ||||
1092 | |||||
1093 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
1094 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; | ||||
1095 | pc_ci.initialDataSize = 0; | ||||
1096 | pc_ci.pInitialData = 0; | ||||
1097 | |||||
1098 | VkPipeline pipeline; | ||||
1099 | VkPipelineCache pipelineCache; | ||||
1100 | |||||
1101 | err = | ||||
1102 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
1103 | ASSERT_VK_SUCCESS(err); | ||||
1104 | |||||
1105 | // Set VkPipelineRasterizationStateCreateInfo::pNext to an invalid value | ||||
1106 | VkApplicationInfo invalid_pnext_struct = {}; | ||||
1107 | rs_state_ci.pNext = &invalid_pnext_struct; | ||||
1108 | |||||
1109 | vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
1110 | &gp_ci, NULL, &pipeline); | ||||
1111 | m_errorMonitor->VerifyFound(); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 1112 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
1113 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
1114 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
1115 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
1116 | |||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 1117 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame] | 1118 | |
1119 | TEST_F(VkLayerTest, UnrecognizedValue) { | ||||
1120 | TEST_DESCRIPTION( | ||||
1121 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); | ||||
1122 | |||||
1123 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1124 | |||||
1125 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1126 | "does not fall within the begin..end " | ||||
1127 | "range of the core VkFormat " | ||||
1128 | "enumeration tokens"); | ||||
1129 | // Specify an invalid VkFormat value | ||||
1130 | // Expected to trigger an error with | ||||
1131 | // parameter_validation::validate_ranged_enum | ||||
1132 | VkFormatProperties format_properties; | ||||
1133 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), | ||||
1134 | &format_properties); | ||||
1135 | m_errorMonitor->VerifyFound(); | ||||
1136 | |||||
1137 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1138 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1139 | "contains flag bits that are not recognized members of"); | ||||
1140 | // Specify an invalid VkFlags bitmask value | ||||
1141 | // Expected to trigger an error with parameter_validation::validate_flags | ||||
1142 | VkImageFormatProperties image_format_properties; | ||||
1143 | vkGetPhysicalDeviceImageFormatProperties( | ||||
1144 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, | ||||
1145 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, | ||||
1146 | &image_format_properties); | ||||
1147 | m_errorMonitor->VerifyFound(); | ||||
1148 | |||||
1149 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1150 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1151 | "contains flag bits that are not recognized members of"); | ||||
1152 | // Specify an invalid VkFlags array entry | ||||
1153 | // Expected to trigger an error with | ||||
1154 | // parameter_validation::validate_flags_array | ||||
1155 | VkSemaphore semaphore = VK_NULL_HANDLE; | ||||
1156 | VkPipelineStageFlags stage_flags = | ||||
1157 | static_cast<VkPipelineStageFlags>(1 << 25); | ||||
1158 | VkSubmitInfo submit_info = {}; | ||||
1159 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
1160 | submit_info.waitSemaphoreCount = 1; | ||||
1161 | submit_info.pWaitSemaphores = &semaphore; | ||||
1162 | submit_info.pWaitDstStageMask = &stage_flags; | ||||
1163 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
1164 | m_errorMonitor->VerifyFound(); | ||||
1165 | |||||
1166 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, | ||||
1167 | "is neither VK_TRUE nor VK_FALSE"); | ||||
1168 | // Specify an invalid VkBool32 value | ||||
1169 | // Expected to trigger a warning with | ||||
1170 | // parameter_validation::validate_bool32 | ||||
1171 | VkSampler sampler = VK_NULL_HANDLE; | ||||
1172 | VkSamplerCreateInfo sampler_info = {}; | ||||
1173 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; | ||||
1174 | sampler_info.pNext = NULL; | ||||
1175 | sampler_info.magFilter = VK_FILTER_NEAREST; | ||||
1176 | sampler_info.minFilter = VK_FILTER_NEAREST; | ||||
1177 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
1178 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
1179 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
1180 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
1181 | sampler_info.mipLodBias = 1.0; | ||||
1182 | sampler_info.maxAnisotropy = 1; | ||||
1183 | sampler_info.compareEnable = VK_FALSE; | ||||
1184 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; | ||||
1185 | sampler_info.minLod = 1.0; | ||||
1186 | sampler_info.maxLod = 1.0; | ||||
1187 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
1188 | sampler_info.unnormalizedCoordinates = VK_FALSE; | ||||
1189 | // Not VK_TRUE or VK_FALSE | ||||
1190 | sampler_info.anisotropyEnable = 3; | ||||
1191 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); | ||||
1192 | m_errorMonitor->VerifyFound(); | ||||
1193 | } | ||||
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 1194 | |
1195 | TEST_F(VkLayerTest, FailedReturnValue) { | ||||
1196 | TEST_DESCRIPTION("Check for a message describing a VkResult failure code"); | ||||
1197 | |||||
1198 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1199 | |||||
Dustin Graves | 13c1e2b | 2016-05-16 15:31:02 -0600 | [diff] [blame] | 1200 | // Find an unsupported image format |
1201 | VkFormat unsupported = VK_FORMAT_UNDEFINED; | ||||
1202 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { | ||||
1203 | VkFormat format = static_cast<VkFormat>(f); | ||||
1204 | VkFormatProperties fProps = m_device->format_properties(format); | ||||
1205 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && | ||||
1206 | fProps.optimalTilingFeatures == 0) { | ||||
1207 | unsupported = format; | ||||
1208 | break; | ||||
1209 | } | ||||
1210 | } | ||||
1211 | |||||
1212 | if (unsupported != VK_FORMAT_UNDEFINED) { | ||||
1213 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1214 | VK_DEBUG_REPORT_WARNING_BIT_EXT, | ||||
1215 | "the requested format is not supported on this device"); | ||||
1216 | // Specify an unsupported VkFormat value to generate a | ||||
1217 | // VK_ERROR_FORMAT_NOT_SUPPORTED return code | ||||
1218 | // Expected to trigger a warning from | ||||
1219 | // parameter_validation::validate_result | ||||
1220 | VkImageFormatProperties image_format_properties; | ||||
1221 | VkResult err = vkGetPhysicalDeviceImageFormatProperties( | ||||
1222 | gpu(), unsupported, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, | ||||
1223 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &image_format_properties); | ||||
1224 | ASSERT_TRUE(err == VK_ERROR_FORMAT_NOT_SUPPORTED); | ||||
1225 | m_errorMonitor->VerifyFound(); | ||||
1226 | } | ||||
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 1227 | } |
Mark Lobodzinski | e090fef | 2016-06-09 17:04:56 -0600 | [diff] [blame] | 1228 | |
1229 | TEST_F(VkLayerTest, UpdateBufferAlignment) { | ||||
1230 | TEST_DESCRIPTION("Check alignment parameters for vkCmdUpdateBuffer"); | ||||
1231 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; | ||||
1232 | |||||
1233 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1234 | |||||
1235 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
1236 | vk_testing::Buffer buffer; | ||||
1237 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); | ||||
1238 | |||||
1239 | BeginCommandBuffer(); | ||||
1240 | // Introduce failure by using dstOffset that is not multiple of 4 | ||||
1241 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1242 | " is not a multiple of 4"); | ||||
1243 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); | ||||
1244 | m_errorMonitor->VerifyFound(); | ||||
1245 | |||||
1246 | // Introduce failure by using dataSize that is not multiple of 4 | ||||
1247 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1248 | " is not a multiple of 4"); | ||||
1249 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); | ||||
1250 | m_errorMonitor->VerifyFound(); | ||||
1251 | |||||
1252 | // Introduce failure by using dataSize that is < 0 | ||||
1253 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1254 | "must be greater than zero and less than or equal to 65536"); | ||||
1255 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, -44, updateData); | ||||
1256 | m_errorMonitor->VerifyFound(); | ||||
1257 | |||||
1258 | // Introduce failure by using dataSize that is > 65536 | ||||
1259 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1260 | "must be greater than zero and less than or equal to 65536"); | ||||
1261 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 80000, updateData); | ||||
1262 | m_errorMonitor->VerifyFound(); | ||||
1263 | |||||
1264 | EndCommandBuffer(); | ||||
1265 | } | ||||
1266 | |||||
1267 | TEST_F(VkLayerTest, FillBufferAlignment) { | ||||
1268 | TEST_DESCRIPTION("Check alignment parameters for vkCmdFillBuffer"); | ||||
1269 | |||||
1270 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1271 | |||||
1272 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
1273 | vk_testing::Buffer buffer; | ||||
1274 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); | ||||
1275 | |||||
1276 | BeginCommandBuffer(); | ||||
1277 | |||||
1278 | // Introduce failure by using dstOffset that is not multiple of 4 | ||||
1279 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1280 | " is not a multiple of 4"); | ||||
1281 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); | ||||
1282 | m_errorMonitor->VerifyFound(); | ||||
1283 | |||||
1284 | // Introduce failure by using size that is not multiple of 4 | ||||
1285 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1286 | " is not a multiple of 4"); | ||||
1287 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); | ||||
1288 | m_errorMonitor->VerifyFound(); | ||||
1289 | |||||
1290 | // Introduce failure by using size that is zero | ||||
1291 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1292 | "must be greater than zero"); | ||||
1293 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 0, 0x11111111); | ||||
1294 | m_errorMonitor->VerifyFound(); | ||||
1295 | |||||
1296 | EndCommandBuffer(); | ||||
1297 | } | ||||
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1298 | |
1299 | // This is a positive test. No failures are expected. | ||||
1300 | TEST_F(VkLayerTest, IgnoreUnrelatedDescriptor) { | ||||
1301 | TEST_DESCRIPTION("Ensure that the vkUpdateDescriptorSet validation code " | ||||
1302 | "is ignoring VkWriteDescriptorSet members that are not " | ||||
1303 | "related to the descriptor type specified by " | ||||
1304 | "VkWriteDescriptorSet::descriptorType. Correct " | ||||
1305 | "validation behavior will result in the test running to " | ||||
1306 | "completion without validation errors."); | ||||
1307 | |||||
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1308 | const uintptr_t invalid_ptr = 0xcdcdcdcd; |
1309 | |||||
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1310 | ASSERT_NO_FATAL_FAILURE(InitState()); |
1311 | |||||
1312 | // Image Case | ||||
1313 | { | ||||
1314 | m_errorMonitor->ExpectSuccess(); | ||||
1315 | |||||
1316 | VkImage image; | ||||
1317 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
1318 | const int32_t tex_width = 32; | ||||
1319 | const int32_t tex_height = 32; | ||||
1320 | VkImageCreateInfo image_create_info = {}; | ||||
1321 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
1322 | image_create_info.pNext = NULL; | ||||
1323 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
1324 | image_create_info.format = tex_format; | ||||
1325 | image_create_info.extent.width = tex_width; | ||||
1326 | image_create_info.extent.height = tex_height; | ||||
1327 | image_create_info.extent.depth = 1; | ||||
1328 | image_create_info.mipLevels = 1; | ||||
1329 | image_create_info.arrayLayers = 1; | ||||
1330 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
Tobin Ehlis | 51cde41 | 2016-07-11 16:08:30 -0600 | [diff] [blame] | 1331 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1332 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
1333 | image_create_info.flags = 0; | ||||
1334 | VkResult err = | ||||
1335 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
1336 | ASSERT_VK_SUCCESS(err); | ||||
1337 | |||||
1338 | VkMemoryRequirements memory_reqs; | ||||
1339 | VkDeviceMemory image_memory; | ||||
1340 | bool pass; | ||||
1341 | VkMemoryAllocateInfo memory_info = {}; | ||||
1342 | memory_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1343 | memory_info.pNext = NULL; | ||||
1344 | memory_info.allocationSize = 0; | ||||
1345 | memory_info.memoryTypeIndex = 0; | ||||
1346 | vkGetImageMemoryRequirements(m_device->device(), image, &memory_reqs); | ||||
1347 | memory_info.allocationSize = memory_reqs.size; | ||||
1348 | pass = m_device->phy().set_memory_type(memory_reqs.memoryTypeBits, | ||||
1349 | &memory_info, 0); | ||||
1350 | ASSERT_TRUE(pass); | ||||
1351 | err = vkAllocateMemory(m_device->device(), &memory_info, NULL, | ||||
1352 | &image_memory); | ||||
1353 | ASSERT_VK_SUCCESS(err); | ||||
1354 | err = vkBindImageMemory(m_device->device(), image, image_memory, 0); | ||||
1355 | ASSERT_VK_SUCCESS(err); | ||||
1356 | |||||
1357 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
1358 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
1359 | image_view_create_info.image = image; | ||||
1360 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
1361 | image_view_create_info.format = tex_format; | ||||
1362 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
1363 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
1364 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
1365 | image_view_create_info.subresourceRange.aspectMask = | ||||
1366 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
1367 | |||||
1368 | VkImageView view; | ||||
1369 | err = vkCreateImageView(m_device->device(), &image_view_create_info, | ||||
1370 | NULL, &view); | ||||
1371 | ASSERT_VK_SUCCESS(err); | ||||
1372 | |||||
1373 | VkDescriptorPoolSize ds_type_count = {}; | ||||
1374 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
1375 | ds_type_count.descriptorCount = 1; | ||||
1376 | |||||
1377 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
1378 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
1379 | ds_pool_ci.pNext = NULL; | ||||
1380 | ds_pool_ci.maxSets = 1; | ||||
1381 | ds_pool_ci.poolSizeCount = 1; | ||||
1382 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
1383 | |||||
1384 | VkDescriptorPool ds_pool; | ||||
1385 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, | ||||
1386 | &ds_pool); | ||||
1387 | ASSERT_VK_SUCCESS(err); | ||||
1388 | |||||
1389 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
1390 | dsl_binding.binding = 0; | ||||
1391 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
1392 | dsl_binding.descriptorCount = 1; | ||||
1393 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
1394 | dsl_binding.pImmutableSamplers = NULL; | ||||
1395 | |||||
1396 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
1397 | ds_layout_ci.sType = | ||||
1398 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
1399 | ds_layout_ci.pNext = NULL; | ||||
1400 | ds_layout_ci.bindingCount = 1; | ||||
1401 | ds_layout_ci.pBindings = &dsl_binding; | ||||
1402 | VkDescriptorSetLayout ds_layout; | ||||
1403 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, | ||||
1404 | NULL, &ds_layout); | ||||
1405 | ASSERT_VK_SUCCESS(err); | ||||
1406 | |||||
1407 | VkDescriptorSet descriptor_set; | ||||
1408 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
1409 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
1410 | alloc_info.descriptorSetCount = 1; | ||||
1411 | alloc_info.descriptorPool = ds_pool; | ||||
1412 | alloc_info.pSetLayouts = &ds_layout; | ||||
1413 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
1414 | &descriptor_set); | ||||
1415 | ASSERT_VK_SUCCESS(err); | ||||
1416 | |||||
1417 | VkDescriptorImageInfo image_info = {}; | ||||
1418 | image_info.imageView = view; | ||||
1419 | image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
1420 | |||||
1421 | VkWriteDescriptorSet descriptor_write; | ||||
1422 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
1423 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
1424 | descriptor_write.dstSet = descriptor_set; | ||||
1425 | descriptor_write.dstBinding = 0; | ||||
1426 | descriptor_write.descriptorCount = 1; | ||||
1427 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
1428 | descriptor_write.pImageInfo = &image_info; | ||||
1429 | |||||
1430 | // Set pBufferInfo and pTexelBufferView to invalid values, which should | ||||
1431 | // be | ||||
1432 | // ignored for descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE. | ||||
1433 | // This will most likely produce a crash if the parameter_validation | ||||
1434 | // layer | ||||
1435 | // does not correctly ignore pBufferInfo. | ||||
1436 | descriptor_write.pBufferInfo = | ||||
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1437 | reinterpret_cast<const VkDescriptorBufferInfo *>(invalid_ptr); |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1438 | descriptor_write.pTexelBufferView = |
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1439 | reinterpret_cast<const VkBufferView *>(invalid_ptr); |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1440 | |
1441 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, | ||||
1442 | NULL); | ||||
1443 | |||||
1444 | m_errorMonitor->VerifyNotFound(); | ||||
1445 | |||||
1446 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set); | ||||
1447 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
1448 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
1449 | vkDestroyImageView(m_device->device(), view, NULL); | ||||
1450 | vkDestroyImage(m_device->device(), image, NULL); | ||||
1451 | vkFreeMemory(m_device->device(), image_memory, NULL); | ||||
1452 | } | ||||
1453 | |||||
1454 | // Buffer Case | ||||
1455 | { | ||||
1456 | m_errorMonitor->ExpectSuccess(); | ||||
1457 | |||||
1458 | VkBuffer buffer; | ||||
1459 | uint32_t queue_family_index = 0; | ||||
1460 | VkBufferCreateInfo buffer_create_info = {}; | ||||
1461 | buffer_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
1462 | buffer_create_info.size = 1024; | ||||
1463 | buffer_create_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
1464 | buffer_create_info.queueFamilyIndexCount = 1; | ||||
1465 | buffer_create_info.pQueueFamilyIndices = &queue_family_index; | ||||
1466 | |||||
1467 | VkResult err = vkCreateBuffer(m_device->device(), &buffer_create_info, | ||||
1468 | NULL, &buffer); | ||||
1469 | ASSERT_VK_SUCCESS(err); | ||||
1470 | |||||
1471 | VkMemoryRequirements memory_reqs; | ||||
1472 | VkDeviceMemory buffer_memory; | ||||
1473 | bool pass; | ||||
1474 | VkMemoryAllocateInfo memory_info = {}; | ||||
1475 | memory_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1476 | memory_info.pNext = NULL; | ||||
1477 | memory_info.allocationSize = 0; | ||||
1478 | memory_info.memoryTypeIndex = 0; | ||||
1479 | |||||
1480 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memory_reqs); | ||||
1481 | memory_info.allocationSize = memory_reqs.size; | ||||
1482 | pass = m_device->phy().set_memory_type(memory_reqs.memoryTypeBits, | ||||
1483 | &memory_info, 0); | ||||
1484 | ASSERT_TRUE(pass); | ||||
1485 | |||||
1486 | err = vkAllocateMemory(m_device->device(), &memory_info, NULL, | ||||
1487 | &buffer_memory); | ||||
1488 | ASSERT_VK_SUCCESS(err); | ||||
1489 | err = vkBindBufferMemory(m_device->device(), buffer, buffer_memory, 0); | ||||
1490 | ASSERT_VK_SUCCESS(err); | ||||
1491 | |||||
1492 | VkDescriptorPoolSize ds_type_count = {}; | ||||
1493 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
1494 | ds_type_count.descriptorCount = 1; | ||||
1495 | |||||
1496 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
1497 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
1498 | ds_pool_ci.pNext = NULL; | ||||
1499 | ds_pool_ci.maxSets = 1; | ||||
1500 | ds_pool_ci.poolSizeCount = 1; | ||||
1501 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
1502 | |||||
1503 | VkDescriptorPool ds_pool; | ||||
1504 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, | ||||
1505 | &ds_pool); | ||||
1506 | ASSERT_VK_SUCCESS(err); | ||||
1507 | |||||
1508 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
1509 | dsl_binding.binding = 0; | ||||
1510 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
1511 | dsl_binding.descriptorCount = 1; | ||||
1512 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
1513 | dsl_binding.pImmutableSamplers = NULL; | ||||
1514 | |||||
1515 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
1516 | ds_layout_ci.sType = | ||||
1517 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
1518 | ds_layout_ci.pNext = NULL; | ||||
1519 | ds_layout_ci.bindingCount = 1; | ||||
1520 | ds_layout_ci.pBindings = &dsl_binding; | ||||
1521 | VkDescriptorSetLayout ds_layout; | ||||
1522 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, | ||||
1523 | NULL, &ds_layout); | ||||
1524 | ASSERT_VK_SUCCESS(err); | ||||
1525 | |||||
1526 | VkDescriptorSet descriptor_set; | ||||
1527 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
1528 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
1529 | alloc_info.descriptorSetCount = 1; | ||||
1530 | alloc_info.descriptorPool = ds_pool; | ||||
1531 | alloc_info.pSetLayouts = &ds_layout; | ||||
1532 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
1533 | &descriptor_set); | ||||
1534 | ASSERT_VK_SUCCESS(err); | ||||
1535 | |||||
1536 | VkDescriptorBufferInfo buffer_info = {}; | ||||
1537 | buffer_info.buffer = buffer; | ||||
1538 | buffer_info.offset = 0; | ||||
1539 | buffer_info.range = 1024; | ||||
1540 | |||||
1541 | VkWriteDescriptorSet descriptor_write; | ||||
1542 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
1543 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
1544 | descriptor_write.dstSet = descriptor_set; | ||||
1545 | descriptor_write.dstBinding = 0; | ||||
1546 | descriptor_write.descriptorCount = 1; | ||||
1547 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
1548 | descriptor_write.pBufferInfo = &buffer_info; | ||||
1549 | |||||
1550 | // Set pImageInfo and pTexelBufferView to invalid values, which should | ||||
1551 | // be | ||||
1552 | // ignored for descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER. | ||||
1553 | // This will most likely produce a crash if the parameter_validation | ||||
1554 | // layer | ||||
1555 | // does not correctly ignore pImageInfo. | ||||
1556 | descriptor_write.pImageInfo = | ||||
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1557 | reinterpret_cast<const VkDescriptorImageInfo *>(invalid_ptr); |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1558 | descriptor_write.pTexelBufferView = |
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1559 | reinterpret_cast<const VkBufferView *>(invalid_ptr); |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1560 | |
1561 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, | ||||
1562 | NULL); | ||||
1563 | |||||
1564 | m_errorMonitor->VerifyNotFound(); | ||||
1565 | |||||
1566 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set); | ||||
1567 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
1568 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
1569 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1570 | vkFreeMemory(m_device->device(), buffer_memory, NULL); | ||||
1571 | } | ||||
1572 | |||||
1573 | // Texel Buffer Case | ||||
1574 | { | ||||
1575 | m_errorMonitor->ExpectSuccess(); | ||||
1576 | |||||
1577 | VkBuffer buffer; | ||||
1578 | uint32_t queue_family_index = 0; | ||||
1579 | VkBufferCreateInfo buffer_create_info = {}; | ||||
1580 | buffer_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
1581 | buffer_create_info.size = 1024; | ||||
1582 | buffer_create_info.usage = VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; | ||||
1583 | buffer_create_info.queueFamilyIndexCount = 1; | ||||
1584 | buffer_create_info.pQueueFamilyIndices = &queue_family_index; | ||||
1585 | |||||
1586 | VkResult err = vkCreateBuffer(m_device->device(), &buffer_create_info, | ||||
1587 | NULL, &buffer); | ||||
1588 | ASSERT_VK_SUCCESS(err); | ||||
1589 | |||||
1590 | VkMemoryRequirements memory_reqs; | ||||
1591 | VkDeviceMemory buffer_memory; | ||||
1592 | bool pass; | ||||
1593 | VkMemoryAllocateInfo memory_info = {}; | ||||
1594 | memory_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1595 | memory_info.pNext = NULL; | ||||
1596 | memory_info.allocationSize = 0; | ||||
1597 | memory_info.memoryTypeIndex = 0; | ||||
1598 | |||||
1599 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memory_reqs); | ||||
1600 | memory_info.allocationSize = memory_reqs.size; | ||||
1601 | pass = m_device->phy().set_memory_type(memory_reqs.memoryTypeBits, | ||||
1602 | &memory_info, 0); | ||||
1603 | ASSERT_TRUE(pass); | ||||
1604 | |||||
1605 | err = vkAllocateMemory(m_device->device(), &memory_info, NULL, | ||||
1606 | &buffer_memory); | ||||
1607 | ASSERT_VK_SUCCESS(err); | ||||
1608 | err = vkBindBufferMemory(m_device->device(), buffer, buffer_memory, 0); | ||||
1609 | ASSERT_VK_SUCCESS(err); | ||||
1610 | |||||
1611 | VkBufferViewCreateInfo buff_view_ci = {}; | ||||
1612 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; | ||||
1613 | buff_view_ci.buffer = buffer; | ||||
1614 | buff_view_ci.format = VK_FORMAT_R8_UNORM; | ||||
1615 | buff_view_ci.range = VK_WHOLE_SIZE; | ||||
1616 | VkBufferView buffer_view; | ||||
1617 | err = vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, | ||||
1618 | &buffer_view); | ||||
1619 | |||||
1620 | VkDescriptorPoolSize ds_type_count = {}; | ||||
1621 | ds_type_count.type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; | ||||
1622 | ds_type_count.descriptorCount = 1; | ||||
1623 | |||||
1624 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
1625 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
1626 | ds_pool_ci.pNext = NULL; | ||||
1627 | ds_pool_ci.maxSets = 1; | ||||
1628 | ds_pool_ci.poolSizeCount = 1; | ||||
1629 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
1630 | |||||
1631 | VkDescriptorPool ds_pool; | ||||
1632 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, | ||||
1633 | &ds_pool); | ||||
1634 | ASSERT_VK_SUCCESS(err); | ||||
1635 | |||||
1636 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
1637 | dsl_binding.binding = 0; | ||||
1638 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; | ||||
1639 | dsl_binding.descriptorCount = 1; | ||||
1640 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
1641 | dsl_binding.pImmutableSamplers = NULL; | ||||
1642 | |||||
1643 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
1644 | ds_layout_ci.sType = | ||||
1645 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
1646 | ds_layout_ci.pNext = NULL; | ||||
1647 | ds_layout_ci.bindingCount = 1; | ||||
1648 | ds_layout_ci.pBindings = &dsl_binding; | ||||
1649 | VkDescriptorSetLayout ds_layout; | ||||
1650 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, | ||||
1651 | NULL, &ds_layout); | ||||
1652 | ASSERT_VK_SUCCESS(err); | ||||
1653 | |||||
1654 | VkDescriptorSet descriptor_set; | ||||
1655 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
1656 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
1657 | alloc_info.descriptorSetCount = 1; | ||||
1658 | alloc_info.descriptorPool = ds_pool; | ||||
1659 | alloc_info.pSetLayouts = &ds_layout; | ||||
1660 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
1661 | &descriptor_set); | ||||
1662 | ASSERT_VK_SUCCESS(err); | ||||
1663 | |||||
1664 | VkWriteDescriptorSet descriptor_write; | ||||
1665 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
1666 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
1667 | descriptor_write.dstSet = descriptor_set; | ||||
1668 | descriptor_write.dstBinding = 0; | ||||
1669 | descriptor_write.descriptorCount = 1; | ||||
1670 | descriptor_write.descriptorType = | ||||
1671 | VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; | ||||
1672 | descriptor_write.pTexelBufferView = &buffer_view; | ||||
1673 | |||||
1674 | // Set pImageInfo and pBufferInfo to invalid values, which should be | ||||
1675 | // ignored for descriptorType == | ||||
1676 | // VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER. | ||||
1677 | // This will most likely produce a crash if the parameter_validation | ||||
1678 | // layer | ||||
1679 | // does not correctly ignore pImageInfo and pBufferInfo. | ||||
1680 | descriptor_write.pImageInfo = | ||||
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1681 | reinterpret_cast<const VkDescriptorImageInfo *>(invalid_ptr); |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1682 | descriptor_write.pBufferInfo = |
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1683 | reinterpret_cast<const VkDescriptorBufferInfo *>(invalid_ptr); |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1684 | |
1685 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, | ||||
1686 | NULL); | ||||
1687 | |||||
1688 | m_errorMonitor->VerifyNotFound(); | ||||
1689 | |||||
1690 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set); | ||||
1691 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
1692 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
1693 | vkDestroyBufferView(m_device->device(), buffer_view, NULL); | ||||
1694 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1695 | vkFreeMemory(m_device->device(), buffer_memory, NULL); | ||||
1696 | } | ||||
1697 | } | ||||
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 1698 | #endif // PARAMETER_VALIDATION_TESTS |
1699 | |||||
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1700 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1701 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1702 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1703 | { |
1704 | vk_testing::Fence testFence; | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1705 | VkFenceCreateInfo fenceInfo = {}; |
1706 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
1707 | fenceInfo.pNext = NULL; | ||||
1708 | fenceInfo.flags = 0; | ||||
1709 | |||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1710 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1711 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1712 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 1713 | |
1714 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
1715 | vk_testing::Buffer buffer; | ||||
1716 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1717 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1718 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1719 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1720 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1721 | |
1722 | testFence.init(*m_device, fenceInfo); | ||||
1723 | |||||
1724 | // Bypass framework since it does the waits automatically | ||||
1725 | VkResult err = VK_SUCCESS; | ||||
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1726 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1727 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
1728 | submit_info.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1729 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1730 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1731 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1732 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1733 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1734 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1735 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1736 | |
1737 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1738 | ASSERT_VK_SUCCESS( err ); |
1739 | |||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1740 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1741 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1742 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1743 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1744 | } |
1745 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1746 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1747 | { |
1748 | vk_testing::Fence testFence; | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1749 | VkFenceCreateInfo fenceInfo = {}; |
1750 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
1751 | fenceInfo.pNext = NULL; | ||||
1752 | fenceInfo.flags = 0; | ||||
1753 | |||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1754 | 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] | 1755 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1756 | ASSERT_NO_FATAL_FAILURE(InitState()); |
1757 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
1758 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
1759 | |||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1760 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1761 | 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] | 1762 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1763 | |
1764 | testFence.init(*m_device, fenceInfo); | ||||
1765 | |||||
1766 | // Bypass framework since it does the waits automatically | ||||
1767 | VkResult err = VK_SUCCESS; | ||||
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1768 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1769 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
1770 | submit_info.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1771 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1772 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1773 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1774 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1775 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1776 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1777 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1778 | |
1779 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1780 | ASSERT_VK_SUCCESS( err ); |
1781 | |||||
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1782 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1783 | VkCommandBufferBeginInfo info = {}; |
1784 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; | ||||
1785 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1786 | info.renderPass = VK_NULL_HANDLE; |
1787 | info.subpass = 0; | ||||
1788 | info.framebuffer = VK_NULL_HANDLE; | ||||
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 1789 | info.occlusionQueryEnable = VK_FALSE; |
1790 | info.queryFlags = 0; | ||||
1791 | info.pipelineStatistics = 0; | ||||
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1792 | |
1793 | // Introduce failure by calling BCB again before checking fence | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1794 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1795 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1796 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1797 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1798 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1799 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1800 | // This is a positive test. No failures are expected. |
1801 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { | ||||
1802 | VkResult err; | ||||
1803 | bool pass; | ||||
1804 | |||||
1805 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " | ||||
1806 | "the buffer, create an image, and bind the same memory to " | ||||
1807 | "it"); | ||||
1808 | |||||
1809 | m_errorMonitor->ExpectSuccess(); | ||||
1810 | |||||
1811 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1812 | |||||
1813 | VkBuffer buffer; | ||||
1814 | VkImage image; | ||||
1815 | VkDeviceMemory mem; | ||||
1816 | VkMemoryRequirements mem_reqs; | ||||
1817 | |||||
1818 | VkBufferCreateInfo buf_info = {}; | ||||
1819 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
1820 | buf_info.pNext = NULL; | ||||
1821 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
1822 | buf_info.size = 256; | ||||
1823 | buf_info.queueFamilyIndexCount = 0; | ||||
1824 | buf_info.pQueueFamilyIndices = NULL; | ||||
1825 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1826 | buf_info.flags = 0; | ||||
1827 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); | ||||
1828 | ASSERT_VK_SUCCESS(err); | ||||
1829 | |||||
1830 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); | ||||
1831 | |||||
1832 | VkMemoryAllocateInfo alloc_info = {}; | ||||
1833 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1834 | alloc_info.pNext = NULL; | ||||
1835 | alloc_info.memoryTypeIndex = 0; | ||||
1836 | |||||
1837 | // Ensure memory is big enough for both bindings | ||||
1838 | alloc_info.allocationSize = 0x10000; | ||||
1839 | |||||
1840 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, | ||||
1841 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
1842 | if (!pass) { | ||||
1843 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1844 | return; | ||||
1845 | } | ||||
1846 | |||||
1847 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); | ||||
1848 | ASSERT_VK_SUCCESS(err); | ||||
1849 | |||||
1850 | uint8_t *pData; | ||||
1851 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, | ||||
1852 | (void **)&pData); | ||||
1853 | ASSERT_VK_SUCCESS(err); | ||||
1854 | |||||
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 1855 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1856 | |
1857 | vkUnmapMemory(m_device->device(), mem); | ||||
1858 | |||||
1859 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
1860 | ASSERT_VK_SUCCESS(err); | ||||
1861 | |||||
1862 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this | ||||
1863 | // memory. In fact, it was never used by the GPU. | ||||
1864 | // Just be be sure, wait for idle. | ||||
1865 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1866 | vkDeviceWaitIdle(m_device->device()); | ||||
1867 | |||||
1868 | VkImageCreateInfo image_create_info = {}; | ||||
1869 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
1870 | image_create_info.pNext = NULL; | ||||
1871 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
1872 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
1873 | image_create_info.extent.width = 64; | ||||
1874 | image_create_info.extent.height = 64; | ||||
1875 | image_create_info.extent.depth = 1; | ||||
1876 | image_create_info.mipLevels = 1; | ||||
1877 | image_create_info.arrayLayers = 1; | ||||
1878 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
1879 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
1880 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | ||||
1881 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
1882 | image_create_info.queueFamilyIndexCount = 0; | ||||
1883 | image_create_info.pQueueFamilyIndices = NULL; | ||||
1884 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1885 | image_create_info.flags = 0; | ||||
1886 | |||||
1887 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
1888 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1889 | mem_alloc.pNext = NULL; | ||||
1890 | mem_alloc.allocationSize = 0; | ||||
1891 | mem_alloc.memoryTypeIndex = 0; | ||||
1892 | |||||
1893 | /* Create a mappable image. It will be the texture if linear images are ok | ||||
1894 | * to be textures or it will be the staging image if they are not. | ||||
1895 | */ | ||||
1896 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
1897 | ASSERT_VK_SUCCESS(err); | ||||
1898 | |||||
1899 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
1900 | |||||
1901 | mem_alloc.allocationSize = mem_reqs.size; | ||||
1902 | |||||
1903 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, | ||||
1904 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
1905 | if (!pass) { | ||||
1906 | vkDestroyImage(m_device->device(), image, NULL); | ||||
1907 | return; | ||||
1908 | } | ||||
1909 | |||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1910 | // VALIDATION FAILURE: |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1911 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
1912 | ASSERT_VK_SUCCESS(err); | ||||
1913 | |||||
1914 | m_errorMonitor->VerifyNotFound(); | ||||
1915 | |||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 1916 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1917 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
1918 | vkDestroyImage(m_device->device(), image, NULL); | ||||
1919 | } | ||||
1920 | |||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1921 | TEST_F(VkLayerTest, InvalidMemoryAliasing) { |
1922 | TEST_DESCRIPTION("Create a buffer and image, allocate memory, and bind the " | ||||
1923 | "buffer and image to memory such that they will alias."); | ||||
1924 | VkResult err; | ||||
1925 | bool pass; | ||||
1926 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1927 | |||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1928 | VkBuffer buffer, buffer2; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1929 | VkImage image; |
1930 | VkDeviceMemory mem; // buffer will be bound first | ||||
1931 | VkDeviceMemory mem_img; // image bound first | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1932 | VkMemoryRequirements buff_mem_reqs, img_mem_reqs; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1933 | |
1934 | VkBufferCreateInfo buf_info = {}; | ||||
1935 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
1936 | buf_info.pNext = NULL; | ||||
1937 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
1938 | buf_info.size = 256; | ||||
1939 | buf_info.queueFamilyIndexCount = 0; | ||||
1940 | buf_info.pQueueFamilyIndices = NULL; | ||||
1941 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1942 | buf_info.flags = 0; | ||||
1943 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); | ||||
1944 | ASSERT_VK_SUCCESS(err); | ||||
1945 | |||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1946 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &buff_mem_reqs); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1947 | |
1948 | VkImageCreateInfo image_create_info = {}; | ||||
1949 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
1950 | image_create_info.pNext = NULL; | ||||
1951 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
1952 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
1953 | image_create_info.extent.width = 64; | ||||
1954 | image_create_info.extent.height = 64; | ||||
1955 | image_create_info.extent.depth = 1; | ||||
1956 | image_create_info.mipLevels = 1; | ||||
1957 | image_create_info.arrayLayers = 1; | ||||
1958 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
1959 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
1960 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | ||||
1961 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
1962 | image_create_info.queueFamilyIndexCount = 0; | ||||
1963 | image_create_info.pQueueFamilyIndices = NULL; | ||||
1964 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1965 | image_create_info.flags = 0; | ||||
1966 | |||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1967 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
1968 | ASSERT_VK_SUCCESS(err); | ||||
1969 | |||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1970 | vkGetImageMemoryRequirements(m_device->device(), image, &img_mem_reqs); |
1971 | |||||
1972 | VkMemoryAllocateInfo alloc_info = {}; | ||||
1973 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1974 | alloc_info.pNext = NULL; | ||||
1975 | alloc_info.memoryTypeIndex = 0; | ||||
1976 | // Ensure memory is big enough for both bindings | ||||
1977 | alloc_info.allocationSize = buff_mem_reqs.size + img_mem_reqs.size; | ||||
1978 | pass = m_device->phy().set_memory_type( | ||||
1979 | buff_mem_reqs.memoryTypeBits | img_mem_reqs.memoryTypeBits, &alloc_info, | ||||
1980 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1981 | if (!pass) { |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1982 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1983 | vkDestroyImage(m_device->device(), image, NULL); |
1984 | return; | ||||
1985 | } | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1986 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
1987 | ASSERT_VK_SUCCESS(err); | ||||
1988 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
1989 | ASSERT_VK_SUCCESS(err); | ||||
1990 | |||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1991 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
1992 | " is aliased with buffer 0x"); | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1993 | // VALIDATION FAILURE due to image mapping overlapping buffer mapping |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1994 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
1995 | m_errorMonitor->VerifyFound(); | ||||
1996 | |||||
1997 | // Now correctly bind image to second mem allocation before incorrectly | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1998 | // aliasing buffer2 |
1999 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer2); | ||||
2000 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 2001 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem_img); |
2002 | ASSERT_VK_SUCCESS(err); | ||||
2003 | err = vkBindImageMemory(m_device->device(), image, mem_img, 0); | ||||
2004 | ASSERT_VK_SUCCESS(err); | ||||
2005 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2006 | " is aliased with image 0x"); | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 2007 | err = vkBindBufferMemory(m_device->device(), buffer2, mem_img, 0); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 2008 | m_errorMonitor->VerifyFound(); |
2009 | |||||
2010 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 2011 | vkDestroyBuffer(m_device->device(), buffer2, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 2012 | vkDestroyImage(m_device->device(), image, NULL); |
2013 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
2014 | vkFreeMemory(m_device->device(), mem_img, NULL); | ||||
2015 | } | ||||
2016 | |||||
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 2017 | TEST_F(VkLayerTest, InvalidMemoryMapping) { |
2018 | TEST_DESCRIPTION("Attempt to map memory in a number of incorrect ways"); | ||||
2019 | VkResult err; | ||||
2020 | bool pass; | ||||
2021 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
2022 | |||||
2023 | VkBuffer buffer; | ||||
2024 | VkDeviceMemory mem; | ||||
2025 | VkMemoryRequirements mem_reqs; | ||||
2026 | |||||
2027 | VkBufferCreateInfo buf_info = {}; | ||||
2028 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
2029 | buf_info.pNext = NULL; | ||||
2030 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
2031 | buf_info.size = 256; | ||||
2032 | buf_info.queueFamilyIndexCount = 0; | ||||
2033 | buf_info.pQueueFamilyIndices = NULL; | ||||
2034 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
2035 | buf_info.flags = 0; | ||||
2036 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); | ||||
2037 | ASSERT_VK_SUCCESS(err); | ||||
2038 | |||||
2039 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); | ||||
2040 | VkMemoryAllocateInfo alloc_info = {}; | ||||
2041 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
2042 | alloc_info.pNext = NULL; | ||||
2043 | alloc_info.memoryTypeIndex = 0; | ||||
2044 | |||||
2045 | // Ensure memory is big enough for both bindings | ||||
2046 | static const VkDeviceSize allocation_size = 0x10000; | ||||
2047 | alloc_info.allocationSize = allocation_size; | ||||
2048 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, | ||||
2049 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
2050 | if (!pass) { | ||||
2051 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
2052 | return; | ||||
2053 | } | ||||
2054 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); | ||||
2055 | ASSERT_VK_SUCCESS(err); | ||||
2056 | |||||
2057 | uint8_t *pData; | ||||
2058 | // Attempt to map memory size 0 is invalid | ||||
2059 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2060 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2061 | "VkMapMemory: Attempting to map memory range of size zero"); | ||||
2062 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, (void **)&pData); | ||||
2063 | m_errorMonitor->VerifyFound(); | ||||
2064 | // Map memory twice | ||||
2065 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, | ||||
2066 | (void **)&pData); | ||||
2067 | ASSERT_VK_SUCCESS(err); | ||||
2068 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2069 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2070 | "VkMapMemory: Attempting to map memory on an already-mapped object "); | ||||
2071 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, | ||||
2072 | (void **)&pData); | ||||
2073 | m_errorMonitor->VerifyFound(); | ||||
2074 | |||||
2075 | // Unmap the memory to avoid re-map error | ||||
2076 | vkUnmapMemory(m_device->device(), mem); | ||||
2077 | // overstep allocation with VK_WHOLE_SIZE | ||||
2078 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2079 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2080 | " with size of VK_WHOLE_SIZE oversteps total array size 0x"); | ||||
2081 | err = vkMapMemory(m_device->device(), mem, allocation_size + 1, | ||||
2082 | VK_WHOLE_SIZE, 0, (void **)&pData); | ||||
2083 | m_errorMonitor->VerifyFound(); | ||||
2084 | // overstep allocation w/o VK_WHOLE_SIZE | ||||
2085 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2086 | " oversteps total array size 0x"); | ||||
2087 | err = vkMapMemory(m_device->device(), mem, 1, allocation_size, 0, | ||||
2088 | (void **)&pData); | ||||
2089 | m_errorMonitor->VerifyFound(); | ||||
2090 | // Now error due to unmapping memory that's not mapped | ||||
2091 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2092 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2093 | "Unmapping Memory without memory being mapped: "); | ||||
2094 | vkUnmapMemory(m_device->device(), mem); | ||||
2095 | m_errorMonitor->VerifyFound(); | ||||
2096 | // Now map memory and cause errors due to flushing invalid ranges | ||||
2097 | err = vkMapMemory(m_device->device(), mem, 16, VK_WHOLE_SIZE, 0, | ||||
2098 | (void **)&pData); | ||||
2099 | ASSERT_VK_SUCCESS(err); | ||||
2100 | VkMappedMemoryRange mmr = {}; | ||||
Chris Forbes | 3aec089 | 2016-06-13 10:29:26 +1200 | [diff] [blame] | 2101 | mmr.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; |
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 2102 | mmr.memory = mem; |
2103 | mmr.offset = 15; // Error b/c offset less than offset of mapped mem | ||||
2104 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2105 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2106 | ") is less than Memory Object's offset ("); | ||||
2107 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); | ||||
2108 | m_errorMonitor->VerifyFound(); | ||||
2109 | // Now flush range that oversteps mapped range | ||||
2110 | vkUnmapMemory(m_device->device(), mem); | ||||
2111 | err = vkMapMemory(m_device->device(), mem, 0, 256, 0, (void **)&pData); | ||||
2112 | ASSERT_VK_SUCCESS(err); | ||||
2113 | mmr.offset = 16; | ||||
2114 | mmr.size = 256; // flushing bounds (272) exceed mapped bounds (256) | ||||
2115 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2116 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2117 | ") exceeds the Memory Object's upper-bound ("); | ||||
2118 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); | ||||
2119 | m_errorMonitor->VerifyFound(); | ||||
2120 | |||||
2121 | pass = | ||||
2122 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, | ||||
2123 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, | ||||
2124 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); | ||||
2125 | if (!pass) { | ||||
2126 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
2127 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
2128 | return; | ||||
2129 | } | ||||
2130 | // TODO : If we can get HOST_VISIBLE w/o HOST_COHERENT we can test cases of | ||||
2131 | // MEMTRACK_INVALID_MAP in validateAndCopyNoncoherentMemoryToDriver() | ||||
2132 | |||||
2133 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
2134 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
2135 | } | ||||
2136 | |||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2137 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
2138 | VkResult err; | ||||
2139 | bool pass; | ||||
2140 | |||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2141 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
2142 | // following declaration (which is temporarily being moved below): | ||||
2143 | // VkSurfaceKHR surface = VK_NULL_HANDLE; | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2144 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
2145 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; | ||||
2146 | uint32_t swapchain_image_count = 0; | ||||
2147 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; | ||||
2148 | uint32_t image_index = 0; | ||||
2149 | // VkPresentInfoKHR present_info = {}; | ||||
2150 | |||||
2151 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
2152 | |||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2153 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
2154 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) | ||||
2155 | // Use the functions from the VK_KHR_android_surface extension without | ||||
2156 | // enabling that extension: | ||||
2157 | |||||
2158 | // Create a surface: | ||||
2159 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2160 | m_errorMonitor->SetDesiredFailureMsg( |
2161 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2162 | "extension was not enabled for this"); | ||||
2163 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, | ||||
2164 | &surface); | ||||
2165 | pass = (err != VK_SUCCESS); | ||||
2166 | ASSERT_TRUE(pass); | ||||
2167 | m_errorMonitor->VerifyFound(); | ||||
2168 | #endif // VK_USE_PLATFORM_ANDROID_KHR | ||||
2169 | |||||
2170 | |||||
2171 | #if defined(VK_USE_PLATFORM_MIR_KHR) | ||||
2172 | // Use the functions from the VK_KHR_mir_surface extension without enabling | ||||
2173 | // that extension: | ||||
2174 | |||||
2175 | // Create a surface: | ||||
2176 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2177 | m_errorMonitor->SetDesiredFailureMsg( |
2178 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2179 | "extension was not enabled for this"); | ||||
2180 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); | ||||
2181 | pass = (err != VK_SUCCESS); | ||||
2182 | ASSERT_TRUE(pass); | ||||
2183 | m_errorMonitor->VerifyFound(); | ||||
2184 | |||||
2185 | // Tell whether an mir_connection supports presentation: | ||||
2186 | MirConnection *mir_connection = NULL; | ||||
2187 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2188 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2189 | "extension was not enabled for this"); | ||||
2190 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, | ||||
2191 | visual_id); | ||||
2192 | m_errorMonitor->VerifyFound(); | ||||
2193 | #endif // VK_USE_PLATFORM_MIR_KHR | ||||
2194 | |||||
2195 | |||||
2196 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) | ||||
2197 | // Use the functions from the VK_KHR_wayland_surface extension without | ||||
2198 | // enabling that extension: | ||||
2199 | |||||
2200 | // Create a surface: | ||||
2201 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2202 | m_errorMonitor->SetDesiredFailureMsg( |
2203 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2204 | "extension was not enabled for this"); | ||||
2205 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, | ||||
2206 | &surface); | ||||
2207 | pass = (err != VK_SUCCESS); | ||||
2208 | ASSERT_TRUE(pass); | ||||
2209 | m_errorMonitor->VerifyFound(); | ||||
2210 | |||||
2211 | // Tell whether an wayland_display supports presentation: | ||||
2212 | struct wl_display wayland_display = {}; | ||||
2213 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2214 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2215 | "extension was not enabled for this"); | ||||
2216 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, | ||||
2217 | &wayland_display); | ||||
2218 | m_errorMonitor->VerifyFound(); | ||||
2219 | #endif // VK_USE_PLATFORM_WAYLAND_KHR | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2220 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2221 | |
2222 | |||||
2223 | #if defined(VK_USE_PLATFORM_WIN32_KHR) | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2224 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
2225 | // TO NON-LINUX PLATFORMS: | ||||
2226 | VkSurfaceKHR surface = VK_NULL_HANDLE; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2227 | // Use the functions from the VK_KHR_win32_surface extension without |
2228 | // enabling that extension: | ||||
2229 | |||||
2230 | // Create a surface: | ||||
2231 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2232 | m_errorMonitor->SetDesiredFailureMsg( |
2233 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2234 | "extension was not enabled for this"); | ||||
2235 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, | ||||
2236 | &surface); | ||||
2237 | pass = (err != VK_SUCCESS); | ||||
2238 | ASSERT_TRUE(pass); | ||||
2239 | m_errorMonitor->VerifyFound(); | ||||
2240 | |||||
2241 | // Tell whether win32 supports presentation: | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2242 | m_errorMonitor->SetDesiredFailureMsg( |
2243 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2244 | "extension was not enabled for this"); | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2245 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2246 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2247 | // Set this (for now, until all platforms are supported and tested): |
2248 | #define NEED_TO_TEST_THIS_ON_PLATFORM | ||||
2249 | #endif // VK_USE_PLATFORM_WIN32_KHR | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2250 | |
2251 | |||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2252 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2253 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
2254 | // TO NON-LINUX PLATFORMS: | ||||
2255 | VkSurfaceKHR surface = VK_NULL_HANDLE; | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2256 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
2257 | // that extension: | ||||
2258 | |||||
2259 | // Create a surface: | ||||
2260 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2261 | m_errorMonitor->SetDesiredFailureMsg( |
2262 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2263 | "extension was not enabled for this"); | ||||
2264 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); | ||||
2265 | pass = (err != VK_SUCCESS); | ||||
2266 | ASSERT_TRUE(pass); | ||||
2267 | m_errorMonitor->VerifyFound(); | ||||
2268 | |||||
2269 | // Tell whether an xcb_visualid_t supports presentation: | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2270 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2271 | xcb_visualid_t visual_id = 0; |
2272 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2273 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2274 | "extension was not enabled for this"); | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2275 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2276 | visual_id); |
2277 | m_errorMonitor->VerifyFound(); | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2278 | // Set this (for now, until all platforms are supported and tested): |
2279 | #define NEED_TO_TEST_THIS_ON_PLATFORM | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2280 | #endif // VK_USE_PLATFORM_XCB_KHR |
2281 | |||||
2282 | |||||
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 2283 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
2284 | // Use the functions from the VK_KHR_xlib_surface extension without enabling | ||||
2285 | // that extension: | ||||
2286 | |||||
2287 | // Create a surface: | ||||
2288 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; | ||||
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 2289 | m_errorMonitor->SetDesiredFailureMsg( |
2290 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2291 | "extension was not enabled for this"); | ||||
2292 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); | ||||
2293 | pass = (err != VK_SUCCESS); | ||||
2294 | ASSERT_TRUE(pass); | ||||
2295 | m_errorMonitor->VerifyFound(); | ||||
2296 | |||||
2297 | // Tell whether an Xlib VisualID supports presentation: | ||||
2298 | Display *dpy = NULL; | ||||
2299 | VisualID visual = 0; | ||||
2300 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2301 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2302 | "extension was not enabled for this"); | ||||
2303 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); | ||||
2304 | m_errorMonitor->VerifyFound(); | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2305 | // Set this (for now, until all platforms are supported and tested): |
2306 | #define NEED_TO_TEST_THIS_ON_PLATFORM | ||||
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 2307 | #endif // VK_USE_PLATFORM_XLIB_KHR |
2308 | |||||
2309 | |||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2310 | // Use the functions from the VK_KHR_surface extension without enabling |
2311 | // that extension: | ||||
2312 | |||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2313 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2314 | // Destroy a surface: |
2315 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2316 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2317 | "extension was not enabled for this"); | ||||
2318 | vkDestroySurfaceKHR(instance(), surface, NULL); | ||||
2319 | m_errorMonitor->VerifyFound(); | ||||
2320 | |||||
2321 | // Check if surface supports presentation: | ||||
2322 | VkBool32 supported = false; | ||||
2323 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2324 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2325 | "extension was not enabled for this"); | ||||
2326 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); | ||||
2327 | pass = (err != VK_SUCCESS); | ||||
2328 | ASSERT_TRUE(pass); | ||||
2329 | m_errorMonitor->VerifyFound(); | ||||
2330 | |||||
2331 | // Check surface capabilities: | ||||
2332 | VkSurfaceCapabilitiesKHR capabilities = {}; | ||||
2333 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2334 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2335 | "extension was not enabled for this"); | ||||
2336 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, | ||||
2337 | &capabilities); | ||||
2338 | pass = (err != VK_SUCCESS); | ||||
2339 | ASSERT_TRUE(pass); | ||||
2340 | m_errorMonitor->VerifyFound(); | ||||
2341 | |||||
2342 | // Check surface formats: | ||||
2343 | uint32_t format_count = 0; | ||||
2344 | VkSurfaceFormatKHR *formats = NULL; | ||||
2345 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2346 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2347 | "extension was not enabled for this"); | ||||
2348 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, | ||||
2349 | &format_count, formats); | ||||
2350 | pass = (err != VK_SUCCESS); | ||||
2351 | ASSERT_TRUE(pass); | ||||
2352 | m_errorMonitor->VerifyFound(); | ||||
2353 | |||||
2354 | // Check surface present modes: | ||||
2355 | uint32_t present_mode_count = 0; | ||||
2356 | VkSurfaceFormatKHR *present_modes = NULL; | ||||
2357 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2358 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2359 | "extension was not enabled for this"); | ||||
2360 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, | ||||
2361 | &present_mode_count, present_modes); | ||||
2362 | pass = (err != VK_SUCCESS); | ||||
2363 | ASSERT_TRUE(pass); | ||||
2364 | m_errorMonitor->VerifyFound(); | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2365 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2366 | |
2367 | |||||
2368 | // Use the functions from the VK_KHR_swapchain extension without enabling | ||||
2369 | // that extension: | ||||
2370 | |||||
2371 | // Create a swapchain: | ||||
2372 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2373 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2374 | "extension was not enabled for this"); | ||||
2375 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; | ||||
2376 | swapchain_create_info.pNext = NULL; | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2377 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
2378 | NULL, &swapchain); | ||||
2379 | pass = (err != VK_SUCCESS); | ||||
2380 | ASSERT_TRUE(pass); | ||||
2381 | m_errorMonitor->VerifyFound(); | ||||
2382 | |||||
2383 | // Get the images from the swapchain: | ||||
2384 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2385 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2386 | "extension was not enabled for this"); | ||||
2387 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, | ||||
2388 | &swapchain_image_count, NULL); | ||||
2389 | pass = (err != VK_SUCCESS); | ||||
2390 | ASSERT_TRUE(pass); | ||||
2391 | m_errorMonitor->VerifyFound(); | ||||
2392 | |||||
2393 | // Try to acquire an image: | ||||
2394 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2395 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2396 | "extension was not enabled for this"); | ||||
2397 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, | ||||
2398 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); | ||||
2399 | pass = (err != VK_SUCCESS); | ||||
2400 | ASSERT_TRUE(pass); | ||||
2401 | m_errorMonitor->VerifyFound(); | ||||
2402 | |||||
2403 | // Try to present an image: | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2404 | // |
2405 | // NOTE: Currently can't test this because a real swapchain is needed (as | ||||
2406 | // opposed to the fake one we created) in order for the layer to lookup the | ||||
2407 | // VkDevice used to enable the extension: | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2408 | |
2409 | // Destroy the swapchain: | ||||
2410 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2411 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2412 | "extension was not enabled for this"); | ||||
2413 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); | ||||
2414 | m_errorMonitor->VerifyFound(); | ||||
2415 | } | ||||
2416 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2417 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2418 | |
Dustin Graves | 6c6d898 | 2016-05-17 10:09:21 -0600 | [diff] [blame] | 2419 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2420 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2421 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2422 | VkResult err; |
2423 | bool pass; | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2424 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
2425 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2426 | // uint32_t swapchain_image_count = 0; |
2427 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; | ||||
2428 | // uint32_t image_index = 0; | ||||
2429 | // VkPresentInfoKHR present_info = {}; | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2430 | |
2431 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
2432 | |||||
2433 | // Use the create function from one of the VK_KHR_*_surface extension in | ||||
2434 | // order to create a surface, testing all known errors in the process, | ||||
2435 | // before successfully creating a surface: | ||||
2436 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2437 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2438 | "called with NULL pointer"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2439 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
2440 | pass = (err != VK_SUCCESS); | ||||
2441 | ASSERT_TRUE(pass); | ||||
2442 | m_errorMonitor->VerifyFound(); | ||||
2443 | |||||
2444 | // Next, try to create a surface with the wrong | ||||
2445 | // VkXcbSurfaceCreateInfoKHR::sType: | ||||
2446 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; | ||||
2447 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2448 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2449 | "called with the wrong value for"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2450 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
2451 | pass = (err != VK_SUCCESS); | ||||
2452 | ASSERT_TRUE(pass); | ||||
2453 | m_errorMonitor->VerifyFound(); | ||||
2454 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2455 | // Create a native window, and then correctly create a surface: |
2456 | xcb_connection_t *connection; | ||||
2457 | xcb_screen_t *screen; | ||||
2458 | xcb_window_t xcb_window; | ||||
2459 | xcb_intern_atom_reply_t *atom_wm_delete_window; | ||||
2460 | |||||
2461 | const xcb_setup_t *setup; | ||||
2462 | xcb_screen_iterator_t iter; | ||||
2463 | int scr; | ||||
2464 | uint32_t value_mask, value_list[32]; | ||||
2465 | int width = 1; | ||||
2466 | int height = 1; | ||||
2467 | |||||
2468 | connection = xcb_connect(NULL, &scr); | ||||
2469 | ASSERT_TRUE(connection != NULL); | ||||
2470 | setup = xcb_get_setup(connection); | ||||
2471 | iter = xcb_setup_roots_iterator(setup); | ||||
2472 | while (scr-- > 0) | ||||
2473 | xcb_screen_next(&iter); | ||||
2474 | screen = iter.data; | ||||
2475 | |||||
2476 | xcb_window = xcb_generate_id(connection); | ||||
2477 | |||||
2478 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; | ||||
2479 | value_list[0] = screen->black_pixel; | ||||
2480 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | | ||||
2481 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; | ||||
2482 | |||||
2483 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, | ||||
2484 | screen->root, 0, 0, width, height, 0, | ||||
2485 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, | ||||
2486 | value_mask, value_list); | ||||
2487 | |||||
2488 | /* Magic code that will send notification when window is destroyed */ | ||||
2489 | xcb_intern_atom_cookie_t cookie = | ||||
2490 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); | ||||
2491 | xcb_intern_atom_reply_t *reply = | ||||
2492 | xcb_intern_atom_reply(connection, cookie, 0); | ||||
2493 | |||||
2494 | xcb_intern_atom_cookie_t cookie2 = | ||||
2495 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2496 | atom_wm_delete_window = xcb_intern_atom_reply(connection, cookie2, 0); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2497 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
2498 | (*reply).atom, 4, 32, 1, | ||||
2499 | &(*atom_wm_delete_window).atom); | ||||
2500 | free(reply); | ||||
2501 | |||||
2502 | xcb_map_window(connection, xcb_window); | ||||
2503 | |||||
2504 | // Force the x/y coordinates to 100,100 results are identical in consecutive | ||||
2505 | // runs | ||||
2506 | const uint32_t coords[] = {100, 100}; | ||||
2507 | xcb_configure_window(connection, xcb_window, | ||||
2508 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); | ||||
2509 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2510 | // Finally, try to correctly create a surface: |
2511 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; | ||||
2512 | xcb_create_info.pNext = NULL; | ||||
2513 | xcb_create_info.flags = 0; | ||||
2514 | xcb_create_info.connection = connection; | ||||
2515 | xcb_create_info.window = xcb_window; | ||||
2516 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); | ||||
2517 | pass = (err == VK_SUCCESS); | ||||
2518 | ASSERT_TRUE(pass); | ||||
2519 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2520 | // Check if surface supports presentation: |
2521 | |||||
2522 | // 1st, do so without having queried the queue families: | ||||
2523 | VkBool32 supported = false; | ||||
2524 | // TODO: Get the following error to come out: | ||||
2525 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2526 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2527 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " | ||||
2528 | "function"); | ||||
2529 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); | ||||
2530 | pass = (err != VK_SUCCESS); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2531 | // ASSERT_TRUE(pass); |
2532 | // m_errorMonitor->VerifyFound(); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2533 | |
2534 | // Next, query a queue family index that's too large: | ||||
2535 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2536 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2537 | "called with a queueFamilyIndex that is too large"); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2538 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, |
2539 | &supported); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2540 | pass = (err != VK_SUCCESS); |
2541 | ASSERT_TRUE(pass); | ||||
2542 | m_errorMonitor->VerifyFound(); | ||||
2543 | |||||
2544 | // Finally, do so correctly: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2545 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
2546 | // SUPPORTED | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2547 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
2548 | pass = (err == VK_SUCCESS); | ||||
2549 | ASSERT_TRUE(pass); | ||||
2550 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2551 | // Before proceeding, try to create a swapchain without having called |
2552 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): | ||||
2553 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; | ||||
2554 | swapchain_create_info.pNext = NULL; | ||||
2555 | swapchain_create_info.flags = 0; | ||||
2556 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2557 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2558 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2559 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
2560 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2561 | pass = (err != VK_SUCCESS); |
2562 | ASSERT_TRUE(pass); | ||||
2563 | m_errorMonitor->VerifyFound(); | ||||
2564 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2565 | // Get the surface capabilities: |
2566 | VkSurfaceCapabilitiesKHR surface_capabilities; | ||||
2567 | |||||
2568 | // Do so correctly (only error logged by this entrypoint is if the | ||||
2569 | // extension isn't enabled): | ||||
2570 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, | ||||
2571 | &surface_capabilities); | ||||
2572 | pass = (err == VK_SUCCESS); | ||||
2573 | ASSERT_TRUE(pass); | ||||
2574 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2575 | // Get the surface formats: |
2576 | uint32_t surface_format_count; | ||||
2577 | |||||
2578 | // First, try without a pointer to surface_format_count: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2579 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2580 | "called with NULL pointer"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2581 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
2582 | pass = (err == VK_SUCCESS); | ||||
2583 | ASSERT_TRUE(pass); | ||||
2584 | m_errorMonitor->VerifyFound(); | ||||
2585 | |||||
2586 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't | ||||
2587 | // correctly done a 1st try (to get the count): | ||||
2588 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2589 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2590 | "but no prior positive value has been seen for"); | ||||
2591 | surface_format_count = 0; | ||||
2592 | vkGetPhysicalDeviceSurfaceFormatsKHR( | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2593 | gpu(), surface, &surface_format_count, |
2594 | (VkSurfaceFormatKHR *)&surface_format_count); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2595 | pass = (err == VK_SUCCESS); |
2596 | ASSERT_TRUE(pass); | ||||
2597 | m_errorMonitor->VerifyFound(); | ||||
2598 | |||||
2599 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2600 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
2601 | NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2602 | pass = (err == VK_SUCCESS); |
2603 | ASSERT_TRUE(pass); | ||||
2604 | |||||
2605 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2606 | VkSurfaceFormatKHR *surface_formats = (VkSurfaceFormatKHR *)malloc( |
2607 | surface_format_count * sizeof(VkSurfaceFormatKHR)); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2608 | |
2609 | // Next, do a 2nd try with surface_format_count being set too high: | ||||
2610 | surface_format_count += 5; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2611 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2612 | "that is greater than the value"); | ||||
2613 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2614 | surface_formats); |
2615 | pass = (err == VK_SUCCESS); | ||||
2616 | ASSERT_TRUE(pass); | ||||
2617 | m_errorMonitor->VerifyFound(); | ||||
2618 | |||||
2619 | // Finally, do a correct 1st and 2nd try: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2620 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
2621 | NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2622 | pass = (err == VK_SUCCESS); |
2623 | ASSERT_TRUE(pass); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2624 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2625 | surface_formats); |
2626 | pass = (err == VK_SUCCESS); | ||||
2627 | ASSERT_TRUE(pass); | ||||
2628 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2629 | // Get the surface present modes: |
2630 | uint32_t surface_present_mode_count; | ||||
2631 | |||||
2632 | // First, try without a pointer to surface_format_count: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2633 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2634 | "called with NULL pointer"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2635 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
2636 | pass = (err == VK_SUCCESS); | ||||
2637 | ASSERT_TRUE(pass); | ||||
2638 | m_errorMonitor->VerifyFound(); | ||||
2639 | |||||
2640 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't | ||||
2641 | // correctly done a 1st try (to get the count): | ||||
2642 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2643 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2644 | "but no prior positive value has been seen for"); | ||||
2645 | surface_present_mode_count = 0; | ||||
2646 | vkGetPhysicalDeviceSurfacePresentModesKHR( | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2647 | gpu(), surface, &surface_present_mode_count, |
2648 | (VkPresentModeKHR *)&surface_present_mode_count); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2649 | pass = (err == VK_SUCCESS); |
2650 | ASSERT_TRUE(pass); | ||||
2651 | m_errorMonitor->VerifyFound(); | ||||
2652 | |||||
2653 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2654 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
2655 | gpu(), surface, &surface_present_mode_count, NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2656 | pass = (err == VK_SUCCESS); |
2657 | ASSERT_TRUE(pass); | ||||
2658 | |||||
2659 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2660 | VkPresentModeKHR *surface_present_modes = (VkPresentModeKHR *)malloc( |
2661 | surface_present_mode_count * sizeof(VkPresentModeKHR)); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2662 | |
2663 | // Next, do a 2nd try with surface_format_count being set too high: | ||||
2664 | surface_present_mode_count += 5; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2665 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2666 | "that is greater than the value"); | ||||
2667 | vkGetPhysicalDeviceSurfacePresentModesKHR( | ||||
2668 | gpu(), surface, &surface_present_mode_count, surface_present_modes); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2669 | pass = (err == VK_SUCCESS); |
2670 | ASSERT_TRUE(pass); | ||||
2671 | m_errorMonitor->VerifyFound(); | ||||
2672 | |||||
2673 | // Finally, do a correct 1st and 2nd try: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2674 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
2675 | gpu(), surface, &surface_present_mode_count, NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2676 | pass = (err == VK_SUCCESS); |
2677 | ASSERT_TRUE(pass); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2678 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
2679 | gpu(), surface, &surface_present_mode_count, surface_present_modes); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2680 | pass = (err == VK_SUCCESS); |
2681 | ASSERT_TRUE(pass); | ||||
2682 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2683 | // Create a swapchain: |
2684 | |||||
2685 | // First, try without a pointer to swapchain_create_info: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2686 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2687 | "called with NULL pointer"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2688 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
2689 | pass = (err != VK_SUCCESS); | ||||
2690 | ASSERT_TRUE(pass); | ||||
2691 | m_errorMonitor->VerifyFound(); | ||||
2692 | |||||
2693 | // Next, call with a non-NULL swapchain_create_info, that has the wrong | ||||
2694 | // sType: | ||||
2695 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2696 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2697 | "called with the wrong value for"); | ||||
2698 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, | ||||
2699 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2700 | pass = (err != VK_SUCCESS); |
2701 | ASSERT_TRUE(pass); | ||||
2702 | m_errorMonitor->VerifyFound(); | ||||
2703 | |||||
2704 | // Next, call with a NULL swapchain pointer: | ||||
2705 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; | ||||
2706 | swapchain_create_info.pNext = NULL; | ||||
2707 | swapchain_create_info.flags = 0; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2708 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2709 | "called with NULL pointer"); | ||||
2710 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, | ||||
2711 | NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2712 | pass = (err != VK_SUCCESS); |
2713 | ASSERT_TRUE(pass); | ||||
2714 | m_errorMonitor->VerifyFound(); | ||||
2715 | |||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2716 | // TODO: Enhance swapchain layer so that |
2717 | // swapchain_create_info.queueFamilyIndexCount is checked against something? | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2718 | |
2719 | // Next, call with a queue family index that's too large: | ||||
2720 | uint32_t queueFamilyIndex[2] = {100000, 0}; | ||||
2721 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; | ||||
2722 | swapchain_create_info.queueFamilyIndexCount = 2; | ||||
2723 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; | ||||
2724 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2725 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2726 | "called with a queueFamilyIndex that is too large"); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2727 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
2728 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2729 | pass = (err != VK_SUCCESS); |
2730 | ASSERT_TRUE(pass); | ||||
2731 | m_errorMonitor->VerifyFound(); | ||||
2732 | |||||
2733 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: | ||||
2734 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; | ||||
2735 | swapchain_create_info.queueFamilyIndexCount = 1; | ||||
2736 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2737 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2738 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " | ||||
2739 | "pCreateInfo->pQueueFamilyIndices)."); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2740 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
2741 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2742 | pass = (err != VK_SUCCESS); |
2743 | ASSERT_TRUE(pass); | ||||
2744 | m_errorMonitor->VerifyFound(); | ||||
2745 | |||||
2746 | // Next, call with an invalid imageSharingMode: | ||||
2747 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; | ||||
2748 | swapchain_create_info.queueFamilyIndexCount = 1; | ||||
2749 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2750 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2751 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2752 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
2753 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2754 | pass = (err != VK_SUCCESS); |
2755 | ASSERT_TRUE(pass); | ||||
2756 | m_errorMonitor->VerifyFound(); | ||||
2757 | // Fix for the future: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2758 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
2759 | // SUPPORTED | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2760 | swapchain_create_info.queueFamilyIndexCount = 0; |
2761 | queueFamilyIndex[0] = 0; | ||||
2762 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
2763 | |||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2764 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2765 | // Get the images from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2766 | // Acquire an image from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2767 | // Present an image to a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2768 | // Destroy the swapchain: |
2769 | |||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2770 | // TODOs: |
2771 | // | ||||
2772 | // - Try destroying the device without first destroying the swapchain | ||||
2773 | // | ||||
2774 | // - Try destroying the device without first destroying the surface | ||||
2775 | // | ||||
2776 | // - Try destroying the surface without first destroying the swapchain | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2777 | |
2778 | // Destroy the surface: | ||||
2779 | vkDestroySurfaceKHR(instance(), surface, NULL); | ||||
2780 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2781 | // Tear down the window: |
2782 | xcb_destroy_window(connection, xcb_window); | ||||
2783 | xcb_disconnect(connection); | ||||
2784 | |||||
2785 | #else // VK_USE_PLATFORM_XCB_KHR | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2786 | return; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2787 | #endif // VK_USE_PLATFORM_XCB_KHR |
2788 | } | ||||
2789 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2790 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
2791 | VkResult err; | ||||
2792 | bool pass; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2793 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2794 | m_errorMonitor->SetDesiredFailureMsg( |
2795 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2796 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
2797 | |||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2798 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2799 | |
2800 | // Create an image, allocate memory, free it, and then try to bind it | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2801 | VkImage image; |
2802 | VkDeviceMemory mem; | ||||
2803 | VkMemoryRequirements mem_reqs; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2804 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2805 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
2806 | const int32_t tex_width = 32; | ||||
2807 | const int32_t tex_height = 32; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2808 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2809 | VkImageCreateInfo image_create_info = {}; |
2810 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2811 | image_create_info.pNext = NULL; |
2812 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
2813 | image_create_info.format = tex_format; | ||||
2814 | image_create_info.extent.width = tex_width; | ||||
2815 | image_create_info.extent.height = tex_height; | ||||
2816 | image_create_info.extent.depth = 1; | ||||
2817 | image_create_info.mipLevels = 1; | ||||
2818 | image_create_info.arrayLayers = 1; | ||||
2819 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
2820 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
2821 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
2822 | image_create_info.flags = 0; | ||||
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2823 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2824 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2825 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2826 | mem_alloc.pNext = NULL; |
2827 | mem_alloc.allocationSize = 0; | ||||
2828 | // Introduce failure, do NOT set memProps to | ||||
2829 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | ||||
2830 | mem_alloc.memoryTypeIndex = 1; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2831 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2832 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2833 | ASSERT_VK_SUCCESS(err); |
2834 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2835 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2836 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2837 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2838 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2839 | pass = |
2840 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, | ||||
2841 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
2842 | if (!pass) { // If we can't find any unmappable memory this test doesn't | ||||
2843 | // make sense | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2844 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2845 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2846 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2847 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2848 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2849 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2850 | ASSERT_VK_SUCCESS(err); |
2851 | |||||
2852 | // Try to bind free memory that has been freed | ||||
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2853 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2854 | ASSERT_VK_SUCCESS(err); |
2855 | |||||
2856 | // Map memory as if to initialize the image | ||||
2857 | void *mappedAddress = NULL; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2858 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
2859 | &mappedAddress); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2860 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2861 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2862 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2863 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 2864 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2865 | } |
2866 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2867 | TEST_F(VkLayerTest, RebindMemory) { |
2868 | VkResult err; | ||||
2869 | bool pass; | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2870 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2871 | m_errorMonitor->SetDesiredFailureMsg( |
2872 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2873 | "which has already been bound to mem object"); |
2874 | |||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2875 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2876 | |
2877 | // Create an image, allocate memory, free it, and then try to bind it | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2878 | VkImage image; |
2879 | VkDeviceMemory mem1; | ||||
2880 | VkDeviceMemory mem2; | ||||
2881 | VkMemoryRequirements mem_reqs; | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2882 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2883 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
2884 | const int32_t tex_width = 32; | ||||
2885 | const int32_t tex_height = 32; | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2886 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2887 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2888 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
2889 | image_create_info.pNext = NULL; | ||||
2890 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
2891 | image_create_info.format = tex_format; | ||||
2892 | image_create_info.extent.width = tex_width; | ||||
2893 | image_create_info.extent.height = tex_height; | ||||
2894 | image_create_info.extent.depth = 1; | ||||
2895 | image_create_info.mipLevels = 1; | ||||
2896 | image_create_info.arrayLayers = 1; | ||||
2897 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
2898 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
2899 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
2900 | image_create_info.flags = 0; | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2901 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2902 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2903 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
2904 | mem_alloc.pNext = NULL; | ||||
2905 | mem_alloc.allocationSize = 0; | ||||
2906 | mem_alloc.memoryTypeIndex = 0; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2907 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2908 | // Introduce failure, do NOT set memProps to |
2909 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2910 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2911 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2912 | ASSERT_VK_SUCCESS(err); |
2913 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2914 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2915 | |
2916 | mem_alloc.allocationSize = mem_reqs.size; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2917 | pass = |
2918 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2919 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2920 | |
2921 | // allocate 2 memory objects | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2922 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2923 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2924 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2925 | ASSERT_VK_SUCCESS(err); |
2926 | |||||
2927 | // Bind first memory object to Image object | ||||
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2928 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2929 | ASSERT_VK_SUCCESS(err); |
2930 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2931 | // Introduce validation failure, try to bind a different memory object to |
2932 | // the same image object | ||||
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2933 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2934 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2935 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2936 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2937 | vkDestroyImage(m_device->device(), image, NULL); |
2938 | vkFreeMemory(m_device->device(), mem1, NULL); | ||||
2939 | vkFreeMemory(m_device->device(), mem2, NULL); | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2940 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2941 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2942 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2943 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2944 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2945 | m_errorMonitor->SetDesiredFailureMsg( |
2946 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " | ||||
2947 | "must be reset before being submitted"); | ||||
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2948 | |
2949 | VkFenceCreateInfo fenceInfo = {}; | ||||
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2950 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
2951 | fenceInfo.pNext = NULL; | ||||
2952 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2953 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2954 | ASSERT_NO_FATAL_FAILURE(InitState()); |
2955 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
2956 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
2957 | |||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2958 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2959 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
2960 | m_stencil_clear_color, NULL); | ||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2961 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2962 | |
2963 | testFence.init(*m_device, fenceInfo); | ||||
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2964 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2965 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2966 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
2967 | submit_info.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2968 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2969 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2970 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2971 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2972 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2973 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2974 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2975 | |
2976 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2977 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2978 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2979 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2980 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2981 | // This is a positive test. We used to expect error in this case but spec now |
2982 | // allows it | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2983 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2984 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2985 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2986 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2987 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
2988 | fenceInfo.pNext = NULL; | ||||
2989 | |||||
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2990 | ASSERT_NO_FATAL_FAILURE(InitState()); |
2991 | testFence.init(*m_device, fenceInfo); | ||||
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2992 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2993 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
2994 | ASSERT_VK_SUCCESS(result); | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2995 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2996 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2997 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2998 | |
Chris Forbes | e70b7d3 | 2016-06-15 15:49:12 +1200 | [diff] [blame] | 2999 | #if 0 |
3000 | TEST_F(VkLayerTest, LongFenceChain) | ||||
3001 | { | ||||
3002 | m_errorMonitor->ExpectSuccess(); | ||||
3003 | |||||
3004 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3005 | VkResult err; | ||||
3006 | |||||
3007 | std::vector<VkFence> fences; | ||||
3008 | |||||
3009 | const int chainLength = 32768; | ||||
3010 | |||||
3011 | for (int i = 0; i < chainLength; i++) { | ||||
3012 | VkFenceCreateInfo fci = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, 0 }; | ||||
3013 | VkFence fence; | ||||
3014 | err = vkCreateFence(m_device->device(), &fci, nullptr, &fence); | ||||
3015 | ASSERT_VK_SUCCESS(err); | ||||
3016 | |||||
3017 | fences.push_back(fence); | ||||
3018 | |||||
3019 | VkSubmitInfo si = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, 0, nullptr, nullptr, | ||||
3020 | 0, nullptr, 0, nullptr }; | ||||
3021 | err = vkQueueSubmit(m_device->m_queue, 1, &si, fence); | ||||
3022 | ASSERT_VK_SUCCESS(err); | ||||
3023 | |||||
3024 | } | ||||
3025 | |||||
3026 | // BOOM, stack overflow. | ||||
3027 | vkWaitForFences(m_device->device(), 1, &fences.back(), VK_TRUE, UINT64_MAX); | ||||
3028 | |||||
3029 | for (auto fence : fences) | ||||
3030 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
3031 | |||||
3032 | m_errorMonitor->VerifyNotFound(); | ||||
3033 | } | ||||
3034 | #endif | ||||
3035 | |||||
Chris Forbes | 18127d1 | 2016-06-08 16:52:28 +1200 | [diff] [blame] | 3036 | TEST_F(VkLayerTest, CommandBufferSimultaneousUseSync) |
3037 | { | ||||
3038 | m_errorMonitor->ExpectSuccess(); | ||||
3039 | |||||
3040 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3041 | VkResult err; | ||||
3042 | |||||
3043 | // Record (empty!) command buffer that can be submitted multiple times | ||||
3044 | // simultaneously. | ||||
3045 | VkCommandBufferBeginInfo cbbi = { | ||||
3046 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, | ||||
3047 | VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, nullptr | ||||
3048 | }; | ||||
3049 | m_commandBuffer->BeginCommandBuffer(&cbbi); | ||||
3050 | m_commandBuffer->EndCommandBuffer(); | ||||
3051 | |||||
3052 | VkFenceCreateInfo fci = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, 0 }; | ||||
3053 | VkFence fence; | ||||
3054 | err = vkCreateFence(m_device->device(), &fci, nullptr, &fence); | ||||
3055 | ASSERT_VK_SUCCESS(err); | ||||
3056 | |||||
3057 | VkSemaphoreCreateInfo sci = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, nullptr, 0 }; | ||||
3058 | VkSemaphore s1, s2; | ||||
3059 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s1); | ||||
3060 | ASSERT_VK_SUCCESS(err); | ||||
3061 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s2); | ||||
3062 | ASSERT_VK_SUCCESS(err); | ||||
3063 | |||||
3064 | // Submit CB once signaling s1, with fence so we can roll forward to its retirement. | ||||
3065 | VkSubmitInfo si = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, 0, nullptr, nullptr, | ||||
3066 | 1, &m_commandBuffer->handle(), 1, &s1 }; | ||||
3067 | err = vkQueueSubmit(m_device->m_queue, 1, &si, fence); | ||||
3068 | ASSERT_VK_SUCCESS(err); | ||||
3069 | |||||
3070 | // Submit CB again, signaling s2. | ||||
3071 | si.pSignalSemaphores = &s2; | ||||
3072 | err = vkQueueSubmit(m_device->m_queue, 1, &si, VK_NULL_HANDLE); | ||||
3073 | ASSERT_VK_SUCCESS(err); | ||||
3074 | |||||
3075 | // Wait for fence. | ||||
3076 | err = vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
3077 | ASSERT_VK_SUCCESS(err); | ||||
3078 | |||||
3079 | // CB is still in flight from second submission, but semaphore s1 is no | ||||
3080 | // longer in flight. delete it. | ||||
3081 | vkDestroySemaphore(m_device->device(), s1, nullptr); | ||||
3082 | |||||
3083 | m_errorMonitor->VerifyNotFound(); | ||||
3084 | |||||
3085 | // Force device idle and clean up remaining objects | ||||
3086 | vkDeviceWaitIdle(m_device->device()); | ||||
3087 | vkDestroySemaphore(m_device->device(), s2, nullptr); | ||||
3088 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
3089 | } | ||||
3090 | |||||
Chris Forbes | 4e44c91 | 2016-06-16 10:20:00 +1200 | [diff] [blame] | 3091 | TEST_F(VkLayerTest, FenceCreateSignaledWaitHandling) |
3092 | { | ||||
3093 | m_errorMonitor->ExpectSuccess(); | ||||
3094 | |||||
3095 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3096 | VkResult err; | ||||
3097 | |||||
3098 | // A fence created signaled | ||||
3099 | VkFenceCreateInfo fci1 = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, VK_FENCE_CREATE_SIGNALED_BIT }; | ||||
3100 | VkFence f1; | ||||
3101 | err = vkCreateFence(m_device->device(), &fci1, nullptr, &f1); | ||||
3102 | ASSERT_VK_SUCCESS(err); | ||||
3103 | |||||
3104 | // A fence created not | ||||
3105 | VkFenceCreateInfo fci2 = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, 0 }; | ||||
3106 | VkFence f2; | ||||
3107 | err = vkCreateFence(m_device->device(), &fci2, nullptr, &f2); | ||||
3108 | ASSERT_VK_SUCCESS(err); | ||||
3109 | |||||
3110 | // Submit the unsignaled fence | ||||
3111 | VkSubmitInfo si = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, 0, nullptr, nullptr, | ||||
3112 | 0, nullptr, 0, nullptr }; | ||||
3113 | err = vkQueueSubmit(m_device->m_queue, 1, &si, f2); | ||||
3114 | |||||
3115 | // Wait on both fences, with signaled first. | ||||
3116 | VkFence fences[] = { f1, f2 }; | ||||
3117 | vkWaitForFences(m_device->device(), 2, fences, VK_TRUE, UINT64_MAX); | ||||
3118 | |||||
3119 | // Should have both retired! | ||||
3120 | vkDestroyFence(m_device->device(), f1, nullptr); | ||||
3121 | vkDestroyFence(m_device->device(), f2, nullptr); | ||||
3122 | |||||
3123 | m_errorMonitor->VerifyNotFound(); | ||||
3124 | } | ||||
3125 | |||||
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 3126 | TEST_F(VkLayerTest, InvalidUsageBits) |
3127 | { | ||||
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 3128 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 3129 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 3130 | "Initialize buffer with wrong usage then perform copy expecting errors " |
3131 | "from both the image and the buffer (2 calls)"); | ||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3132 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3133 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 3134 | |
3135 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 3136 | VkImageObj image(m_device); |
3137 | // Initialize image with USAGE_INPUT_ATTACHMENT | ||||
Tobin Ehlis | 8b313c0 | 2016-05-25 15:01:52 -0600 | [diff] [blame] | 3138 | image.init(128, 128, VK_FORMAT_D24_UNORM_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 3139 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
3140 | ASSERT_TRUE(image.initialized()); | ||||
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 3141 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 3142 | VkImageView dsv; |
3143 | VkImageViewCreateInfo dsvci = {}; | ||||
3144 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
3145 | dsvci.image = image.handle(); | ||||
3146 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
3147 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; | ||||
3148 | dsvci.subresourceRange.layerCount = 1; | ||||
3149 | dsvci.subresourceRange.baseMipLevel = 0; | ||||
3150 | dsvci.subresourceRange.levelCount = 1; | ||||
3151 | dsvci.subresourceRange.aspectMask = | ||||
3152 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; | ||||
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 3153 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 3154 | // Create a view with depth / stencil aspect for image with different usage |
3155 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3156 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3157 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 3158 | |
3159 | // Initialize buffer with TRANSFER_DST usage | ||||
3160 | vk_testing::Buffer buffer; | ||||
3161 | VkMemoryPropertyFlags reqs = 0; | ||||
3162 | buffer.init_as_dst(*m_device, 128 * 128, reqs); | ||||
3163 | VkBufferImageCopy region = {}; | ||||
3164 | region.bufferRowLength = 128; | ||||
3165 | region.bufferImageHeight = 128; | ||||
3166 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
3167 | region.imageSubresource.layerCount = 1; | ||||
3168 | region.imageExtent.height = 16; | ||||
3169 | region.imageExtent.width = 16; | ||||
3170 | region.imageExtent.depth = 1; | ||||
3171 | |||||
3172 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
3173 | "Invalid usage flag for buffer "); | ||||
3174 | // Buffer usage not set to TRANSFER_SRC and image usage not set to | ||||
3175 | // TRANSFER_DST | ||||
3176 | BeginCommandBuffer(); | ||||
3177 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), | ||||
3178 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
3179 | 1, ®ion); | ||||
3180 | m_errorMonitor->VerifyFound(); | ||||
3181 | |||||
3182 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
3183 | "Invalid usage flag for image "); | ||||
3184 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), | ||||
3185 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
3186 | 1, ®ion); | ||||
3187 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 3188 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3189 | #endif // MEM_TRACKER_TESTS |
3190 | |||||
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 3191 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 3192 | |
3193 | TEST_F(VkLayerTest, LeakAnObject) { | ||||
3194 | VkResult err; | ||||
3195 | |||||
3196 | TEST_DESCRIPTION( | ||||
3197 | "Create a fence and destroy its device without first destroying the fence."); | ||||
3198 | |||||
3199 | // Note that we have to create a new device since destroying the | ||||
3200 | // framework's device causes Teardown() to fail and just calling Teardown | ||||
3201 | // will destroy the errorMonitor. | ||||
3202 | |||||
3203 | m_errorMonitor->SetDesiredFailureMsg( | ||||
3204 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
3205 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); | ||||
3206 | |||||
3207 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3208 | |||||
3209 | const std::vector<VkQueueFamilyProperties> queue_props = | ||||
3210 | m_device->queue_props; | ||||
3211 | std::vector<VkDeviceQueueCreateInfo> queue_info; | ||||
3212 | queue_info.reserve(queue_props.size()); | ||||
3213 | std::vector<std::vector<float>> queue_priorities; | ||||
3214 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { | ||||
3215 | VkDeviceQueueCreateInfo qi = {}; | ||||
3216 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; | ||||
3217 | qi.pNext = NULL; | ||||
3218 | qi.queueFamilyIndex = i; | ||||
3219 | qi.queueCount = queue_props[i].queueCount; | ||||
3220 | queue_priorities.emplace_back(qi.queueCount, 0.0f); | ||||
3221 | qi.pQueuePriorities = queue_priorities[i].data(); | ||||
3222 | queue_info.push_back(qi); | ||||
3223 | } | ||||
3224 | |||||
3225 | std::vector<const char *> device_layer_names; | ||||
3226 | std::vector<const char *> device_extension_names; | ||||
3227 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); | ||||
3228 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); | ||||
3229 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); | ||||
3230 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); | ||||
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 3231 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
3232 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); | ||||
3233 | |||||
3234 | // The sacrificial device object | ||||
3235 | VkDevice testDevice; | ||||
3236 | VkDeviceCreateInfo device_create_info = {}; | ||||
3237 | auto features = m_device->phy().features(); | ||||
3238 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; | ||||
3239 | device_create_info.pNext = NULL; | ||||
3240 | device_create_info.queueCreateInfoCount = queue_info.size(); | ||||
3241 | device_create_info.pQueueCreateInfos = queue_info.data(); | ||||
3242 | device_create_info.enabledLayerCount = device_layer_names.size(); | ||||
3243 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); | ||||
3244 | device_create_info.pEnabledFeatures = &features; | ||||
3245 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); | ||||
3246 | ASSERT_VK_SUCCESS(err); | ||||
3247 | |||||
3248 | VkFence fence; | ||||
3249 | VkFenceCreateInfo fence_create_info = {}; | ||||
3250 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
3251 | fence_create_info.pNext = NULL; | ||||
3252 | fence_create_info.flags = 0; | ||||
3253 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); | ||||
3254 | ASSERT_VK_SUCCESS(err); | ||||
3255 | |||||
3256 | // Induce failure by not calling vkDestroyFence | ||||
3257 | vkDestroyDevice(testDevice, NULL); | ||||
3258 | m_errorMonitor->VerifyFound(); | ||||
3259 | } | ||||
3260 | |||||
3261 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { | ||||
3262 | |||||
3263 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " | ||||
3264 | "attempt to delete them from another."); | ||||
3265 | |||||
3266 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
3267 | "FreeCommandBuffers is attempting to free Command Buffer"); | ||||
3268 | |||||
3269 | VkCommandPool command_pool_one; | ||||
3270 | VkCommandPool command_pool_two; | ||||
3271 | |||||
3272 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
3273 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3274 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3275 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3276 | |||||
3277 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3278 | &command_pool_one); | ||||
3279 | |||||
3280 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3281 | &command_pool_two); | ||||
3282 | |||||
3283 | VkCommandBuffer command_buffer[9]; | ||||
3284 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
3285 | command_buffer_allocate_info.sType = | ||||
3286 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3287 | command_buffer_allocate_info.commandPool = command_pool_one; | ||||
3288 | command_buffer_allocate_info.commandBufferCount = 9; | ||||
3289 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3290 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
3291 | command_buffer); | ||||
3292 | |||||
3293 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, | ||||
3294 | &command_buffer[3]); | ||||
3295 | |||||
3296 | m_errorMonitor->VerifyFound(); | ||||
3297 | |||||
3298 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); | ||||
3299 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); | ||||
3300 | } | ||||
3301 | |||||
3302 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { | ||||
3303 | VkResult err; | ||||
3304 | |||||
3305 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " | ||||
3306 | "attempt to delete them from another."); | ||||
3307 | |||||
3308 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
3309 | "FreeDescriptorSets is attempting to free descriptorSet"); | ||||
3310 | |||||
3311 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3312 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
3313 | |||||
3314 | VkDescriptorPoolSize ds_type_count = {}; | ||||
3315 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
3316 | ds_type_count.descriptorCount = 1; | ||||
3317 | |||||
3318 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
3319 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
3320 | ds_pool_ci.pNext = NULL; | ||||
3321 | ds_pool_ci.flags = 0; | ||||
3322 | ds_pool_ci.maxSets = 1; | ||||
3323 | ds_pool_ci.poolSizeCount = 1; | ||||
3324 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
3325 | |||||
3326 | VkDescriptorPool ds_pool_one; | ||||
3327 | err = | ||||
3328 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); | ||||
3329 | ASSERT_VK_SUCCESS(err); | ||||
3330 | |||||
3331 | // Create a second descriptor pool | ||||
3332 | VkDescriptorPool ds_pool_two; | ||||
3333 | err = | ||||
3334 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); | ||||
3335 | ASSERT_VK_SUCCESS(err); | ||||
3336 | |||||
3337 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
3338 | dsl_binding.binding = 0; | ||||
3339 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
3340 | dsl_binding.descriptorCount = 1; | ||||
3341 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
3342 | dsl_binding.pImmutableSamplers = NULL; | ||||
3343 | |||||
3344 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
3345 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
3346 | ds_layout_ci.pNext = NULL; | ||||
3347 | ds_layout_ci.bindingCount = 1; | ||||
3348 | ds_layout_ci.pBindings = &dsl_binding; | ||||
3349 | |||||
3350 | VkDescriptorSetLayout ds_layout; | ||||
3351 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
3352 | &ds_layout); | ||||
3353 | ASSERT_VK_SUCCESS(err); | ||||
3354 | |||||
3355 | VkDescriptorSet descriptorSet; | ||||
3356 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
3357 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
3358 | alloc_info.descriptorSetCount = 1; | ||||
3359 | alloc_info.descriptorPool = ds_pool_one; | ||||
3360 | alloc_info.pSetLayouts = &ds_layout; | ||||
3361 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
3362 | &descriptorSet); | ||||
3363 | ASSERT_VK_SUCCESS(err); | ||||
3364 | |||||
3365 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); | ||||
3366 | |||||
3367 | m_errorMonitor->VerifyFound(); | ||||
3368 | |||||
3369 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
3370 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); | ||||
3371 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); | ||||
3372 | } | ||||
3373 | |||||
3374 | TEST_F(VkLayerTest, CreateUnknownObject) { | ||||
3375 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
3376 | "Invalid VkImage Object "); | ||||
3377 | |||||
3378 | TEST_DESCRIPTION( | ||||
3379 | "Pass an invalid image object handle into a Vulkan API call."); | ||||
3380 | |||||
3381 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3382 | |||||
3383 | // Pass bogus handle into GetImageMemoryRequirements | ||||
3384 | VkMemoryRequirements mem_reqs; | ||||
3385 | uint64_t fakeImageHandle = 0xCADECADE; | ||||
3386 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); | ||||
3387 | |||||
3388 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); | ||||
3389 | |||||
3390 | m_errorMonitor->VerifyFound(); | ||||
3391 | } | ||||
3392 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3393 | TEST_F(VkLayerTest, PipelineNotBound) { |
3394 | VkResult err; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3395 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 3396 | TEST_DESCRIPTION( |
3397 | "Pass in an invalid pipeline object handle into a Vulkan API call."); | ||||
3398 | |||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3399 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3400 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3401 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3402 | ASSERT_NO_FATAL_FAILURE(InitState()); |
3403 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3404 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3405 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3406 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
3407 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3408 | |
3409 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3410 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
3411 | ds_pool_ci.pNext = NULL; | ||||
3412 | ds_pool_ci.maxSets = 1; | ||||
3413 | ds_pool_ci.poolSizeCount = 1; | ||||
3414 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3415 | |
3416 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3417 | err = |
3418 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3419 | ASSERT_VK_SUCCESS(err); |
3420 | |||||
3421 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3422 | dsl_binding.binding = 0; |
3423 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
3424 | dsl_binding.descriptorCount = 1; | ||||
3425 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
3426 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3427 | |
3428 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3429 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
3430 | ds_layout_ci.pNext = NULL; | ||||
3431 | ds_layout_ci.bindingCount = 1; | ||||
3432 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3433 | |
3434 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3435 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
3436 | &ds_layout); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3437 | ASSERT_VK_SUCCESS(err); |
3438 | |||||
3439 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3440 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3441 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3442 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3443 | alloc_info.descriptorPool = ds_pool; |
3444 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3445 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
3446 | &descriptorSet); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3447 | ASSERT_VK_SUCCESS(err); |
3448 | |||||
3449 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3450 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
3451 | pipeline_layout_ci.pNext = NULL; | ||||
3452 | pipeline_layout_ci.setLayoutCount = 1; | ||||
3453 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3454 | |
3455 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3456 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
3457 | &pipeline_layout); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3458 | ASSERT_VK_SUCCESS(err); |
3459 | |||||
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 3460 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3461 | |
3462 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3463 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
3464 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3465 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3466 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3467 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3468 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
3469 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
3470 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3471 | } |
Mike Stroyan | 80fc6c3 | 2016-06-20 15:42:29 -0600 | [diff] [blame] | 3472 | |
Mark Lobodzinski | bc18576 | 2016-06-15 16:28:53 -0600 | [diff] [blame] | 3473 | TEST_F(VkLayerTest, BindImageInvalidMemoryType) { |
3474 | VkResult err; | ||||
3475 | |||||
3476 | TEST_DESCRIPTION("Test validation check for an invalid memory type index " | ||||
3477 | "during bind[Buffer|Image]Memory time"); | ||||
3478 | |||||
Mark Lobodzinski | bc18576 | 2016-06-15 16:28:53 -0600 | [diff] [blame] | 3479 | ASSERT_NO_FATAL_FAILURE(InitState()); |
3480 | |||||
3481 | // Create an image, allocate memory, set a bad typeIndex and then try to | ||||
3482 | // bind it | ||||
3483 | VkImage image; | ||||
3484 | VkDeviceMemory mem; | ||||
3485 | VkMemoryRequirements mem_reqs; | ||||
3486 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
3487 | const int32_t tex_width = 32; | ||||
3488 | const int32_t tex_height = 32; | ||||
3489 | |||||
3490 | VkImageCreateInfo image_create_info = {}; | ||||
3491 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
3492 | image_create_info.pNext = NULL; | ||||
3493 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
3494 | image_create_info.format = tex_format; | ||||
3495 | image_create_info.extent.width = tex_width; | ||||
3496 | image_create_info.extent.height = tex_height; | ||||
3497 | image_create_info.extent.depth = 1; | ||||
3498 | image_create_info.mipLevels = 1; | ||||
3499 | image_create_info.arrayLayers = 1; | ||||
3500 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
3501 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
3502 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
3503 | image_create_info.flags = 0; | ||||
3504 | |||||
3505 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
3506 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
3507 | mem_alloc.pNext = NULL; | ||||
3508 | mem_alloc.allocationSize = 0; | ||||
3509 | mem_alloc.memoryTypeIndex = 0; | ||||
3510 | |||||
3511 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
3512 | ASSERT_VK_SUCCESS(err); | ||||
3513 | |||||
3514 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
3515 | mem_alloc.allocationSize = mem_reqs.size; | ||||
Mike Stroyan | 80fc6c3 | 2016-06-20 15:42:29 -0600 | [diff] [blame] | 3516 | |
3517 | // Introduce Failure, select invalid TypeIndex | ||||
3518 | VkPhysicalDeviceMemoryProperties memory_info; | ||||
3519 | |||||
3520 | vkGetPhysicalDeviceMemoryProperties(gpu(), &memory_info); | ||||
3521 | unsigned int i; | ||||
3522 | for (i = 0; i < memory_info.memoryTypeCount; i++) { | ||||
3523 | if ((mem_reqs.memoryTypeBits & (1 << i)) == 0) { | ||||
3524 | mem_alloc.memoryTypeIndex = i; | ||||
3525 | break; | ||||
3526 | } | ||||
3527 | } | ||||
3528 | if (i >= memory_info.memoryTypeCount) { | ||||
3529 | printf("No invalid memory type index could be found; skipped.\n"); | ||||
3530 | vkDestroyImage(m_device->device(), image, NULL); | ||||
3531 | return; | ||||
3532 | } | ||||
3533 | |||||
3534 | m_errorMonitor->SetDesiredFailureMsg( | ||||
3535 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
3536 | "for this object type are not compatible with the memory"); | ||||
Mark Lobodzinski | bc18576 | 2016-06-15 16:28:53 -0600 | [diff] [blame] | 3537 | |
3538 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); | ||||
3539 | ASSERT_VK_SUCCESS(err); | ||||
3540 | |||||
3541 | err = vkBindImageMemory(m_device->device(), image, mem, 0); | ||||
3542 | (void)err; | ||||
3543 | |||||
3544 | m_errorMonitor->VerifyFound(); | ||||
3545 | |||||
3546 | vkDestroyImage(m_device->device(), image, NULL); | ||||
3547 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
3548 | } | ||||
Mike Stroyan | 80fc6c3 | 2016-06-20 15:42:29 -0600 | [diff] [blame] | 3549 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3550 | TEST_F(VkLayerTest, BindInvalidMemory) { |
3551 | VkResult err; | ||||
3552 | bool pass; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3553 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3554 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3555 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3556 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3557 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3558 | |
3559 | // Create an image, allocate memory, free it, and then try to bind it | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3560 | VkImage image; |
3561 | VkDeviceMemory mem; | ||||
3562 | VkMemoryRequirements mem_reqs; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3563 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3564 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
3565 | const int32_t tex_width = 32; | ||||
3566 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3567 | |
3568 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3569 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
3570 | image_create_info.pNext = NULL; | ||||
3571 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
3572 | image_create_info.format = tex_format; | ||||
3573 | image_create_info.extent.width = tex_width; | ||||
3574 | image_create_info.extent.height = tex_height; | ||||
3575 | image_create_info.extent.depth = 1; | ||||
3576 | image_create_info.mipLevels = 1; | ||||
3577 | image_create_info.arrayLayers = 1; | ||||
3578 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
3579 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
3580 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
3581 | image_create_info.flags = 0; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3582 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3583 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3584 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
3585 | mem_alloc.pNext = NULL; | ||||
3586 | mem_alloc.allocationSize = 0; | ||||
3587 | mem_alloc.memoryTypeIndex = 0; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3588 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3589 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3590 | ASSERT_VK_SUCCESS(err); |
3591 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3592 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3593 | |
3594 | mem_alloc.allocationSize = mem_reqs.size; | ||||
3595 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3596 | pass = |
3597 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 3598 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3599 | |
3600 | // allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3601 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3602 | ASSERT_VK_SUCCESS(err); |
3603 | |||||
3604 | // Introduce validation failure, free memory before binding | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3605 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3606 | |
3607 | // Try to bind free memory that has been freed | ||||
3608 | err = vkBindImageMemory(m_device->device(), image, mem, 0); | ||||
3609 | // This may very well return an error. | ||||
3610 | (void)err; | ||||
3611 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3612 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3613 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3614 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3615 | } |
3616 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3617 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
3618 | VkResult err; | ||||
3619 | bool pass; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3620 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3621 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
3622 | "Invalid VkImage Object "); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3623 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3624 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3625 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3626 | // Create an image object, allocate memory, destroy the object and then try |
3627 | // to bind it | ||||
3628 | VkImage image; | ||||
3629 | VkDeviceMemory mem; | ||||
3630 | VkMemoryRequirements mem_reqs; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3631 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3632 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
3633 | const int32_t tex_width = 32; | ||||
3634 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3635 | |
3636 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3637 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
3638 | image_create_info.pNext = NULL; | ||||
3639 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
3640 | image_create_info.format = tex_format; | ||||
3641 | image_create_info.extent.width = tex_width; | ||||
3642 | image_create_info.extent.height = tex_height; | ||||
3643 | image_create_info.extent.depth = 1; | ||||
3644 | image_create_info.mipLevels = 1; | ||||
3645 | image_create_info.arrayLayers = 1; | ||||
3646 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
3647 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
3648 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
3649 | image_create_info.flags = 0; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3650 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3651 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3652 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
3653 | mem_alloc.pNext = NULL; | ||||
3654 | mem_alloc.allocationSize = 0; | ||||
3655 | mem_alloc.memoryTypeIndex = 0; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3656 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3657 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3658 | ASSERT_VK_SUCCESS(err); |
3659 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3660 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3661 | |
3662 | mem_alloc.allocationSize = mem_reqs.size; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3663 | pass = |
3664 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 3665 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3666 | |
3667 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3668 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3669 | ASSERT_VK_SUCCESS(err); |
3670 | |||||
3671 | // Introduce validation failure, destroy Image object before binding | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3672 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3673 | ASSERT_VK_SUCCESS(err); |
3674 | |||||
3675 | // Now Try to bind memory to this destroyed object | ||||
3676 | err = vkBindImageMemory(m_device->device(), image, mem, 0); | ||||
3677 | // This may very well return an error. | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3678 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3679 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3680 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3681 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3682 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3683 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3684 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3685 | #endif // OBJ_TRACKER_TESTS |
3686 | |||||
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 3687 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3688 | |
Chris Forbes | 48a5390 | 2016-06-30 11:46:27 +1200 | [diff] [blame] | 3689 | TEST_F(VkLayerTest, RenderPassInitialLayoutUndefined) { |
3690 | TEST_DESCRIPTION("Ensure that CmdBeginRenderPass with an attachment's " | ||||
3691 | "initialLayout of VK_IMAGE_LAYOUT_UNDEFINED works when " | ||||
3692 | "the command buffer has prior knowledge of that " | ||||
3693 | "attachment's layout."); | ||||
3694 | |||||
3695 | m_errorMonitor->ExpectSuccess(); | ||||
3696 | |||||
3697 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3698 | |||||
3699 | // A renderpass with one color attachment. | ||||
3700 | VkAttachmentDescription attachment = { | ||||
3701 | 0, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, | ||||
3702 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_STORE, | ||||
3703 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
3704 | VK_IMAGE_LAYOUT_UNDEFINED, | ||||
3705 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
3706 | }; | ||||
3707 | |||||
3708 | VkAttachmentReference att_ref = { | ||||
3709 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
3710 | }; | ||||
3711 | |||||
3712 | VkSubpassDescription subpass = { | ||||
3713 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, | ||||
3714 | 1, &att_ref, nullptr, nullptr, 0, nullptr | ||||
3715 | }; | ||||
3716 | |||||
3717 | VkRenderPassCreateInfo rpci = { | ||||
3718 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
3719 | 0, 1, &attachment, 1, &subpass, 0, nullptr | ||||
3720 | }; | ||||
3721 | |||||
3722 | VkRenderPass rp; | ||||
3723 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
3724 | ASSERT_VK_SUCCESS(err); | ||||
3725 | |||||
3726 | // A compatible framebuffer. | ||||
3727 | VkImageObj image(m_device); | ||||
3728 | image.init(32, 32, VK_FORMAT_R8G8B8A8_UNORM, | ||||
3729 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, | ||||
3730 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
3731 | ASSERT_TRUE(image.initialized()); | ||||
3732 | |||||
3733 | VkImageViewCreateInfo ivci = { | ||||
3734 | VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, nullptr, | ||||
3735 | 0, image.handle(), VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM, | ||||
3736 | { | ||||
3737 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3738 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3739 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3740 | VK_COMPONENT_SWIZZLE_IDENTITY | ||||
3741 | }, | ||||
3742 | { | ||||
3743 | VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 | ||||
3744 | }, | ||||
3745 | }; | ||||
3746 | VkImageView view; | ||||
3747 | err = vkCreateImageView(m_device->device(), &ivci, nullptr, &view); | ||||
3748 | ASSERT_VK_SUCCESS(err); | ||||
3749 | |||||
3750 | VkFramebufferCreateInfo fci = { | ||||
3751 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, | ||||
3752 | 0, rp, 1, &view, | ||||
3753 | 32, 32, 1 | ||||
3754 | }; | ||||
3755 | VkFramebuffer fb; | ||||
3756 | err = vkCreateFramebuffer(m_device->device(), &fci, nullptr, &fb); | ||||
3757 | ASSERT_VK_SUCCESS(err); | ||||
3758 | |||||
3759 | // Record a single command buffer which uses this renderpass twice. The | ||||
3760 | // bug is triggered at the beginning of the second renderpass, when the | ||||
3761 | // command buffer already has a layout recorded for the attachment. | ||||
3762 | VkRenderPassBeginInfo rpbi = { | ||||
3763 | VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, | ||||
Tobin Ehlis | 0f9aa40 | 2016-07-01 08:47:12 -0600 | [diff] [blame] | 3764 | rp, fb, { { 0, 0 } , { 32, 32 } }, |
Chris Forbes | 48a5390 | 2016-06-30 11:46:27 +1200 | [diff] [blame] | 3765 | 0, nullptr |
3766 | }; | ||||
3767 | BeginCommandBuffer(); | ||||
3768 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, | ||||
3769 | VK_SUBPASS_CONTENTS_INLINE); | ||||
3770 | vkCmdEndRenderPass(m_commandBuffer->handle()); | ||||
3771 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, | ||||
3772 | VK_SUBPASS_CONTENTS_INLINE); | ||||
3773 | |||||
3774 | m_errorMonitor->VerifyNotFound(); | ||||
3775 | |||||
3776 | vkCmdEndRenderPass(m_commandBuffer->handle()); | ||||
3777 | EndCommandBuffer(); | ||||
3778 | |||||
3779 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); | ||||
3780 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
3781 | vkDestroyImageView(m_device->device(), view, nullptr); | ||||
3782 | } | ||||
3783 | |||||
Chris Forbes | 51bf7c9 | 2016-06-30 15:22:08 +1200 | [diff] [blame] | 3784 | TEST_F(VkLayerTest, RenderPassSubpassZeroTransitionsApplied) { |
3785 | TEST_DESCRIPTION("Ensure that CmdBeginRenderPass applies the layout " | ||||
3786 | "transitions for the first subpass"); | ||||
3787 | |||||
3788 | m_errorMonitor->ExpectSuccess(); | ||||
3789 | |||||
3790 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3791 | |||||
3792 | // A renderpass with one color attachment. | ||||
3793 | VkAttachmentDescription attachment = { | ||||
3794 | 0, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, | ||||
3795 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_STORE, | ||||
3796 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
3797 | VK_IMAGE_LAYOUT_UNDEFINED, | ||||
3798 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
3799 | }; | ||||
3800 | |||||
3801 | VkAttachmentReference att_ref = { | ||||
3802 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
3803 | }; | ||||
3804 | |||||
3805 | VkSubpassDescription subpass = { | ||||
3806 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, | ||||
3807 | 1, &att_ref, nullptr, nullptr, 0, nullptr | ||||
3808 | }; | ||||
3809 | |||||
3810 | VkSubpassDependency dep = { | ||||
Chris Forbes | cb4c7ad | 2016-07-06 10:28:18 +1200 | [diff] [blame] | 3811 | 0, 0, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, |
3812 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, | ||||
Chris Forbes | 51bf7c9 | 2016-06-30 15:22:08 +1200 | [diff] [blame] | 3813 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, |
3814 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, | ||||
3815 | VK_DEPENDENCY_BY_REGION_BIT | ||||
3816 | }; | ||||
3817 | |||||
3818 | VkRenderPassCreateInfo rpci = { | ||||
3819 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
3820 | 0, 1, &attachment, 1, &subpass, 1, &dep | ||||
3821 | }; | ||||
3822 | |||||
3823 | VkResult err; | ||||
3824 | VkRenderPass rp; | ||||
3825 | err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
3826 | ASSERT_VK_SUCCESS(err); | ||||
3827 | |||||
3828 | // A compatible framebuffer. | ||||
3829 | VkImageObj image(m_device); | ||||
3830 | image.init(32, 32, VK_FORMAT_R8G8B8A8_UNORM, | ||||
3831 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, | ||||
3832 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
3833 | ASSERT_TRUE(image.initialized()); | ||||
3834 | |||||
3835 | VkImageViewCreateInfo ivci = { | ||||
3836 | VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, nullptr, | ||||
3837 | 0, image.handle(), VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM, | ||||
3838 | { | ||||
3839 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3840 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3841 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3842 | VK_COMPONENT_SWIZZLE_IDENTITY | ||||
3843 | }, | ||||
3844 | { | ||||
3845 | VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 | ||||
3846 | }, | ||||
3847 | }; | ||||
3848 | VkImageView view; | ||||
3849 | err = vkCreateImageView(m_device->device(), &ivci, nullptr, &view); | ||||
3850 | ASSERT_VK_SUCCESS(err); | ||||
3851 | |||||
3852 | VkFramebufferCreateInfo fci = { | ||||
3853 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, | ||||
3854 | 0, rp, 1, &view, | ||||
3855 | 32, 32, 1 | ||||
3856 | }; | ||||
3857 | VkFramebuffer fb; | ||||
3858 | err = vkCreateFramebuffer(m_device->device(), &fci, nullptr, &fb); | ||||
3859 | ASSERT_VK_SUCCESS(err); | ||||
3860 | |||||
3861 | // Record a single command buffer which issues a pipeline barrier w/ | ||||
3862 | // image memory barrier for the attachment. This detects the previously | ||||
3863 | // missing tracking of the subpass layout by throwing a validation error | ||||
3864 | // if it doesn't occur. | ||||
3865 | VkRenderPassBeginInfo rpbi = { | ||||
3866 | VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, | ||||
Tobin Ehlis | 0f9aa40 | 2016-07-01 08:47:12 -0600 | [diff] [blame] | 3867 | rp, fb, { { 0, 0 }, { 32, 32 } }, |
Chris Forbes | 51bf7c9 | 2016-06-30 15:22:08 +1200 | [diff] [blame] | 3868 | 0, nullptr |
3869 | }; | ||||
3870 | BeginCommandBuffer(); | ||||
3871 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, | ||||
3872 | VK_SUBPASS_CONTENTS_INLINE); | ||||
3873 | |||||
3874 | VkImageMemoryBarrier imb = { | ||||
3875 | VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, nullptr, | ||||
3876 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, | ||||
3877 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, | ||||
3878 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
3879 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
3880 | VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, | ||||
3881 | image.handle(), | ||||
3882 | { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 } | ||||
3883 | }; | ||||
3884 | vkCmdPipelineBarrier(m_commandBuffer->handle(), | ||||
Chris Forbes | cb4c7ad | 2016-07-06 10:28:18 +1200 | [diff] [blame] | 3885 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, |
3886 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, | ||||
Chris Forbes | 51bf7c9 | 2016-06-30 15:22:08 +1200 | [diff] [blame] | 3887 | VK_DEPENDENCY_BY_REGION_BIT, |
3888 | 0, nullptr, 0, nullptr, 1, &imb); | ||||
3889 | |||||
3890 | vkCmdEndRenderPass(m_commandBuffer->handle()); | ||||
3891 | m_errorMonitor->VerifyNotFound(); | ||||
3892 | EndCommandBuffer(); | ||||
3893 | |||||
3894 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); | ||||
3895 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
3896 | vkDestroyImageView(m_device->device(), view, nullptr); | ||||
3897 | } | ||||
3898 | |||||
Chris Forbes | 6b3d3f4 | 2016-06-30 16:09:47 +1200 | [diff] [blame] | 3899 | TEST_F(VkLayerTest, RenderPassTransitionsAttachmentUnused) { |
3900 | TEST_DESCRIPTION("Ensure that layout transitions work correctly without " | ||||
3901 | "errors, when an attachment reference is " | ||||
3902 | "VK_ATTACHMENT_UNUSED"); | ||||
3903 | |||||
3904 | m_errorMonitor->ExpectSuccess(); | ||||
3905 | |||||
3906 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3907 | |||||
3908 | // A renderpass with no attachments | ||||
3909 | VkAttachmentReference att_ref = { | ||||
3910 | VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
3911 | }; | ||||
3912 | |||||
3913 | VkSubpassDescription subpass = { | ||||
3914 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, | ||||
3915 | 1, &att_ref, nullptr, nullptr, 0, nullptr | ||||
3916 | }; | ||||
3917 | |||||
3918 | VkRenderPassCreateInfo rpci = { | ||||
3919 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
3920 | 0, 0, nullptr, 1, &subpass, 0, nullptr | ||||
3921 | }; | ||||
3922 | |||||
3923 | VkRenderPass rp; | ||||
3924 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
3925 | ASSERT_VK_SUCCESS(err); | ||||
3926 | |||||
3927 | // A compatible framebuffer. | ||||
3928 | VkFramebufferCreateInfo fci = { | ||||
3929 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, | ||||
3930 | 0, rp, 0, nullptr, | ||||
3931 | 32, 32, 1 | ||||
3932 | }; | ||||
3933 | VkFramebuffer fb; | ||||
3934 | err = vkCreateFramebuffer(m_device->device(), &fci, nullptr, &fb); | ||||
3935 | ASSERT_VK_SUCCESS(err); | ||||
3936 | |||||
3937 | // Record a command buffer which just begins and ends the renderpass. The | ||||
3938 | // bug manifests in BeginRenderPass. | ||||
3939 | VkRenderPassBeginInfo rpbi = { | ||||
3940 | VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, | ||||
Tobin Ehlis | 0f9aa40 | 2016-07-01 08:47:12 -0600 | [diff] [blame] | 3941 | rp, fb, { { 0, 0 }, { 32, 32 } }, |
Chris Forbes | 6b3d3f4 | 2016-06-30 16:09:47 +1200 | [diff] [blame] | 3942 | 0, nullptr |
3943 | }; | ||||
3944 | BeginCommandBuffer(); | ||||
3945 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, | ||||
3946 | VK_SUBPASS_CONTENTS_INLINE); | ||||
3947 | vkCmdEndRenderPass(m_commandBuffer->handle()); | ||||
3948 | m_errorMonitor->VerifyNotFound(); | ||||
3949 | EndCommandBuffer(); | ||||
3950 | |||||
3951 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); | ||||
3952 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
3953 | } | ||||
3954 | |||||
Mark Lobodzinski | ce7eee7 | 2016-06-14 16:33:29 -0600 | [diff] [blame] | 3955 | // This is a positive test. No errors are expected. |
3956 | TEST_F(VkLayerTest, StencilLoadOp) { | ||||
3957 | TEST_DESCRIPTION("Create a stencil-only attachment with a LOAD_OP set to " | ||||
3958 | "CLEAR. stencil[Load|Store]Op used to be ignored."); | ||||
3959 | VkResult result = VK_SUCCESS; | ||||
3960 | VkImageFormatProperties formatProps; | ||||
3961 | vkGetPhysicalDeviceImageFormatProperties( | ||||
3962 | gpu(), VK_FORMAT_D24_UNORM_S8_UINT, VK_IMAGE_TYPE_2D, | ||||
3963 | VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | | ||||
3964 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, | ||||
3965 | 0, &formatProps); | ||||
3966 | if (formatProps.maxExtent.width < 100 || formatProps.maxExtent.height < 100) { | ||||
3967 | return; | ||||
3968 | } | ||||
3969 | |||||
3970 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3971 | VkFormat depth_stencil_fmt = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
3972 | m_depthStencil->Init(m_device, 100, 100, depth_stencil_fmt, | ||||
3973 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | | ||||
3974 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT); | ||||
3975 | VkAttachmentDescription att = {}; | ||||
3976 | VkAttachmentReference ref = {}; | ||||
3977 | att.format = depth_stencil_fmt; | ||||
3978 | att.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; | ||||
3979 | att.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; | ||||
3980 | att.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; | ||||
3981 | att.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; | ||||
3982 | att.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
3983 | att.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
3984 | |||||
3985 | VkClearValue clear; | ||||
3986 | clear.depthStencil.depth = 1.0; | ||||
3987 | clear.depthStencil.stencil = 0; | ||||
3988 | ref.attachment = 0; | ||||
3989 | ref.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
3990 | |||||
3991 | VkSubpassDescription subpass = {}; | ||||
3992 | subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; | ||||
3993 | subpass.flags = 0; | ||||
3994 | subpass.inputAttachmentCount = 0; | ||||
3995 | subpass.pInputAttachments = NULL; | ||||
3996 | subpass.colorAttachmentCount = 0; | ||||
3997 | subpass.pColorAttachments = NULL; | ||||
3998 | subpass.pResolveAttachments = NULL; | ||||
3999 | subpass.pDepthStencilAttachment = &ref; | ||||
4000 | subpass.preserveAttachmentCount = 0; | ||||
4001 | subpass.pPreserveAttachments = NULL; | ||||
4002 | |||||
4003 | VkRenderPass rp; | ||||
4004 | VkRenderPassCreateInfo rp_info = {}; | ||||
4005 | rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; | ||||
4006 | rp_info.attachmentCount = 1; | ||||
4007 | rp_info.pAttachments = &att; | ||||
4008 | rp_info.subpassCount = 1; | ||||
4009 | rp_info.pSubpasses = &subpass; | ||||
4010 | result = vkCreateRenderPass(device(), &rp_info, NULL, &rp); | ||||
4011 | ASSERT_VK_SUCCESS(result); | ||||
4012 | |||||
4013 | VkImageView *depthView = m_depthStencil->BindInfo(); | ||||
4014 | VkFramebufferCreateInfo fb_info = {}; | ||||
4015 | fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; | ||||
4016 | fb_info.pNext = NULL; | ||||
4017 | fb_info.renderPass = rp; | ||||
4018 | fb_info.attachmentCount = 1; | ||||
4019 | fb_info.pAttachments = depthView; | ||||
4020 | fb_info.width = 100; | ||||
4021 | fb_info.height = 100; | ||||
4022 | fb_info.layers = 1; | ||||
4023 | VkFramebuffer fb; | ||||
4024 | result = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4025 | ASSERT_VK_SUCCESS(result); | ||||
4026 | |||||
4027 | |||||
4028 | VkRenderPassBeginInfo rpbinfo = {}; | ||||
4029 | rpbinfo.clearValueCount = 1; | ||||
4030 | rpbinfo.pClearValues = &clear; | ||||
4031 | rpbinfo.pNext = NULL; | ||||
4032 | rpbinfo.renderPass = rp; | ||||
4033 | rpbinfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; | ||||
4034 | rpbinfo.renderArea.extent.width = 100; | ||||
4035 | rpbinfo.renderArea.extent.height = 100; | ||||
4036 | rpbinfo.renderArea.offset.x = 0; | ||||
4037 | rpbinfo.renderArea.offset.y = 0; | ||||
4038 | rpbinfo.framebuffer = fb; | ||||
4039 | |||||
4040 | VkFence fence = {}; | ||||
4041 | VkFenceCreateInfo fence_ci = {}; | ||||
4042 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
4043 | fence_ci.pNext = nullptr; | ||||
4044 | fence_ci.flags = 0; | ||||
4045 | result = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fence); | ||||
4046 | ASSERT_VK_SUCCESS(result); | ||||
4047 | |||||
4048 | |||||
4049 | m_commandBuffer->BeginCommandBuffer(); | ||||
4050 | m_commandBuffer->BeginRenderPass(rpbinfo); | ||||
4051 | m_commandBuffer->EndRenderPass(); | ||||
4052 | m_commandBuffer->EndCommandBuffer(); | ||||
4053 | m_commandBuffer->QueueCommandBuffer(fence); | ||||
4054 | |||||
4055 | VkImageObj destImage(m_device); | ||||
4056 | destImage.init(100, 100, depth_stencil_fmt, | ||||
4057 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | | ||||
4058 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
4059 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
4060 | VkImageMemoryBarrier barrier = {}; | ||||
4061 | VkImageSubresourceRange range; | ||||
4062 | barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; | ||||
4063 | barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT | | ||||
4064 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; | ||||
4065 | barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | | ||||
4066 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; | ||||
4067 | barrier.oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
4068 | barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; | ||||
4069 | barrier.image = m_depthStencil->handle(); | ||||
4070 | range.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; | ||||
4071 | range.baseMipLevel = 0; | ||||
4072 | range.levelCount = 1; | ||||
4073 | range.baseArrayLayer = 0; | ||||
4074 | range.layerCount = 1; | ||||
4075 | barrier.subresourceRange = range; | ||||
4076 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
4077 | VkCommandBufferObj cmdbuf(m_device, m_commandPool); | ||||
4078 | cmdbuf.BeginCommandBuffer(); | ||||
4079 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
4080 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, | ||||
4081 | nullptr, 1, &barrier); | ||||
4082 | barrier.srcAccessMask = 0; | ||||
4083 | barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; | ||||
4084 | barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; | ||||
4085 | barrier.image = destImage.handle(); | ||||
4086 | barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT | | ||||
4087 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; | ||||
4088 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
4089 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, | ||||
4090 | nullptr, 1, &barrier); | ||||
4091 | VkImageCopy cregion; | ||||
4092 | cregion.srcSubresource.aspectMask = | ||||
4093 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; | ||||
4094 | cregion.srcSubresource.mipLevel = 0; | ||||
4095 | cregion.srcSubresource.baseArrayLayer = 0; | ||||
4096 | cregion.srcSubresource.layerCount = 1; | ||||
4097 | cregion.srcOffset.x = 0; | ||||
4098 | cregion.srcOffset.y = 0; | ||||
4099 | cregion.srcOffset.z = 0; | ||||
4100 | cregion.dstSubresource.aspectMask = | ||||
4101 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; | ||||
4102 | cregion.dstSubresource.mipLevel = 0; | ||||
4103 | cregion.dstSubresource.baseArrayLayer = 0; | ||||
4104 | cregion.dstSubresource.layerCount = 1; | ||||
4105 | cregion.dstOffset.x = 0; | ||||
4106 | cregion.dstOffset.y = 0; | ||||
4107 | cregion.dstOffset.z = 0; | ||||
4108 | cregion.extent.width = 100; | ||||
4109 | cregion.extent.height = 100; | ||||
4110 | cregion.extent.depth = 1; | ||||
4111 | cmdbuf.CopyImage(m_depthStencil->handle(), | ||||
4112 | VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, destImage.handle(), | ||||
4113 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &cregion); | ||||
4114 | cmdbuf.EndCommandBuffer(); | ||||
4115 | |||||
4116 | VkSubmitInfo submit_info; | ||||
4117 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
4118 | submit_info.pNext = NULL; | ||||
4119 | submit_info.waitSemaphoreCount = 0; | ||||
4120 | submit_info.pWaitSemaphores = NULL; | ||||
4121 | submit_info.pWaitDstStageMask = NULL; | ||||
4122 | submit_info.commandBufferCount = 1; | ||||
4123 | submit_info.pCommandBuffers = &cmdbuf.handle(); | ||||
4124 | submit_info.signalSemaphoreCount = 0; | ||||
4125 | submit_info.pSignalSemaphores = NULL; | ||||
4126 | |||||
4127 | m_errorMonitor->ExpectSuccess(); | ||||
4128 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
4129 | m_errorMonitor->VerifyNotFound(); | ||||
4130 | |||||
Mark Lobodzinski | d0440da | 2016-06-17 15:10:03 -0600 | [diff] [blame] | 4131 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | ce7eee7 | 2016-06-14 16:33:29 -0600 | [diff] [blame] | 4132 | vkDestroyFence(m_device->device(), fence, nullptr); |
4133 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
4134 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); | ||||
4135 | } | ||||
4136 | |||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4137 | TEST_F(VkLayerTest, UnusedPreserveAttachment) { |
4138 | TEST_DESCRIPTION("Create a framebuffer where a subpass has a preserve " | ||||
4139 | "attachment reference of VK_ATTACHMENT_UNUSED"); | ||||
4140 | |||||
4141 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4142 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
4143 | |||||
4144 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4145 | "must not be VK_ATTACHMENT_UNUSED"); | ||||
4146 | |||||
4147 | VkAttachmentReference color_attach = {}; | ||||
4148 | color_attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
4149 | color_attach.attachment = 0; | ||||
4150 | uint32_t preserve_attachment = VK_ATTACHMENT_UNUSED; | ||||
4151 | VkSubpassDescription subpass = {}; | ||||
4152 | subpass.colorAttachmentCount = 1; | ||||
4153 | subpass.pColorAttachments = &color_attach; | ||||
4154 | subpass.preserveAttachmentCount = 1; | ||||
4155 | subpass.pPreserveAttachments = &preserve_attachment; | ||||
4156 | |||||
4157 | VkRenderPassCreateInfo rpci = {}; | ||||
4158 | rpci.subpassCount = 1; | ||||
4159 | rpci.pSubpasses = &subpass; | ||||
4160 | rpci.attachmentCount = 1; | ||||
4161 | VkAttachmentDescription attach_desc = {}; | ||||
4162 | attach_desc.format = VK_FORMAT_UNDEFINED; | ||||
4163 | rpci.pAttachments = &attach_desc; | ||||
4164 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; | ||||
4165 | VkRenderPass rp; | ||||
Mark Lobodzinski | a4feeeb | 2016-06-17 12:00:46 -0600 | [diff] [blame] | 4166 | VkResult result = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4167 | |
4168 | m_errorMonitor->VerifyFound(); | ||||
4169 | |||||
Mark Lobodzinski | a4feeeb | 2016-06-17 12:00:46 -0600 | [diff] [blame] | 4170 | if (result == VK_SUCCESS) { |
4171 | vkDestroyRenderPass(m_device->device(), rp, NULL); | ||||
4172 | } | ||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4173 | } |
4174 | |||||
Chris Forbes | c538974 | 2016-06-29 11:49:23 +1200 | [diff] [blame] | 4175 | TEST_F(VkLayerTest, CreateRenderPassResolveRequiresColorMsaa) { |
Chris Forbes | 6655bb3 | 2016-07-01 18:27:30 +1200 | [diff] [blame] | 4176 | TEST_DESCRIPTION("Ensure that CreateRenderPass produces a validation error " |
4177 | "when the source of a subpass multisample resolve " | ||||
4178 | "does not have multiple samples."); | ||||
4179 | |||||
Chris Forbes | c538974 | 2016-06-29 11:49:23 +1200 | [diff] [blame] | 4180 | ASSERT_NO_FATAL_FAILURE(InitState()); |
4181 | |||||
4182 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4183 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Chris Forbes | 6655bb3 | 2016-07-01 18:27:30 +1200 | [diff] [blame] | 4184 | "Subpass 0 requests multisample resolve from attachment 0 which has " |
4185 | "VK_SAMPLE_COUNT_1_BIT"); | ||||
Chris Forbes | c538974 | 2016-06-29 11:49:23 +1200 | [diff] [blame] | 4186 | |
4187 | VkAttachmentDescription attachments[] = { | ||||
4188 | { | ||||
4189 | 0, VK_FORMAT_R8G8B8A8_UNORM, | ||||
4190 | VK_SAMPLE_COUNT_1_BIT, | ||||
4191 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4192 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4193 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4194 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4195 | }, | ||||
4196 | { | ||||
4197 | 0, VK_FORMAT_R8G8B8A8_UNORM, | ||||
4198 | VK_SAMPLE_COUNT_1_BIT, | ||||
4199 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4200 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4201 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4202 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4203 | }, | ||||
4204 | }; | ||||
4205 | |||||
4206 | VkAttachmentReference color = { | ||||
4207 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4208 | }; | ||||
4209 | |||||
4210 | VkAttachmentReference resolve = { | ||||
4211 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4212 | }; | ||||
4213 | |||||
4214 | VkSubpassDescription subpass = { | ||||
4215 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
4216 | 0, nullptr, | ||||
4217 | 1, &color, | ||||
4218 | &resolve, | ||||
4219 | nullptr, | ||||
4220 | 0, nullptr | ||||
4221 | }; | ||||
4222 | |||||
4223 | VkRenderPassCreateInfo rpci = { | ||||
4224 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
4225 | 0, 2, attachments, 1, &subpass, 0, nullptr | ||||
4226 | }; | ||||
4227 | |||||
4228 | VkRenderPass rp; | ||||
4229 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
4230 | |||||
4231 | m_errorMonitor->VerifyFound(); | ||||
4232 | |||||
4233 | if (err == VK_SUCCESS) | ||||
4234 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
4235 | } | ||||
4236 | |||||
4237 | TEST_F(VkLayerTest, CreateRenderPassResolveRequiresSingleSampleDest) { | ||||
Chris Forbes | 6655bb3 | 2016-07-01 18:27:30 +1200 | [diff] [blame] | 4238 | TEST_DESCRIPTION("Ensure CreateRenderPass produces a validation error " |
4239 | "when a subpass multisample resolve operation is " | ||||
4240 | "requested, and the destination of that resolve has " | ||||
4241 | "multiple samples."); | ||||
4242 | |||||
Chris Forbes | c538974 | 2016-06-29 11:49:23 +1200 | [diff] [blame] | 4243 | ASSERT_NO_FATAL_FAILURE(InitState()); |
4244 | |||||
4245 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4246 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4247 | "Subpass 0 requests multisample resolve into attachment 1, which " | ||||
4248 | "must have VK_SAMPLE_COUNT_1_BIT but has VK_SAMPLE_COUNT_4_BIT"); | ||||
4249 | |||||
4250 | VkAttachmentDescription attachments[] = { | ||||
4251 | { | ||||
4252 | 0, VK_FORMAT_R8G8B8A8_UNORM, | ||||
4253 | VK_SAMPLE_COUNT_4_BIT, | ||||
4254 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4255 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4256 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4257 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4258 | }, | ||||
4259 | { | ||||
4260 | 0, VK_FORMAT_R8G8B8A8_UNORM, | ||||
4261 | VK_SAMPLE_COUNT_4_BIT, | ||||
4262 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4263 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4264 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4265 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4266 | }, | ||||
4267 | }; | ||||
4268 | |||||
4269 | VkAttachmentReference color = { | ||||
4270 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4271 | }; | ||||
4272 | |||||
4273 | VkAttachmentReference resolve = { | ||||
4274 | 1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4275 | }; | ||||
4276 | |||||
4277 | VkSubpassDescription subpass = { | ||||
4278 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
4279 | 0, nullptr, | ||||
4280 | 1, &color, | ||||
4281 | &resolve, | ||||
4282 | nullptr, | ||||
4283 | 0, nullptr | ||||
4284 | }; | ||||
4285 | |||||
4286 | VkRenderPassCreateInfo rpci = { | ||||
4287 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
4288 | 0, 2, attachments, 1, &subpass, 0, nullptr | ||||
4289 | }; | ||||
4290 | |||||
4291 | VkRenderPass rp; | ||||
4292 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
4293 | |||||
4294 | m_errorMonitor->VerifyFound(); | ||||
4295 | |||||
4296 | if (err == VK_SUCCESS) | ||||
4297 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
4298 | } | ||||
4299 | |||||
Chris Forbes | 3f128ef | 2016-06-29 14:58:53 +1200 | [diff] [blame] | 4300 | TEST_F(VkLayerTest, CreateRenderPassSubpassSampleCountConsistency) { |
Chris Forbes | 6655bb3 | 2016-07-01 18:27:30 +1200 | [diff] [blame] | 4301 | TEST_DESCRIPTION("Ensure CreateRenderPass produces a validation error " |
4302 | "when the color and depth attachments used by a subpass " | ||||
4303 | "have inconsistent sample counts"); | ||||
4304 | |||||
Chris Forbes | 3f128ef | 2016-06-29 14:58:53 +1200 | [diff] [blame] | 4305 | ASSERT_NO_FATAL_FAILURE(InitState()); |
4306 | |||||
4307 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4308 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4309 | "Subpass 0 attempts to render to attachments with inconsistent sample counts"); | ||||
4310 | |||||
4311 | VkAttachmentDescription attachments[] = { | ||||
4312 | { | ||||
4313 | 0, VK_FORMAT_R8G8B8A8_UNORM, | ||||
4314 | VK_SAMPLE_COUNT_1_BIT, | ||||
4315 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4316 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4317 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4318 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4319 | }, | ||||
4320 | { | ||||
4321 | 0, VK_FORMAT_R8G8B8A8_UNORM, | ||||
4322 | VK_SAMPLE_COUNT_4_BIT, | ||||
4323 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4324 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4325 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4326 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4327 | }, | ||||
4328 | }; | ||||
4329 | |||||
4330 | VkAttachmentReference color[] = { | ||||
4331 | { | ||||
4332 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4333 | }, | ||||
4334 | { | ||||
4335 | 1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4336 | }, | ||||
4337 | }; | ||||
4338 | |||||
4339 | VkSubpassDescription subpass = { | ||||
4340 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
4341 | 0, nullptr, | ||||
4342 | 2, color, | ||||
4343 | nullptr, | ||||
4344 | nullptr, | ||||
4345 | 0, nullptr | ||||
4346 | }; | ||||
4347 | |||||
4348 | VkRenderPassCreateInfo rpci = { | ||||
4349 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
4350 | 0, 2, attachments, 1, &subpass, 0, nullptr | ||||
4351 | }; | ||||
4352 | |||||
4353 | VkRenderPass rp; | ||||
4354 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
4355 | |||||
4356 | m_errorMonitor->VerifyFound(); | ||||
4357 | |||||
4358 | if (err == VK_SUCCESS) | ||||
4359 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
4360 | } | ||||
4361 | |||||
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4362 | TEST_F(VkLayerTest, FramebufferCreateErrors) { |
4363 | TEST_DESCRIPTION("Hit errors when attempting to create a framebuffer :\n" | ||||
4364 | " 1. Mismatch between fb & renderPass attachmentCount\n" | ||||
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 4365 | " 2. Use a color image as depthStencil attachment\n" |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 4366 | " 3. Mismatch fb & renderPass attachment formats\n" |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 4367 | " 4. Mismatch fb & renderPass attachment #samples\n" |
Tobin Ehlis | 27f2ae8 | 2016-06-23 07:36:57 -0600 | [diff] [blame] | 4368 | " 5. FB attachment w/ non-1 mip-levels\n" |
Tobin Ehlis | b1f303b | 2016-06-23 08:19:55 -0600 | [diff] [blame] | 4369 | " 6. FB attachment where dimensions don't match\n" |
Tobin Ehlis | 08d4b5e | 2016-06-23 08:52:39 -0600 | [diff] [blame] | 4370 | " 7. FB attachment w/o identity swizzle\n" |
4371 | " 8. FB dimensions exceed physical device limits\n"); | ||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4372 | |
4373 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4374 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
4375 | |||||
4376 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4377 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4378 | "vkCreateFramebuffer(): VkFramebufferCreateInfo attachmentCount of 2 " |
4379 | "does not match attachmentCount of 1 of "); | ||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4380 | |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4381 | // Create a renderPass with a single color attachment |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4382 | VkAttachmentReference attach = {}; |
4383 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
4384 | VkSubpassDescription subpass = {}; | ||||
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4385 | subpass.pColorAttachments = &attach; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4386 | VkRenderPassCreateInfo rpci = {}; |
4387 | rpci.subpassCount = 1; | ||||
4388 | rpci.pSubpasses = &subpass; | ||||
4389 | rpci.attachmentCount = 1; | ||||
4390 | VkAttachmentDescription attach_desc = {}; | ||||
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 4391 | attach_desc.format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 4392 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4393 | rpci.pAttachments = &attach_desc; |
4394 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; | ||||
4395 | VkRenderPass rp; | ||||
4396 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
4397 | ASSERT_VK_SUCCESS(err); | ||||
4398 | |||||
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4399 | VkImageView ivs[2]; |
4400 | ivs[0] = m_renderTargets[0]->targetView(VK_FORMAT_B8G8R8A8_UNORM); | ||||
4401 | ivs[1] = m_renderTargets[0]->targetView(VK_FORMAT_B8G8R8A8_UNORM); | ||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4402 | VkFramebufferCreateInfo fb_info = {}; |
4403 | fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; | ||||
4404 | fb_info.pNext = NULL; | ||||
4405 | fb_info.renderPass = rp; | ||||
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4406 | // Set mis-matching attachmentCount |
4407 | fb_info.attachmentCount = 2; | ||||
4408 | fb_info.pAttachments = ivs; | ||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4409 | fb_info.width = 100; |
4410 | fb_info.height = 100; | ||||
4411 | fb_info.layers = 1; | ||||
4412 | |||||
4413 | VkFramebuffer fb; | ||||
4414 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4415 | |||||
4416 | m_errorMonitor->VerifyFound(); | ||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4417 | if (err == VK_SUCCESS) { |
4418 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4419 | } | ||||
4420 | vkDestroyRenderPass(m_device->device(), rp, NULL); | ||||
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4421 | |
4422 | // Create a renderPass with a depth-stencil attachment created with | ||||
4423 | // IMAGE_USAGE_COLOR_ATTACHMENT | ||||
4424 | // Add our color attachment to pDepthStencilAttachment | ||||
4425 | subpass.pDepthStencilAttachment = &attach; | ||||
4426 | subpass.pColorAttachments = NULL; | ||||
4427 | VkRenderPass rp_ds; | ||||
4428 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp_ds); | ||||
4429 | ASSERT_VK_SUCCESS(err); | ||||
4430 | // Set correct attachment count, but attachment has COLOR usage bit set | ||||
4431 | fb_info.attachmentCount = 1; | ||||
4432 | fb_info.renderPass = rp_ds; | ||||
4433 | |||||
4434 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4435 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4436 | " conflicts with the image's IMAGE_USAGE flags "); | ||||
4437 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4438 | |||||
4439 | m_errorMonitor->VerifyFound(); | ||||
4440 | if (err == VK_SUCCESS) { | ||||
4441 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4442 | } | ||||
4443 | vkDestroyRenderPass(m_device->device(), rp_ds, NULL); | ||||
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 4444 | |
4445 | // Create new renderpass with alternate attachment format from fb | ||||
4446 | attach_desc.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
4447 | subpass.pDepthStencilAttachment = NULL; | ||||
4448 | subpass.pColorAttachments = &attach; | ||||
4449 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
4450 | ASSERT_VK_SUCCESS(err); | ||||
4451 | |||||
4452 | // Cause error due to mis-matched formats between rp & fb | ||||
4453 | // rp attachment 0 now has RGBA8 but corresponding fb attach is BGRA8 | ||||
4454 | fb_info.renderPass = rp; | ||||
4455 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4456 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4457 | " has format of VK_FORMAT_B8G8R8A8_UNORM that does not match "); | ||||
4458 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4459 | |||||
4460 | m_errorMonitor->VerifyFound(); | ||||
4461 | if (err == VK_SUCCESS) { | ||||
4462 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4463 | } | ||||
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 4464 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
4465 | |||||
4466 | // Create new renderpass with alternate sample count from fb | ||||
4467 | attach_desc.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
4468 | attach_desc.samples = VK_SAMPLE_COUNT_4_BIT; | ||||
4469 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
4470 | ASSERT_VK_SUCCESS(err); | ||||
4471 | |||||
4472 | // Cause error due to mis-matched sample count between rp & fb | ||||
4473 | fb_info.renderPass = rp; | ||||
4474 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4475 | " has VK_SAMPLE_COUNT_1_BIT samples " | ||||
4476 | "that do not match the " | ||||
4477 | "VK_SAMPLE_COUNT_4_BIT "); | ||||
4478 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4479 | |||||
4480 | m_errorMonitor->VerifyFound(); | ||||
4481 | if (err == VK_SUCCESS) { | ||||
4482 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4483 | } | ||||
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 4484 | |
4485 | vkDestroyRenderPass(m_device->device(), rp, NULL); | ||||
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 4486 | |
4487 | // Create a custom imageView with non-1 mip levels | ||||
4488 | VkImageObj image(m_device); | ||||
4489 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
4490 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); | ||||
4491 | ASSERT_TRUE(image.initialized()); | ||||
4492 | |||||
4493 | VkImageView view; | ||||
4494 | VkImageViewCreateInfo ivci = {}; | ||||
4495 | ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
4496 | ivci.image = image.handle(); | ||||
4497 | ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
4498 | ivci.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
4499 | ivci.subresourceRange.layerCount = 1; | ||||
4500 | ivci.subresourceRange.baseMipLevel = 0; | ||||
4501 | // Set level count 2 (only 1 is allowed for FB attachment) | ||||
4502 | ivci.subresourceRange.levelCount = 2; | ||||
4503 | ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
4504 | err = vkCreateImageView(m_device->device(), &ivci, NULL, &view); | ||||
4505 | ASSERT_VK_SUCCESS(err); | ||||
4506 | // Re-create renderpass to have matching sample count | ||||
4507 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
4508 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
4509 | ASSERT_VK_SUCCESS(err); | ||||
4510 | |||||
4511 | fb_info.renderPass = rp; | ||||
4512 | fb_info.pAttachments = &view; | ||||
4513 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4514 | " has mip levelCount of 2 but only "); | ||||
4515 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4516 | |||||
4517 | m_errorMonitor->VerifyFound(); | ||||
4518 | if (err == VK_SUCCESS) { | ||||
4519 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4520 | } | ||||
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 4521 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 27f2ae8 | 2016-06-23 07:36:57 -0600 | [diff] [blame] | 4522 | // Update view to original color buffer and grow FB dimensions too big |
4523 | fb_info.pAttachments = ivs; | ||||
4524 | fb_info.height = 1024; | ||||
4525 | fb_info.width = 1024; | ||||
4526 | fb_info.layers = 2; | ||||
4527 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4528 | " Attachment dimensions must be at " | ||||
4529 | "least as large. "); | ||||
4530 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4531 | |||||
4532 | m_errorMonitor->VerifyFound(); | ||||
4533 | if (err == VK_SUCCESS) { | ||||
4534 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4535 | } | ||||
Tobin Ehlis | b1f303b | 2016-06-23 08:19:55 -0600 | [diff] [blame] | 4536 | // Create view attachment with non-identity swizzle |
4537 | ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
4538 | ivci.image = image.handle(); | ||||
4539 | ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
4540 | ivci.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
4541 | ivci.subresourceRange.layerCount = 1; | ||||
4542 | ivci.subresourceRange.baseMipLevel = 0; | ||||
4543 | ivci.subresourceRange.levelCount = 1; | ||||
4544 | ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
4545 | ivci.components.r = VK_COMPONENT_SWIZZLE_G; | ||||
4546 | ivci.components.g = VK_COMPONENT_SWIZZLE_R; | ||||
4547 | ivci.components.b = VK_COMPONENT_SWIZZLE_A; | ||||
4548 | ivci.components.a = VK_COMPONENT_SWIZZLE_B; | ||||
4549 | err = vkCreateImageView(m_device->device(), &ivci, NULL, &view); | ||||
4550 | ASSERT_VK_SUCCESS(err); | ||||
4551 | |||||
4552 | fb_info.pAttachments = &view; | ||||
4553 | fb_info.height = 100; | ||||
4554 | fb_info.width = 100; | ||||
4555 | fb_info.layers = 1; | ||||
4556 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4557 | " has non-identy swizzle. All " | ||||
4558 | "framebuffer attachments must have " | ||||
4559 | "been created with the identity " | ||||
4560 | "swizzle. "); | ||||
4561 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4562 | |||||
4563 | m_errorMonitor->VerifyFound(); | ||||
4564 | if (err == VK_SUCCESS) { | ||||
4565 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4566 | } | ||||
4567 | vkDestroyImageView(m_device->device(), view, NULL); | ||||
Tobin Ehlis | 08d4b5e | 2016-06-23 08:52:39 -0600 | [diff] [blame] | 4568 | // Request fb that exceeds max dimensions |
4569 | // reset attachment to color attachment | ||||
4570 | fb_info.pAttachments = ivs; | ||||
4571 | fb_info.width = m_device->props.limits.maxFramebufferWidth + 1; | ||||
4572 | fb_info.height = m_device->props.limits.maxFramebufferHeight + 1; | ||||
4573 | fb_info.layers = m_device->props.limits.maxFramebufferLayers + 1; | ||||
4574 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4575 | " Requested VkFramebufferCreateInfo " | ||||
4576 | "dimensions exceed physical device " | ||||
4577 | "limits. "); | ||||
4578 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4579 | |||||
4580 | m_errorMonitor->VerifyFound(); | ||||
4581 | if (err == VK_SUCCESS) { | ||||
4582 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4583 | } | ||||
Tobin Ehlis | 27f2ae8 | 2016-06-23 07:36:57 -0600 | [diff] [blame] | 4584 | |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 4585 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4586 | } |
4587 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4588 | // This is a positive test. No errors should be generated. |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4589 | TEST_F(VkLayerTest, WaitEventThenSet) { |
4590 | TEST_DESCRIPTION( | ||||
4591 | "Wait on a event then set it after the wait has been submitted."); | ||||
4592 | |||||
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4593 | m_errorMonitor->ExpectSuccess(); |
4594 | |||||
4595 | VkEvent event; | ||||
4596 | VkEventCreateInfo event_create_info{}; | ||||
4597 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
4598 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); | ||||
4599 | |||||
4600 | VkCommandPool command_pool; | ||||
4601 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
4602 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
4603 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
4604 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
4605 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
4606 | &command_pool); | ||||
4607 | |||||
4608 | VkCommandBuffer command_buffer; | ||||
4609 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
4610 | command_buffer_allocate_info.sType = | ||||
4611 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
4612 | command_buffer_allocate_info.commandPool = command_pool; | ||||
4613 | command_buffer_allocate_info.commandBufferCount = 1; | ||||
4614 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
4615 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
4616 | &command_buffer); | ||||
4617 | |||||
4618 | VkQueue queue = VK_NULL_HANDLE; | ||||
4619 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 4620 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4621 | |
4622 | { | ||||
4623 | VkCommandBufferBeginInfo begin_info{}; | ||||
4624 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
4625 | vkBeginCommandBuffer(command_buffer, &begin_info); | ||||
4626 | |||||
4627 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, | ||||
4628 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, | ||||
4629 | nullptr, 0, nullptr); | ||||
4630 | vkCmdResetEvent(command_buffer, event, | ||||
4631 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); | ||||
4632 | vkEndCommandBuffer(command_buffer); | ||||
4633 | } | ||||
4634 | { | ||||
4635 | VkSubmitInfo submit_info{}; | ||||
4636 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
4637 | submit_info.commandBufferCount = 1; | ||||
4638 | submit_info.pCommandBuffers = &command_buffer; | ||||
4639 | submit_info.signalSemaphoreCount = 0; | ||||
4640 | submit_info.pSignalSemaphores = nullptr; | ||||
4641 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
4642 | } | ||||
4643 | { vkSetEvent(m_device->device(), event); } | ||||
4644 | |||||
4645 | vkQueueWaitIdle(queue); | ||||
4646 | |||||
4647 | vkDestroyEvent(m_device->device(), event, nullptr); | ||||
4648 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); | ||||
4649 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
4650 | |||||
4651 | m_errorMonitor->VerifyNotFound(); | ||||
4652 | } | ||||
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 4653 | // This is a positive test. No errors should be generated. |
4654 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { | ||||
4655 | TEST_DESCRIPTION( | ||||
4656 | "Issue a query and copy from it on a second command buffer."); | ||||
4657 | |||||
4658 | if ((m_device->queue_props.empty()) || | ||||
4659 | (m_device->queue_props[0].queueCount < 2)) | ||||
4660 | return; | ||||
4661 | |||||
4662 | m_errorMonitor->ExpectSuccess(); | ||||
4663 | |||||
4664 | VkQueryPool query_pool; | ||||
4665 | VkQueryPoolCreateInfo query_pool_create_info{}; | ||||
4666 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; | ||||
4667 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; | ||||
4668 | query_pool_create_info.queryCount = 1; | ||||
4669 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, | ||||
4670 | &query_pool); | ||||
4671 | |||||
4672 | VkCommandPool command_pool; | ||||
4673 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
4674 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
4675 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
4676 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
4677 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
4678 | &command_pool); | ||||
4679 | |||||
4680 | VkCommandBuffer command_buffer[2]; | ||||
4681 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
4682 | command_buffer_allocate_info.sType = | ||||
4683 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
4684 | command_buffer_allocate_info.commandPool = command_pool; | ||||
4685 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
4686 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
4687 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
4688 | command_buffer); | ||||
4689 | |||||
4690 | VkQueue queue = VK_NULL_HANDLE; | ||||
4691 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
4692 | 1, &queue); | ||||
4693 | |||||
4694 | uint32_t qfi = 0; | ||||
4695 | VkBufferCreateInfo buff_create_info = {}; | ||||
4696 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
4697 | buff_create_info.size = 1024; | ||||
4698 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; | ||||
4699 | buff_create_info.queueFamilyIndexCount = 1; | ||||
4700 | buff_create_info.pQueueFamilyIndices = &qfi; | ||||
4701 | |||||
4702 | VkResult err; | ||||
4703 | VkBuffer buffer; | ||||
4704 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); | ||||
4705 | ASSERT_VK_SUCCESS(err); | ||||
4706 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
4707 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
4708 | mem_alloc.pNext = NULL; | ||||
4709 | mem_alloc.allocationSize = 1024; | ||||
4710 | mem_alloc.memoryTypeIndex = 0; | ||||
4711 | |||||
4712 | VkMemoryRequirements memReqs; | ||||
4713 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); | ||||
4714 | bool pass = | ||||
4715 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); | ||||
4716 | if (!pass) { | ||||
4717 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
4718 | return; | ||||
4719 | } | ||||
4720 | |||||
4721 | VkDeviceMemory mem; | ||||
4722 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); | ||||
4723 | ASSERT_VK_SUCCESS(err); | ||||
4724 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
4725 | ASSERT_VK_SUCCESS(err); | ||||
4726 | |||||
4727 | { | ||||
4728 | VkCommandBufferBeginInfo begin_info{}; | ||||
4729 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
4730 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
4731 | |||||
4732 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); | ||||
4733 | vkCmdWriteTimestamp(command_buffer[0], | ||||
4734 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); | ||||
4735 | |||||
4736 | vkEndCommandBuffer(command_buffer[0]); | ||||
4737 | |||||
4738 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
4739 | |||||
4740 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, | ||||
4741 | 0, 0, 0); | ||||
4742 | |||||
4743 | vkEndCommandBuffer(command_buffer[1]); | ||||
4744 | } | ||||
4745 | { | ||||
4746 | VkSubmitInfo submit_info{}; | ||||
4747 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
4748 | submit_info.commandBufferCount = 2; | ||||
4749 | submit_info.pCommandBuffers = command_buffer; | ||||
4750 | submit_info.signalSemaphoreCount = 0; | ||||
4751 | submit_info.pSignalSemaphores = nullptr; | ||||
4752 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
4753 | } | ||||
4754 | |||||
4755 | vkQueueWaitIdle(queue); | ||||
4756 | |||||
4757 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); | ||||
4758 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); | ||||
4759 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4760 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
4761 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 4762 | |
4763 | m_errorMonitor->VerifyNotFound(); | ||||
4764 | } | ||||
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4765 | |
4766 | TEST_F(VkLayerTest, ResetEventThenSet) { | ||||
4767 | TEST_DESCRIPTION( | ||||
4768 | "Reset an event then set it after the reset has been submitted."); | ||||
4769 | |||||
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4770 | m_errorMonitor->ExpectSuccess(); |
4771 | |||||
4772 | VkEvent event; | ||||
4773 | VkEventCreateInfo event_create_info{}; | ||||
4774 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
4775 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); | ||||
4776 | |||||
4777 | VkCommandPool command_pool; | ||||
4778 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
4779 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
4780 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
4781 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
4782 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
4783 | &command_pool); | ||||
4784 | |||||
4785 | VkCommandBuffer command_buffer; | ||||
4786 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
4787 | command_buffer_allocate_info.sType = | ||||
4788 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
4789 | command_buffer_allocate_info.commandPool = command_pool; | ||||
4790 | command_buffer_allocate_info.commandBufferCount = 1; | ||||
4791 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
4792 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
4793 | &command_buffer); | ||||
4794 | |||||
4795 | VkQueue queue = VK_NULL_HANDLE; | ||||
4796 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 4797 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4798 | |
4799 | { | ||||
4800 | VkCommandBufferBeginInfo begin_info{}; | ||||
4801 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
4802 | vkBeginCommandBuffer(command_buffer, &begin_info); | ||||
4803 | |||||
4804 | vkCmdResetEvent(command_buffer, event, | ||||
4805 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); | ||||
4806 | vkCmdWaitEvents(command_buffer, 1, &event, | ||||
4807 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
4808 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, | ||||
4809 | nullptr, 0, nullptr); | ||||
4810 | vkEndCommandBuffer(command_buffer); | ||||
4811 | } | ||||
4812 | { | ||||
4813 | VkSubmitInfo submit_info{}; | ||||
4814 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
4815 | submit_info.commandBufferCount = 1; | ||||
4816 | submit_info.pCommandBuffers = &command_buffer; | ||||
4817 | submit_info.signalSemaphoreCount = 0; | ||||
4818 | submit_info.pSignalSemaphores = nullptr; | ||||
4819 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
4820 | } | ||||
4821 | { | ||||
4822 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4823 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " | ||||
4824 | "0x1 that is already in use by a " | ||||
4825 | "command buffer."); | ||||
4826 | vkSetEvent(m_device->device(), event); | ||||
4827 | m_errorMonitor->VerifyFound(); | ||||
4828 | } | ||||
4829 | |||||
4830 | vkQueueWaitIdle(queue); | ||||
4831 | |||||
4832 | vkDestroyEvent(m_device->device(), event, nullptr); | ||||
4833 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); | ||||
4834 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
4835 | } | ||||
4836 | |||||
4837 | // This is a positive test. No errors should be generated. | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4838 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
4839 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " | ||||
4840 | "run through a Submit & WaitForFences cycle 3 times. This " | ||||
4841 | "previously revealed a bug so running this positive test " | ||||
4842 | "to prevent a regression."); | ||||
4843 | m_errorMonitor->ExpectSuccess(); | ||||
4844 | |||||
4845 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4846 | VkQueue queue = VK_NULL_HANDLE; | ||||
4847 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
4848 | 0, &queue); | ||||
4849 | |||||
4850 | static const uint32_t NUM_OBJECTS = 2; | ||||
4851 | static const uint32_t NUM_FRAMES = 3; | ||||
4852 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; | ||||
4853 | VkFence fences[NUM_OBJECTS] = {}; | ||||
4854 | |||||
4855 | VkCommandPool cmd_pool; | ||||
4856 | VkCommandPoolCreateInfo cmd_pool_ci = {}; | ||||
4857 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
4858 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
4859 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
4860 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, | ||||
4861 | nullptr, &cmd_pool); | ||||
4862 | ASSERT_VK_SUCCESS(err); | ||||
4863 | |||||
4864 | VkCommandBufferAllocateInfo cmd_buf_info = {}; | ||||
4865 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
4866 | cmd_buf_info.commandPool = cmd_pool; | ||||
4867 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
4868 | cmd_buf_info.commandBufferCount = 1; | ||||
4869 | |||||
4870 | VkFenceCreateInfo fence_ci = {}; | ||||
4871 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
4872 | fence_ci.pNext = nullptr; | ||||
4873 | fence_ci.flags = 0; | ||||
4874 | |||||
4875 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { | ||||
4876 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, | ||||
4877 | &cmd_buffers[i]); | ||||
4878 | ASSERT_VK_SUCCESS(err); | ||||
4879 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); | ||||
4880 | ASSERT_VK_SUCCESS(err); | ||||
4881 | } | ||||
4882 | |||||
4883 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { | ||||
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 4884 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
4885 | // Create empty cmd buffer | ||||
4886 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; | ||||
4887 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4888 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 4889 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
4890 | ASSERT_VK_SUCCESS(err); | ||||
4891 | err = vkEndCommandBuffer(cmd_buffers[obj]); | ||||
4892 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4893 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 4894 | VkSubmitInfo submit_info = {}; |
4895 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
4896 | submit_info.commandBufferCount = 1; | ||||
4897 | submit_info.pCommandBuffers = &cmd_buffers[obj]; | ||||
4898 | // Submit cmd buffer and wait for fence | ||||
4899 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); | ||||
4900 | ASSERT_VK_SUCCESS(err); | ||||
4901 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, | ||||
4902 | UINT64_MAX); | ||||
4903 | ASSERT_VK_SUCCESS(err); | ||||
4904 | err = vkResetFences(m_device->device(), 1, &fences[obj]); | ||||
4905 | ASSERT_VK_SUCCESS(err); | ||||
4906 | } | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4907 | } |
4908 | m_errorMonitor->VerifyNotFound(); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4909 | vkDestroyCommandPool(m_device->device(), cmd_pool, NULL); |
4910 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { | ||||
4911 | vkDestroyFence(m_device->device(), fences[i], nullptr); | ||||
4912 | } | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 4913 | } |
4914 | // This is a positive test. No errors should be generated. | ||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4915 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
4916 | |||||
4917 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
4918 | "submitted on separate queues followed by a QueueWaitIdle."); | ||||
4919 | |||||
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 4920 | if ((m_device->queue_props.empty()) || |
4921 | (m_device->queue_props[0].queueCount < 2)) | ||||
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 4922 | return; |
4923 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4924 | m_errorMonitor->ExpectSuccess(); |
4925 | |||||
4926 | VkSemaphore semaphore; | ||||
4927 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
4928 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
4929 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
4930 | &semaphore); | ||||
4931 | |||||
4932 | VkCommandPool command_pool; | ||||
4933 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
4934 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
4935 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
4936 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
4937 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
4938 | &command_pool); | ||||
4939 | |||||
4940 | VkCommandBuffer command_buffer[2]; | ||||
4941 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
4942 | command_buffer_allocate_info.sType = | ||||
4943 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
4944 | command_buffer_allocate_info.commandPool = command_pool; | ||||
4945 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
4946 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
4947 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
4948 | command_buffer); | ||||
4949 | |||||
4950 | VkQueue queue = VK_NULL_HANDLE; | ||||
4951 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
4952 | 1, &queue); | ||||
4953 | |||||
4954 | { | ||||
4955 | VkCommandBufferBeginInfo begin_info{}; | ||||
4956 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
4957 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
4958 | |||||
4959 | vkCmdPipelineBarrier(command_buffer[0], | ||||
4960 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
4961 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
4962 | 0, nullptr, 0, nullptr); | ||||
4963 | |||||
4964 | VkViewport viewport{}; | ||||
4965 | viewport.maxDepth = 1.0f; | ||||
4966 | viewport.minDepth = 0.0f; | ||||
4967 | viewport.width = 512; | ||||
4968 | viewport.height = 512; | ||||
4969 | viewport.x = 0; | ||||
4970 | viewport.y = 0; | ||||
4971 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
4972 | vkEndCommandBuffer(command_buffer[0]); | ||||
4973 | } | ||||
4974 | { | ||||
4975 | VkCommandBufferBeginInfo begin_info{}; | ||||
4976 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
4977 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
4978 | |||||
4979 | VkViewport viewport{}; | ||||
4980 | viewport.maxDepth = 1.0f; | ||||
4981 | viewport.minDepth = 0.0f; | ||||
4982 | viewport.width = 512; | ||||
4983 | viewport.height = 512; | ||||
4984 | viewport.x = 0; | ||||
4985 | viewport.y = 0; | ||||
4986 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
4987 | vkEndCommandBuffer(command_buffer[1]); | ||||
4988 | } | ||||
4989 | { | ||||
4990 | VkSubmitInfo submit_info{}; | ||||
4991 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
4992 | submit_info.commandBufferCount = 1; | ||||
4993 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
4994 | submit_info.signalSemaphoreCount = 1; | ||||
4995 | submit_info.pSignalSemaphores = &semaphore; | ||||
4996 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
4997 | } | ||||
4998 | { | ||||
4999 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5000 | VkSubmitInfo submit_info{}; | ||||
5001 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5002 | submit_info.commandBufferCount = 1; | ||||
5003 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5004 | submit_info.waitSemaphoreCount = 1; | ||||
5005 | submit_info.pWaitSemaphores = &semaphore; | ||||
5006 | submit_info.pWaitDstStageMask = flags; | ||||
5007 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5008 | } | ||||
5009 | |||||
5010 | vkQueueWaitIdle(m_device->m_queue); | ||||
5011 | |||||
5012 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
5013 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5014 | &command_buffer[0]); | ||||
5015 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5016 | |||||
5017 | m_errorMonitor->VerifyNotFound(); | ||||
5018 | } | ||||
5019 | |||||
5020 | // This is a positive test. No errors should be generated. | ||||
5021 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { | ||||
5022 | |||||
5023 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
5024 | "submitted on separate queues, the second having a fence" | ||||
5025 | "followed by a QueueWaitIdle."); | ||||
5026 | |||||
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 5027 | if ((m_device->queue_props.empty()) || |
5028 | (m_device->queue_props[0].queueCount < 2)) | ||||
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 5029 | return; |
5030 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5031 | m_errorMonitor->ExpectSuccess(); |
5032 | |||||
5033 | VkFence fence; | ||||
5034 | VkFenceCreateInfo fence_create_info{}; | ||||
5035 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5036 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
5037 | |||||
5038 | VkSemaphore semaphore; | ||||
5039 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
5040 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
5041 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
5042 | &semaphore); | ||||
5043 | |||||
5044 | VkCommandPool command_pool; | ||||
5045 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5046 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5047 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5048 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5049 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5050 | &command_pool); | ||||
5051 | |||||
5052 | VkCommandBuffer command_buffer[2]; | ||||
5053 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5054 | command_buffer_allocate_info.sType = | ||||
5055 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5056 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5057 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5058 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5059 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5060 | command_buffer); | ||||
5061 | |||||
5062 | VkQueue queue = VK_NULL_HANDLE; | ||||
5063 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
5064 | 1, &queue); | ||||
5065 | |||||
5066 | { | ||||
5067 | VkCommandBufferBeginInfo begin_info{}; | ||||
5068 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5069 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5070 | |||||
5071 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5072 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5073 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5074 | 0, nullptr, 0, nullptr); | ||||
5075 | |||||
5076 | VkViewport viewport{}; | ||||
5077 | viewport.maxDepth = 1.0f; | ||||
5078 | viewport.minDepth = 0.0f; | ||||
5079 | viewport.width = 512; | ||||
5080 | viewport.height = 512; | ||||
5081 | viewport.x = 0; | ||||
5082 | viewport.y = 0; | ||||
5083 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5084 | vkEndCommandBuffer(command_buffer[0]); | ||||
5085 | } | ||||
5086 | { | ||||
5087 | VkCommandBufferBeginInfo begin_info{}; | ||||
5088 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5089 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5090 | |||||
5091 | VkViewport viewport{}; | ||||
5092 | viewport.maxDepth = 1.0f; | ||||
5093 | viewport.minDepth = 0.0f; | ||||
5094 | viewport.width = 512; | ||||
5095 | viewport.height = 512; | ||||
5096 | viewport.x = 0; | ||||
5097 | viewport.y = 0; | ||||
5098 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5099 | vkEndCommandBuffer(command_buffer[1]); | ||||
5100 | } | ||||
5101 | { | ||||
5102 | VkSubmitInfo submit_info{}; | ||||
5103 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5104 | submit_info.commandBufferCount = 1; | ||||
5105 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
5106 | submit_info.signalSemaphoreCount = 1; | ||||
5107 | submit_info.pSignalSemaphores = &semaphore; | ||||
5108 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5109 | } | ||||
5110 | { | ||||
5111 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5112 | VkSubmitInfo submit_info{}; | ||||
5113 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5114 | submit_info.commandBufferCount = 1; | ||||
5115 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5116 | submit_info.waitSemaphoreCount = 1; | ||||
5117 | submit_info.pWaitSemaphores = &semaphore; | ||||
5118 | submit_info.pWaitDstStageMask = flags; | ||||
5119 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
5120 | } | ||||
5121 | |||||
5122 | vkQueueWaitIdle(m_device->m_queue); | ||||
5123 | |||||
5124 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
5125 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
5126 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5127 | &command_buffer[0]); | ||||
5128 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5129 | |||||
5130 | m_errorMonitor->VerifyNotFound(); | ||||
5131 | } | ||||
5132 | |||||
5133 | // This is a positive test. No errors should be generated. | ||||
5134 | TEST_F(VkLayerTest, | ||||
5135 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { | ||||
5136 | |||||
5137 | TEST_DESCRIPTION( | ||||
5138 | "Two command buffers, each in a separate QueueSubmit call " | ||||
5139 | "submitted on separate queues, the second having a fence" | ||||
5140 | "followed by two consecutive WaitForFences calls on the same fence."); | ||||
5141 | |||||
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 5142 | if ((m_device->queue_props.empty()) || |
5143 | (m_device->queue_props[0].queueCount < 2)) | ||||
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 5144 | return; |
5145 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5146 | m_errorMonitor->ExpectSuccess(); |
5147 | |||||
5148 | VkFence fence; | ||||
5149 | VkFenceCreateInfo fence_create_info{}; | ||||
5150 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5151 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
5152 | |||||
5153 | VkSemaphore semaphore; | ||||
5154 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
5155 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
5156 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
5157 | &semaphore); | ||||
5158 | |||||
5159 | VkCommandPool command_pool; | ||||
5160 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5161 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5162 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5163 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5164 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5165 | &command_pool); | ||||
5166 | |||||
5167 | VkCommandBuffer command_buffer[2]; | ||||
5168 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5169 | command_buffer_allocate_info.sType = | ||||
5170 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5171 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5172 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5173 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5174 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5175 | command_buffer); | ||||
5176 | |||||
5177 | VkQueue queue = VK_NULL_HANDLE; | ||||
5178 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
5179 | 1, &queue); | ||||
5180 | |||||
5181 | { | ||||
5182 | VkCommandBufferBeginInfo begin_info{}; | ||||
5183 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5184 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5185 | |||||
5186 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5187 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5188 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5189 | 0, nullptr, 0, nullptr); | ||||
5190 | |||||
5191 | VkViewport viewport{}; | ||||
5192 | viewport.maxDepth = 1.0f; | ||||
5193 | viewport.minDepth = 0.0f; | ||||
5194 | viewport.width = 512; | ||||
5195 | viewport.height = 512; | ||||
5196 | viewport.x = 0; | ||||
5197 | viewport.y = 0; | ||||
5198 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5199 | vkEndCommandBuffer(command_buffer[0]); | ||||
5200 | } | ||||
5201 | { | ||||
5202 | VkCommandBufferBeginInfo begin_info{}; | ||||
5203 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5204 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5205 | |||||
5206 | VkViewport viewport{}; | ||||
5207 | viewport.maxDepth = 1.0f; | ||||
5208 | viewport.minDepth = 0.0f; | ||||
5209 | viewport.width = 512; | ||||
5210 | viewport.height = 512; | ||||
5211 | viewport.x = 0; | ||||
5212 | viewport.y = 0; | ||||
5213 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5214 | vkEndCommandBuffer(command_buffer[1]); | ||||
5215 | } | ||||
5216 | { | ||||
5217 | VkSubmitInfo submit_info{}; | ||||
5218 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5219 | submit_info.commandBufferCount = 1; | ||||
5220 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
5221 | submit_info.signalSemaphoreCount = 1; | ||||
5222 | submit_info.pSignalSemaphores = &semaphore; | ||||
5223 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5224 | } | ||||
5225 | { | ||||
5226 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5227 | VkSubmitInfo submit_info{}; | ||||
5228 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5229 | submit_info.commandBufferCount = 1; | ||||
5230 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5231 | submit_info.waitSemaphoreCount = 1; | ||||
5232 | submit_info.pWaitSemaphores = &semaphore; | ||||
5233 | submit_info.pWaitDstStageMask = flags; | ||||
5234 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
5235 | } | ||||
5236 | |||||
5237 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
5238 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
5239 | |||||
5240 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
5241 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
5242 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5243 | &command_buffer[0]); | ||||
5244 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5245 | |||||
5246 | m_errorMonitor->VerifyNotFound(); | ||||
5247 | } | ||||
5248 | |||||
Chris Forbes | 0f8126b | 2016-06-20 17:48:22 +1200 | [diff] [blame] | 5249 | #if 0 |
5250 | TEST_F(VkLayerTest, TwoQueuesEnsureCorrectRetirementWithWorkStolen) { | ||||
5251 | if ((m_device->queue_props.empty()) || | ||||
5252 | (m_device->queue_props[0].queueCount < 2)) { | ||||
5253 | printf("Test requires two queues, skipping\n"); | ||||
5254 | return; | ||||
5255 | } | ||||
5256 | |||||
5257 | VkResult err; | ||||
5258 | |||||
5259 | m_errorMonitor->ExpectSuccess(); | ||||
5260 | |||||
5261 | VkQueue q0 = m_device->m_queue; | ||||
5262 | VkQueue q1 = nullptr; | ||||
5263 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, 1, &q1); | ||||
5264 | ASSERT_NE(q1, nullptr); | ||||
5265 | |||||
5266 | // An (empty) command buffer. We must have work in the first submission -- | ||||
5267 | // the layer treats unfenced work differently from fenced work. | ||||
5268 | VkCommandPoolCreateInfo cpci = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, nullptr, 0, 0 }; | ||||
5269 | VkCommandPool pool; | ||||
5270 | err = vkCreateCommandPool(m_device->device(), &cpci, nullptr, &pool); | ||||
5271 | ASSERT_VK_SUCCESS(err); | ||||
5272 | VkCommandBufferAllocateInfo cbai = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, nullptr, | ||||
5273 | pool, VK_COMMAND_BUFFER_LEVEL_PRIMARY, 1 | ||||
5274 | }; | ||||
5275 | VkCommandBuffer cb; | ||||
5276 | err = vkAllocateCommandBuffers(m_device->device(), &cbai, &cb); | ||||
5277 | ASSERT_VK_SUCCESS(err); | ||||
5278 | VkCommandBufferBeginInfo cbbi = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, | ||||
5279 | 0, nullptr | ||||
5280 | }; | ||||
5281 | err = vkBeginCommandBuffer(cb, &cbbi); | ||||
5282 | ASSERT_VK_SUCCESS(err); | ||||
5283 | err = vkEndCommandBuffer(cb); | ||||
5284 | ASSERT_VK_SUCCESS(err); | ||||
5285 | |||||
5286 | // A semaphore | ||||
5287 | VkSemaphoreCreateInfo sci = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, nullptr, 0 }; | ||||
5288 | VkSemaphore s; | ||||
5289 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s); | ||||
5290 | ASSERT_VK_SUCCESS(err); | ||||
5291 | |||||
5292 | // First submission, to q0 | ||||
5293 | VkSubmitInfo s0 = { | ||||
5294 | VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, | ||||
5295 | 0, nullptr, nullptr, | ||||
5296 | 1, &cb, | ||||
5297 | 1, &s | ||||
5298 | }; | ||||
5299 | |||||
5300 | err = vkQueueSubmit(q0, 1, &s0, VK_NULL_HANDLE); | ||||
5301 | ASSERT_VK_SUCCESS(err); | ||||
5302 | |||||
5303 | // Second submission, to q1, waiting on s | ||||
5304 | VkFlags waitmask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; // doesn't really matter what this value is. | ||||
5305 | VkSubmitInfo s1 = { | ||||
5306 | VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, | ||||
5307 | 1, &s, &waitmask, | ||||
5308 | 0, nullptr, | ||||
5309 | 0, nullptr | ||||
5310 | }; | ||||
5311 | |||||
5312 | err = vkQueueSubmit(q1, 1, &s1, VK_NULL_HANDLE); | ||||
5313 | ASSERT_VK_SUCCESS(err); | ||||
5314 | |||||
5315 | // Wait for q0 idle | ||||
5316 | err = vkQueueWaitIdle(q0); | ||||
5317 | ASSERT_VK_SUCCESS(err); | ||||
5318 | |||||
5319 | // Command buffer should have been completed (it was on q0); reset the pool. | ||||
5320 | vkFreeCommandBuffers(m_device->device(), pool, 1, &cb); | ||||
5321 | |||||
5322 | m_errorMonitor->VerifyNotFound(); | ||||
5323 | |||||
5324 | // Force device completely idle and clean up resources | ||||
5325 | vkDeviceWaitIdle(m_device->device()); | ||||
5326 | vkDestroyCommandPool(m_device->device(), pool, nullptr); | ||||
5327 | vkDestroySemaphore(m_device->device(), s, nullptr); | ||||
5328 | } | ||||
5329 | #endif | ||||
5330 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5331 | // This is a positive test. No errors should be generated. |
5332 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { | ||||
5333 | |||||
5334 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
5335 | "submitted on separate queues, the second having a fence, " | ||||
5336 | "followed by a WaitForFences call."); | ||||
5337 | |||||
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 5338 | if ((m_device->queue_props.empty()) || |
5339 | (m_device->queue_props[0].queueCount < 2)) | ||||
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 5340 | return; |
5341 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5342 | m_errorMonitor->ExpectSuccess(); |
5343 | |||||
5344 | VkFence fence; | ||||
5345 | VkFenceCreateInfo fence_create_info{}; | ||||
5346 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5347 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
5348 | |||||
5349 | VkSemaphore semaphore; | ||||
5350 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
5351 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
5352 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
5353 | &semaphore); | ||||
5354 | |||||
5355 | VkCommandPool command_pool; | ||||
5356 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5357 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5358 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5359 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5360 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5361 | &command_pool); | ||||
5362 | |||||
5363 | VkCommandBuffer command_buffer[2]; | ||||
5364 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5365 | command_buffer_allocate_info.sType = | ||||
5366 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5367 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5368 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5369 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5370 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5371 | command_buffer); | ||||
5372 | |||||
5373 | VkQueue queue = VK_NULL_HANDLE; | ||||
5374 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
5375 | 1, &queue); | ||||
5376 | |||||
5377 | |||||
5378 | { | ||||
5379 | VkCommandBufferBeginInfo begin_info{}; | ||||
5380 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5381 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5382 | |||||
5383 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5384 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5385 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5386 | 0, nullptr, 0, nullptr); | ||||
5387 | |||||
5388 | VkViewport viewport{}; | ||||
5389 | viewport.maxDepth = 1.0f; | ||||
5390 | viewport.minDepth = 0.0f; | ||||
5391 | viewport.width = 512; | ||||
5392 | viewport.height = 512; | ||||
5393 | viewport.x = 0; | ||||
5394 | viewport.y = 0; | ||||
5395 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5396 | vkEndCommandBuffer(command_buffer[0]); | ||||
5397 | } | ||||
5398 | { | ||||
5399 | VkCommandBufferBeginInfo begin_info{}; | ||||
5400 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5401 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5402 | |||||
5403 | VkViewport viewport{}; | ||||
5404 | viewport.maxDepth = 1.0f; | ||||
5405 | viewport.minDepth = 0.0f; | ||||
5406 | viewport.width = 512; | ||||
5407 | viewport.height = 512; | ||||
5408 | viewport.x = 0; | ||||
5409 | viewport.y = 0; | ||||
5410 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5411 | vkEndCommandBuffer(command_buffer[1]); | ||||
5412 | } | ||||
5413 | { | ||||
5414 | VkSubmitInfo submit_info{}; | ||||
5415 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5416 | submit_info.commandBufferCount = 1; | ||||
5417 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
5418 | submit_info.signalSemaphoreCount = 1; | ||||
5419 | submit_info.pSignalSemaphores = &semaphore; | ||||
5420 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5421 | } | ||||
5422 | { | ||||
5423 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5424 | VkSubmitInfo submit_info{}; | ||||
5425 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5426 | submit_info.commandBufferCount = 1; | ||||
5427 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5428 | submit_info.waitSemaphoreCount = 1; | ||||
5429 | submit_info.pWaitSemaphores = &semaphore; | ||||
5430 | submit_info.pWaitDstStageMask = flags; | ||||
5431 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
5432 | } | ||||
5433 | |||||
5434 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
5435 | |||||
5436 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
5437 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
5438 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5439 | &command_buffer[0]); | ||||
5440 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5441 | |||||
5442 | m_errorMonitor->VerifyNotFound(); | ||||
5443 | } | ||||
5444 | |||||
5445 | // This is a positive test. No errors should be generated. | ||||
5446 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { | ||||
5447 | |||||
5448 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
5449 | "on the same queue, sharing a signal/wait semaphore, the " | ||||
5450 | "second having a fence, " | ||||
5451 | "followed by a WaitForFences call."); | ||||
5452 | |||||
5453 | m_errorMonitor->ExpectSuccess(); | ||||
5454 | |||||
5455 | VkFence fence; | ||||
5456 | VkFenceCreateInfo fence_create_info{}; | ||||
5457 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5458 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
5459 | |||||
5460 | VkSemaphore semaphore; | ||||
5461 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
5462 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
5463 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
5464 | &semaphore); | ||||
5465 | |||||
5466 | VkCommandPool command_pool; | ||||
5467 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5468 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5469 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5470 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5471 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5472 | &command_pool); | ||||
5473 | |||||
5474 | VkCommandBuffer command_buffer[2]; | ||||
5475 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5476 | command_buffer_allocate_info.sType = | ||||
5477 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5478 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5479 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5480 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5481 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5482 | command_buffer); | ||||
5483 | |||||
5484 | { | ||||
5485 | VkCommandBufferBeginInfo begin_info{}; | ||||
5486 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5487 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5488 | |||||
5489 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5490 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5491 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5492 | 0, nullptr, 0, nullptr); | ||||
5493 | |||||
5494 | VkViewport viewport{}; | ||||
5495 | viewport.maxDepth = 1.0f; | ||||
5496 | viewport.minDepth = 0.0f; | ||||
5497 | viewport.width = 512; | ||||
5498 | viewport.height = 512; | ||||
5499 | viewport.x = 0; | ||||
5500 | viewport.y = 0; | ||||
5501 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5502 | vkEndCommandBuffer(command_buffer[0]); | ||||
5503 | } | ||||
5504 | { | ||||
5505 | VkCommandBufferBeginInfo begin_info{}; | ||||
5506 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5507 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5508 | |||||
5509 | VkViewport viewport{}; | ||||
5510 | viewport.maxDepth = 1.0f; | ||||
5511 | viewport.minDepth = 0.0f; | ||||
5512 | viewport.width = 512; | ||||
5513 | viewport.height = 512; | ||||
5514 | viewport.x = 0; | ||||
5515 | viewport.y = 0; | ||||
5516 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5517 | vkEndCommandBuffer(command_buffer[1]); | ||||
5518 | } | ||||
5519 | { | ||||
5520 | VkSubmitInfo submit_info{}; | ||||
5521 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5522 | submit_info.commandBufferCount = 1; | ||||
5523 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
5524 | submit_info.signalSemaphoreCount = 1; | ||||
5525 | submit_info.pSignalSemaphores = &semaphore; | ||||
5526 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5527 | } | ||||
5528 | { | ||||
5529 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5530 | VkSubmitInfo submit_info{}; | ||||
5531 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5532 | submit_info.commandBufferCount = 1; | ||||
5533 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5534 | submit_info.waitSemaphoreCount = 1; | ||||
5535 | submit_info.pWaitSemaphores = &semaphore; | ||||
5536 | submit_info.pWaitDstStageMask = flags; | ||||
5537 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
5538 | } | ||||
5539 | |||||
5540 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
5541 | |||||
5542 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
5543 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
5544 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5545 | &command_buffer[0]); | ||||
5546 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5547 | |||||
5548 | m_errorMonitor->VerifyNotFound(); | ||||
5549 | } | ||||
5550 | |||||
5551 | // This is a positive test. No errors should be generated. | ||||
5552 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { | ||||
5553 | |||||
5554 | TEST_DESCRIPTION( | ||||
5555 | "Two command buffers, each in a separate QueueSubmit call " | ||||
5556 | "on the same queue, no fences, followed by a third QueueSubmit with NO " | ||||
5557 | "SubmitInfos but with a fence, followed by a WaitForFences call."); | ||||
5558 | |||||
5559 | m_errorMonitor->ExpectSuccess(); | ||||
5560 | |||||
5561 | VkFence fence; | ||||
5562 | VkFenceCreateInfo fence_create_info{}; | ||||
5563 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5564 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
5565 | |||||
5566 | VkCommandPool command_pool; | ||||
5567 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5568 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5569 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5570 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5571 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5572 | &command_pool); | ||||
5573 | |||||
5574 | VkCommandBuffer command_buffer[2]; | ||||
5575 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5576 | command_buffer_allocate_info.sType = | ||||
5577 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5578 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5579 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5580 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5581 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5582 | command_buffer); | ||||
5583 | |||||
5584 | { | ||||
5585 | VkCommandBufferBeginInfo begin_info{}; | ||||
5586 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5587 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5588 | |||||
5589 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5590 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5591 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5592 | 0, nullptr, 0, nullptr); | ||||
5593 | |||||
5594 | VkViewport viewport{}; | ||||
5595 | viewport.maxDepth = 1.0f; | ||||
5596 | viewport.minDepth = 0.0f; | ||||
5597 | viewport.width = 512; | ||||
5598 | viewport.height = 512; | ||||
5599 | viewport.x = 0; | ||||
5600 | viewport.y = 0; | ||||
5601 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5602 | vkEndCommandBuffer(command_buffer[0]); | ||||
5603 | } | ||||
5604 | { | ||||
5605 | VkCommandBufferBeginInfo begin_info{}; | ||||
5606 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5607 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5608 | |||||
5609 | VkViewport viewport{}; | ||||
5610 | viewport.maxDepth = 1.0f; | ||||
5611 | viewport.minDepth = 0.0f; | ||||
5612 | viewport.width = 512; | ||||
5613 | viewport.height = 512; | ||||
5614 | viewport.x = 0; | ||||
5615 | viewport.y = 0; | ||||
5616 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5617 | vkEndCommandBuffer(command_buffer[1]); | ||||
5618 | } | ||||
5619 | { | ||||
5620 | VkSubmitInfo submit_info{}; | ||||
5621 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5622 | submit_info.commandBufferCount = 1; | ||||
5623 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
5624 | submit_info.signalSemaphoreCount = 0; | ||||
5625 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; | ||||
5626 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5627 | } | ||||
5628 | { | ||||
5629 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5630 | VkSubmitInfo submit_info{}; | ||||
5631 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5632 | submit_info.commandBufferCount = 1; | ||||
5633 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5634 | submit_info.waitSemaphoreCount = 0; | ||||
5635 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; | ||||
5636 | submit_info.pWaitDstStageMask = flags; | ||||
5637 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5638 | } | ||||
5639 | |||||
5640 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); | ||||
5641 | |||||
Mike Stroyan | cd1c3e5 | 2016-06-21 09:20:01 -0600 | [diff] [blame] | 5642 | VkResult err = |
5643 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
5644 | ASSERT_VK_SUCCESS(err); | ||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5645 | |
5646 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
5647 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5648 | &command_buffer[0]); | ||||
5649 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5650 | |||||
5651 | m_errorMonitor->VerifyNotFound(); | ||||
5652 | } | ||||
5653 | |||||
5654 | // This is a positive test. No errors should be generated. | ||||
5655 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { | ||||
5656 | |||||
5657 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
5658 | "on the same queue, the second having a fence, followed " | ||||
5659 | "by a WaitForFences call."); | ||||
5660 | |||||
5661 | m_errorMonitor->ExpectSuccess(); | ||||
5662 | |||||
5663 | VkFence fence; | ||||
5664 | VkFenceCreateInfo fence_create_info{}; | ||||
5665 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5666 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
5667 | |||||
5668 | VkCommandPool command_pool; | ||||
5669 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5670 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5671 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5672 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5673 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5674 | &command_pool); | ||||
5675 | |||||
5676 | VkCommandBuffer command_buffer[2]; | ||||
5677 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5678 | command_buffer_allocate_info.sType = | ||||
5679 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5680 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5681 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5682 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5683 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5684 | command_buffer); | ||||
5685 | |||||
5686 | { | ||||
5687 | VkCommandBufferBeginInfo begin_info{}; | ||||
5688 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5689 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5690 | |||||
5691 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5692 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5693 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5694 | 0, nullptr, 0, nullptr); | ||||
5695 | |||||
5696 | VkViewport viewport{}; | ||||
5697 | viewport.maxDepth = 1.0f; | ||||
5698 | viewport.minDepth = 0.0f; | ||||
5699 | viewport.width = 512; | ||||
5700 | viewport.height = 512; | ||||
5701 | viewport.x = 0; | ||||
5702 | viewport.y = 0; | ||||
5703 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5704 | vkEndCommandBuffer(command_buffer[0]); | ||||
5705 | } | ||||
5706 | { | ||||
5707 | VkCommandBufferBeginInfo begin_info{}; | ||||
5708 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5709 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5710 | |||||
5711 | VkViewport viewport{}; | ||||
5712 | viewport.maxDepth = 1.0f; | ||||
5713 | viewport.minDepth = 0.0f; | ||||
5714 | viewport.width = 512; | ||||
5715 | viewport.height = 512; | ||||
5716 | viewport.x = 0; | ||||
5717 | viewport.y = 0; | ||||
5718 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5719 | vkEndCommandBuffer(command_buffer[1]); | ||||
5720 | } | ||||
5721 | { | ||||
5722 | VkSubmitInfo submit_info{}; | ||||
5723 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5724 | submit_info.commandBufferCount = 1; | ||||
5725 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
5726 | submit_info.signalSemaphoreCount = 0; | ||||
5727 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; | ||||
5728 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5729 | } | ||||
5730 | { | ||||
5731 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5732 | VkSubmitInfo submit_info{}; | ||||
5733 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5734 | submit_info.commandBufferCount = 1; | ||||
5735 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5736 | submit_info.waitSemaphoreCount = 0; | ||||
5737 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; | ||||
5738 | submit_info.pWaitDstStageMask = flags; | ||||
5739 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
5740 | } | ||||
5741 | |||||
5742 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
5743 | |||||
5744 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
5745 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5746 | &command_buffer[0]); | ||||
5747 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5748 | |||||
5749 | m_errorMonitor->VerifyNotFound(); | ||||
5750 | } | ||||
5751 | |||||
5752 | // This is a positive test. No errors should be generated. | ||||
5753 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { | ||||
5754 | |||||
5755 | TEST_DESCRIPTION( | ||||
5756 | "Two command buffers each in a separate SubmitInfo sent in a single " | ||||
5757 | "QueueSubmit call followed by a WaitForFences call."); | ||||
5758 | |||||
5759 | m_errorMonitor->ExpectSuccess(); | ||||
5760 | |||||
5761 | VkFence fence; | ||||
5762 | VkFenceCreateInfo fence_create_info{}; | ||||
5763 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5764 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
5765 | |||||
5766 | VkSemaphore semaphore; | ||||
5767 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
5768 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
5769 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
5770 | &semaphore); | ||||
5771 | |||||
5772 | VkCommandPool command_pool; | ||||
5773 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5774 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5775 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5776 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5777 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5778 | &command_pool); | ||||
5779 | |||||
5780 | VkCommandBuffer command_buffer[2]; | ||||
5781 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5782 | command_buffer_allocate_info.sType = | ||||
5783 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5784 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5785 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5786 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5787 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5788 | command_buffer); | ||||
5789 | |||||
5790 | { | ||||
5791 | VkCommandBufferBeginInfo begin_info{}; | ||||
5792 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5793 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5794 | |||||
5795 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5796 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5797 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5798 | 0, nullptr, 0, nullptr); | ||||
5799 | |||||
5800 | VkViewport viewport{}; | ||||
5801 | viewport.maxDepth = 1.0f; | ||||
5802 | viewport.minDepth = 0.0f; | ||||
5803 | viewport.width = 512; | ||||
5804 | viewport.height = 512; | ||||
5805 | viewport.x = 0; | ||||
5806 | viewport.y = 0; | ||||
5807 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5808 | vkEndCommandBuffer(command_buffer[0]); | ||||
5809 | } | ||||
5810 | { | ||||
5811 | VkCommandBufferBeginInfo begin_info{}; | ||||
5812 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5813 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5814 | |||||
5815 | VkViewport viewport{}; | ||||
5816 | viewport.maxDepth = 1.0f; | ||||
5817 | viewport.minDepth = 0.0f; | ||||
5818 | viewport.width = 512; | ||||
5819 | viewport.height = 512; | ||||
5820 | viewport.x = 0; | ||||
5821 | viewport.y = 0; | ||||
5822 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5823 | vkEndCommandBuffer(command_buffer[1]); | ||||
5824 | } | ||||
5825 | { | ||||
5826 | VkSubmitInfo submit_info[2]; | ||||
5827 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5828 | |||||
5829 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5830 | submit_info[0].pNext = NULL; | ||||
5831 | submit_info[0].commandBufferCount = 1; | ||||
5832 | submit_info[0].pCommandBuffers = &command_buffer[0]; | ||||
5833 | submit_info[0].signalSemaphoreCount = 1; | ||||
5834 | submit_info[0].pSignalSemaphores = &semaphore; | ||||
5835 | submit_info[0].waitSemaphoreCount = 0; | ||||
5836 | submit_info[0].pWaitSemaphores = NULL; | ||||
5837 | submit_info[0].pWaitDstStageMask = 0; | ||||
5838 | |||||
5839 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5840 | submit_info[1].pNext = NULL; | ||||
5841 | submit_info[1].commandBufferCount = 1; | ||||
5842 | submit_info[1].pCommandBuffers = &command_buffer[1]; | ||||
5843 | submit_info[1].waitSemaphoreCount = 1; | ||||
5844 | submit_info[1].pWaitSemaphores = &semaphore; | ||||
5845 | submit_info[1].pWaitDstStageMask = flags; | ||||
5846 | submit_info[1].signalSemaphoreCount = 0; | ||||
5847 | submit_info[1].pSignalSemaphores = NULL; | ||||
5848 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); | ||||
5849 | } | ||||
5850 | |||||
5851 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
5852 | |||||
5853 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
5854 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5855 | &command_buffer[0]); | ||||
5856 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5857 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5858 | |
5859 | m_errorMonitor->VerifyNotFound(); | ||||
5860 | } | ||||
5861 | |||||
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5862 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5863 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5864 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
5865 | "state is required but not correctly bound."); | ||||
5866 | |||||
5867 | // Dynamic depth bias | ||||
5868 | m_errorMonitor->SetDesiredFailureMsg( | ||||
5869 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
5870 | "Dynamic depth bias state not set for this command buffer"); | ||||
5871 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, | ||||
5872 | BsoFailDepthBias); | ||||
5873 | m_errorMonitor->VerifyFound(); | ||||
5874 | } | ||||
5875 | |||||
5876 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { | ||||
5877 | TEST_DESCRIPTION( | ||||
5878 | "Run a simple draw calls to validate failure when Line Width dynamic " | ||||
5879 | "state is required but not correctly bound."); | ||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5880 | |
5881 | // Dynamic line width | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5882 | m_errorMonitor->SetDesiredFailureMsg( |
5883 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5884 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5885 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
5886 | BsoFailLineWidth); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5887 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5888 | } |
5889 | |||||
5890 | TEST_F(VkLayerTest, DynamicViewportNotBound) { | ||||
5891 | TEST_DESCRIPTION( | ||||
5892 | "Run a simple draw calls to validate failure when Viewport dynamic " | ||||
5893 | "state is required but not correctly bound."); | ||||
5894 | |||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5895 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5896 | m_errorMonitor->SetDesiredFailureMsg( |
5897 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5898 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5899 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
5900 | BsoFailViewport); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5901 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5902 | } |
5903 | |||||
5904 | TEST_F(VkLayerTest, DynamicScissorNotBound) { | ||||
5905 | TEST_DESCRIPTION( | ||||
5906 | "Run a simple draw calls to validate failure when Scissor dynamic " | ||||
5907 | "state is required but not correctly bound."); | ||||
5908 | |||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5909 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5910 | m_errorMonitor->SetDesiredFailureMsg( |
5911 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5912 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5913 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
5914 | BsoFailScissor); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5915 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5916 | } |
5917 | |||||
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 5918 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5919 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 5920 | "Run a simple draw calls to validate failure when Blend Constants " |
5921 | "dynamic state is required but not correctly bound."); | ||||
5922 | // Dynamic blend constant state | ||||
5923 | m_errorMonitor->SetDesiredFailureMsg( | ||||
5924 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
5925 | "Dynamic blend constants state not set for this command buffer"); | ||||
5926 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, | ||||
5927 | BsoFailBlend); | ||||
5928 | m_errorMonitor->VerifyFound(); | ||||
5929 | } | ||||
5930 | |||||
5931 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { | ||||
5932 | TEST_DESCRIPTION( | ||||
5933 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " | ||||
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5934 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 5935 | if (!m_device->phy().features().depthBounds) { |
5936 | printf("Device does not support depthBounds test; skipped.\n"); | ||||
5937 | return; | ||||
5938 | } | ||||
5939 | // Dynamic depth bounds | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5940 | m_errorMonitor->SetDesiredFailureMsg( |
5941 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5942 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5943 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
5944 | BsoFailDepthBounds); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5945 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5946 | } |
5947 | |||||
5948 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { | ||||
5949 | TEST_DESCRIPTION( | ||||
5950 | "Run a simple draw calls to validate failure when Stencil Read dynamic " | ||||
5951 | "state is required but not correctly bound."); | ||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5952 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5953 | m_errorMonitor->SetDesiredFailureMsg( |
5954 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5955 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5956 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
5957 | BsoFailStencilReadMask); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5958 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5959 | } |
5960 | |||||
5961 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { | ||||
5962 | TEST_DESCRIPTION( | ||||
5963 | "Run a simple draw calls to validate failure when Stencil Write dynamic" | ||||
5964 | " state is required but not correctly bound."); | ||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5965 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5966 | m_errorMonitor->SetDesiredFailureMsg( |
5967 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5968 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5969 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
5970 | BsoFailStencilWriteMask); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5971 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 5972 | } |
5973 | |||||
5974 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { | ||||
5975 | TEST_DESCRIPTION( | ||||
5976 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " | ||||
5977 | "state is required but not correctly bound."); | ||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 5978 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5979 | m_errorMonitor->SetDesiredFailureMsg( |
5980 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5981 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5982 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
5983 | BsoFailStencilReference); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5984 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 5985 | } |
5986 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5987 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5988 | m_errorMonitor->SetDesiredFailureMsg( |
5989 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
5990 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " | ||||
5991 | "been submitted"); | ||||
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5992 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5993 | ASSERT_NO_FATAL_FAILURE(InitState()); |
5994 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
5995 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
5996 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5997 | // We luck out b/c by default the framework creates CB w/ the |
5998 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set | ||||
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 5999 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6000 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
6001 | m_stencil_clear_color, NULL); | ||||
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6002 | EndCommandBuffer(); |
6003 | |||||
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6004 | // Bypass framework since it does the waits automatically |
6005 | VkResult err = VK_SUCCESS; | ||||
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 6006 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 6007 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
6008 | submit_info.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6009 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 6010 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 6011 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6012 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6013 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6014 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 6015 | submit_info.pSignalSemaphores = NULL; |
6016 | |||||
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 6017 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6018 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6019 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6020 | // Cause validation error by re-submitting cmd buffer that should only be |
6021 | // submitted once | ||||
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 6022 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6023 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6024 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6025 | } |
6026 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6027 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6028 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6029 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6030 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6031 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6032 | "Unable to allocate 1 descriptors of " |
6033 | "type " | ||||
6034 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6035 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6036 | ASSERT_NO_FATAL_FAILURE(InitState()); |
6037 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6038 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6039 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
6040 | // descriptor from it | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6041 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6042 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
6043 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6044 | |
6045 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6046 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
6047 | ds_pool_ci.pNext = NULL; | ||||
6048 | ds_pool_ci.flags = 0; | ||||
6049 | ds_pool_ci.maxSets = 1; | ||||
6050 | ds_pool_ci.poolSizeCount = 1; | ||||
6051 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6052 | |
6053 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6054 | err = |
6055 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6056 | ASSERT_VK_SUCCESS(err); |
6057 | |||||
6058 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6059 | dsl_binding.binding = 0; |
6060 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6061 | dsl_binding.descriptorCount = 1; | ||||
6062 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
6063 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6064 | |
6065 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6066 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
6067 | ds_layout_ci.pNext = NULL; | ||||
6068 | ds_layout_ci.bindingCount = 1; | ||||
6069 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6070 | |
6071 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6072 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
6073 | &ds_layout); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6074 | ASSERT_VK_SUCCESS(err); |
6075 | |||||
6076 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6077 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6078 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6079 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6080 | alloc_info.descriptorPool = ds_pool; |
6081 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6082 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
6083 | &descriptorSet); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6084 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6085 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6086 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6087 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
6088 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6089 | } |
6090 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6091 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
6092 | VkResult err; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6093 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6094 | m_errorMonitor->SetDesiredFailureMsg( |
6095 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6096 | "It is invalid to call vkFreeDescriptorSets() with a pool created " | ||||
6097 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6098 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6099 | ASSERT_NO_FATAL_FAILURE(InitState()); |
6100 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6101 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6102 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6103 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
6104 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6105 | |
6106 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6107 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
6108 | ds_pool_ci.pNext = NULL; | ||||
6109 | ds_pool_ci.maxSets = 1; | ||||
6110 | ds_pool_ci.poolSizeCount = 1; | ||||
6111 | ds_pool_ci.flags = 0; | ||||
6112 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means | ||||
6113 | // app can only call vkResetDescriptorPool on this pool.; | ||||
6114 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6115 | |
6116 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6117 | err = |
6118 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6119 | ASSERT_VK_SUCCESS(err); |
6120 | |||||
6121 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6122 | dsl_binding.binding = 0; |
6123 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6124 | dsl_binding.descriptorCount = 1; | ||||
6125 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
6126 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6127 | |
6128 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6129 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
6130 | ds_layout_ci.pNext = NULL; | ||||
6131 | ds_layout_ci.bindingCount = 1; | ||||
6132 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6133 | |
6134 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6135 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
6136 | &ds_layout); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6137 | ASSERT_VK_SUCCESS(err); |
6138 | |||||
6139 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6140 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6141 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6142 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6143 | alloc_info.descriptorPool = ds_pool; |
6144 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6145 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
6146 | &descriptorSet); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6147 | ASSERT_VK_SUCCESS(err); |
6148 | |||||
6149 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6150 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6151 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6152 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
6153 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6154 | } |
6155 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6156 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6157 | // Attempt to clear Descriptor Pool with bad object. |
6158 | // ObjectTracker should catch this. | ||||
6159 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6160 | "Invalid VkDescriptorPool Object 0xbaad6001"); | ||||
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 6161 | uint64_t fake_pool_handle = 0xbaad6001; |
6162 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); | ||||
6163 | vkResetDescriptorPool(device(), bad_pool, 0); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6164 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6165 | } |
6166 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6167 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6168 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
6169 | // ObjectTracker should catch this. | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6170 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6171 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 6172 | |
6173 | uint64_t fake_set_handle = 0xbaad6001; | ||||
6174 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6175 | VkResult err; |
6176 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6177 | "Invalid VkDescriptorSet Object 0xbaad6001"); | ||||
6178 | |||||
6179 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6180 | |||||
6181 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; | ||||
6182 | layout_bindings[0].binding = 0; | ||||
6183 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6184 | layout_bindings[0].descriptorCount = 1; | ||||
6185 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; | ||||
6186 | layout_bindings[0].pImmutableSamplers = NULL; | ||||
6187 | |||||
6188 | VkDescriptorSetLayout descriptor_set_layout; | ||||
6189 | VkDescriptorSetLayoutCreateInfo dslci = {}; | ||||
6190 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
6191 | dslci.pNext = NULL; | ||||
6192 | dslci.bindingCount = 1; | ||||
6193 | dslci.pBindings = layout_bindings; | ||||
6194 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); | ||||
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 6195 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6196 | |
6197 | VkPipelineLayout pipeline_layout; | ||||
6198 | VkPipelineLayoutCreateInfo plci = {}; | ||||
6199 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
6200 | plci.pNext = NULL; | ||||
6201 | plci.setLayoutCount = 1; | ||||
6202 | plci.pSetLayouts = &descriptor_set_layout; | ||||
6203 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); | ||||
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 6204 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6205 | |
6206 | BeginCommandBuffer(); | ||||
6207 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 6208 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6209 | m_errorMonitor->VerifyFound(); |
6210 | EndCommandBuffer(); | ||||
6211 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); | ||||
6212 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6213 | } |
6214 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6215 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6216 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
6217 | // ObjectTracker should catch this. | ||||
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 6218 | uint64_t fake_layout_handle = 0xbaad6001; |
6219 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6220 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
6221 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); | ||||
6222 | |||||
6223 | VkPipelineLayout pipeline_layout; | ||||
6224 | VkPipelineLayoutCreateInfo plci = {}; | ||||
6225 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
6226 | plci.pNext = NULL; | ||||
6227 | plci.setLayoutCount = 1; | ||||
6228 | plci.pSetLayouts = &bad_layout; | ||||
6229 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); | ||||
6230 | |||||
6231 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6232 | } |
6233 | |||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6234 | TEST_F(VkLayerTest, WriteDescriptorSetIntegrityCheck) { |
6235 | TEST_DESCRIPTION("This test verifies some requirements of chapter 13.2.3 of the Vulkan Spec " | ||||
6236 | "1) A uniform buffer update must have a valid buffer index." | ||||
6237 | "2) When using an array of descriptors in a single WriteDescriptor," | ||||
6238 | " the descriptor types and stageflags must all be the same." | ||||
6239 | "3) Immutable Sampler state must match across descriptors"); | ||||
6240 | |||||
6241 | const char *invalid_BufferInfo_ErrorMessage = | ||||
6242 | "vkUpdateDescriptorSets: if pDescriptorWrites[0].descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, " | ||||
6243 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or " | ||||
6244 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pDescriptorWrites[0].pBufferInfo must not be NULL"; | ||||
6245 | const char *stateFlag_ErrorMessage = | ||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6246 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6247 | const char *immutable_ErrorMessage = |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6248 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6249 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6250 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, invalid_BufferInfo_ErrorMessage); |
6251 | |||||
6252 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6253 | VkDescriptorPoolSize ds_type_count[4] = {}; | ||||
6254 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6255 | ds_type_count[0].descriptorCount = 1; | ||||
6256 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; | ||||
6257 | ds_type_count[1].descriptorCount = 1; | ||||
6258 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; | ||||
6259 | ds_type_count[2].descriptorCount = 1; | ||||
6260 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; | ||||
6261 | ds_type_count[3].descriptorCount = 1; | ||||
6262 | |||||
6263 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
6264 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
6265 | ds_pool_ci.maxSets = 1; | ||||
6266 | ds_pool_ci.poolSizeCount = sizeof(ds_type_count) / sizeof(VkDescriptorPoolSize); | ||||
6267 | ds_pool_ci.pPoolSizes = ds_type_count; | ||||
6268 | |||||
6269 | VkDescriptorPool ds_pool; | ||||
6270 | VkResult err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
6271 | ASSERT_VK_SUCCESS(err); | ||||
6272 | |||||
Mark Mueller | b989672 | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6273 | VkDescriptorSetLayoutBinding layout_binding[3] = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6274 | layout_binding[0].binding = 0; |
6275 | layout_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6276 | layout_binding[0].descriptorCount = 1; | ||||
6277 | layout_binding[0].stageFlags = VK_SHADER_STAGE_ALL; | ||||
6278 | layout_binding[0].pImmutableSamplers = NULL; | ||||
6279 | |||||
6280 | layout_binding[1].binding = 1; | ||||
6281 | layout_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
6282 | layout_binding[1].descriptorCount = 1; | ||||
6283 | layout_binding[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; | ||||
6284 | layout_binding[1].pImmutableSamplers = NULL; | ||||
6285 | |||||
6286 | VkSamplerCreateInfo sampler_ci = {}; | ||||
6287 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; | ||||
6288 | sampler_ci.pNext = NULL; | ||||
6289 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
6290 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
6291 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
6292 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
6293 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
6294 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
6295 | sampler_ci.mipLodBias = 1.0; | ||||
6296 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
6297 | sampler_ci.maxAnisotropy = 1; | ||||
6298 | sampler_ci.compareEnable = VK_FALSE; | ||||
6299 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
6300 | sampler_ci.minLod = 1.0; | ||||
6301 | sampler_ci.maxLod = 1.0; | ||||
6302 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
6303 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
6304 | VkSampler sampler; | ||||
6305 | |||||
6306 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); | ||||
6307 | ASSERT_VK_SUCCESS(err); | ||||
6308 | |||||
6309 | layout_binding[2].binding = 2; | ||||
6310 | layout_binding[2].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
6311 | layout_binding[2].descriptorCount = 1; | ||||
6312 | layout_binding[2].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; | ||||
6313 | layout_binding[2].pImmutableSamplers = static_cast<VkSampler *>(&sampler); | ||||
6314 | |||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6315 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
6316 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
6317 | ds_layout_ci.bindingCount = sizeof(layout_binding) / sizeof(VkDescriptorSetLayoutBinding); | ||||
6318 | ds_layout_ci.pBindings = layout_binding; | ||||
6319 | VkDescriptorSetLayout ds_layout; | ||||
6320 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); | ||||
6321 | ASSERT_VK_SUCCESS(err); | ||||
6322 | |||||
6323 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
6324 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
6325 | alloc_info.descriptorSetCount = 1; | ||||
6326 | alloc_info.descriptorPool = ds_pool; | ||||
6327 | alloc_info.pSetLayouts = &ds_layout; | ||||
6328 | VkDescriptorSet descriptorSet; | ||||
6329 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); | ||||
6330 | ASSERT_VK_SUCCESS(err); | ||||
6331 | |||||
6332 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
6333 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
6334 | pipeline_layout_ci.pNext = NULL; | ||||
6335 | pipeline_layout_ci.setLayoutCount = 1; | ||||
6336 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
6337 | |||||
6338 | VkPipelineLayout pipeline_layout; | ||||
6339 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); | ||||
6340 | ASSERT_VK_SUCCESS(err); | ||||
6341 | |||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6342 | VkWriteDescriptorSet descriptor_write = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6343 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
6344 | descriptor_write.dstSet = descriptorSet; | ||||
6345 | descriptor_write.dstBinding = 0; | ||||
6346 | descriptor_write.descriptorCount = 1; | ||||
6347 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6348 | |||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6349 | // 1) The uniform buffer is intentionally invalid here |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6350 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
6351 | m_errorMonitor->VerifyFound(); | ||||
6352 | |||||
6353 | // Create a buffer to update the descriptor with | ||||
6354 | uint32_t qfi = 0; | ||||
6355 | VkBufferCreateInfo buffCI = {}; | ||||
6356 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
6357 | buffCI.size = 1024; | ||||
6358 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
6359 | buffCI.queueFamilyIndexCount = 1; | ||||
6360 | buffCI.pQueueFamilyIndices = &qfi; | ||||
6361 | |||||
6362 | VkBuffer dyub; | ||||
6363 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); | ||||
6364 | ASSERT_VK_SUCCESS(err); | ||||
6365 | VkDescriptorBufferInfo buffInfo = {}; | ||||
6366 | buffInfo.buffer = dyub; | ||||
6367 | buffInfo.offset = 0; | ||||
6368 | buffInfo.range = 1024; | ||||
6369 | |||||
6370 | descriptor_write.pBufferInfo = &buffInfo; | ||||
6371 | descriptor_write.descriptorCount = 2; | ||||
6372 | |||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6373 | // 2) The stateFlags don't match between the first and second descriptor |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6374 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, stateFlag_ErrorMessage); |
6375 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
6376 | m_errorMonitor->VerifyFound(); | ||||
6377 | |||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6378 | // 3) The second descriptor has a null_ptr pImmutableSamplers and |
6379 | // the third descriptor contains an immutable sampler | ||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6380 | descriptor_write.dstBinding = 1; |
6381 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6382 | |
6383 | |||||
6384 | // Make pImageInfo index non-null to avoid complaints of it missing | ||||
6385 | VkDescriptorImageInfo imageInfo = {}; | ||||
6386 | imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
6387 | descriptor_write.pImageInfo = &imageInfo; | ||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6388 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, immutable_ErrorMessage); |
6389 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
6390 | m_errorMonitor->VerifyFound(); | ||||
6391 | |||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6392 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
6393 | vkDestroySampler(m_device->device(), sampler, NULL); | ||||
6394 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
6395 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
6396 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
6397 | } | ||||
6398 | |||||
Tobin Ehlis | 0283c4d | 2016-06-28 17:57:07 -0600 | [diff] [blame] | 6399 | TEST_F(VkLayerTest, InvalidCmdBufferBufferDestroyed) { |
6400 | TEST_DESCRIPTION("Attempt to draw with a command buffer that is invalid " | ||||
6401 | "due to a buffer dependency being destroyed."); | ||||
6402 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6403 | |||||
6404 | VkImageObj image(m_device); | ||||
6405 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
6406 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | ||||
6407 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
6408 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
6409 | ASSERT_TRUE(image.initialized()); | ||||
6410 | |||||
6411 | VkBuffer buffer; | ||||
6412 | VkDeviceMemory mem; | ||||
6413 | VkMemoryRequirements mem_reqs; | ||||
6414 | |||||
6415 | VkBufferCreateInfo buf_info = {}; | ||||
6416 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
6417 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
6418 | buf_info.size = 256; | ||||
6419 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
6420 | VkResult err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); | ||||
6421 | ASSERT_VK_SUCCESS(err); | ||||
6422 | |||||
6423 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); | ||||
6424 | |||||
6425 | VkMemoryAllocateInfo alloc_info = {}; | ||||
6426 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
6427 | alloc_info.allocationSize = 256; | ||||
6428 | bool pass = false; | ||||
6429 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, | ||||
6430 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
6431 | if (!pass) { | ||||
6432 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
6433 | return; | ||||
6434 | } | ||||
6435 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); | ||||
6436 | ASSERT_VK_SUCCESS(err); | ||||
6437 | |||||
6438 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
6439 | ASSERT_VK_SUCCESS(err); | ||||
6440 | |||||
6441 | VkBufferImageCopy region = {}; | ||||
6442 | region.bufferRowLength = 128; | ||||
6443 | region.bufferImageHeight = 128; | ||||
6444 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
6445 | |||||
6446 | region.imageSubresource.layerCount = 1; | ||||
6447 | region.imageExtent.height = 4; | ||||
6448 | region.imageExtent.width = 4; | ||||
6449 | region.imageExtent.depth = 1; | ||||
6450 | m_commandBuffer->BeginCommandBuffer(); | ||||
6451 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer, | ||||
6452 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
6453 | 1, ®ion); | ||||
6454 | m_commandBuffer->EndCommandBuffer(); | ||||
6455 | |||||
6456 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6457 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6458 | " that is invalid because bound buffer "); | ||||
6459 | // Destroy buffer dependency prior to submit to cause ERROR | ||||
6460 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
6461 | |||||
6462 | VkSubmitInfo submit_info = {}; | ||||
6463 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
6464 | submit_info.commandBufferCount = 1; | ||||
6465 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); | ||||
6466 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
6467 | |||||
6468 | m_errorMonitor->VerifyFound(); | ||||
6469 | vkFreeMemory(m_device->handle(), mem, NULL); | ||||
6470 | } | ||||
6471 | |||||
Tobin Ehlis | 11c8cea | 2016-06-28 17:44:21 -0600 | [diff] [blame] | 6472 | TEST_F(VkLayerTest, InvalidCmdBufferImageDestroyed) { |
6473 | TEST_DESCRIPTION("Attempt to draw with a command buffer that is invalid " | ||||
6474 | "due to an image dependency being destroyed."); | ||||
6475 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6476 | |||||
6477 | VkImage image; | ||||
6478 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
6479 | VkImageCreateInfo image_create_info = {}; | ||||
6480 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
6481 | image_create_info.pNext = NULL; | ||||
6482 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
6483 | image_create_info.format = tex_format; | ||||
6484 | image_create_info.extent.width = 32; | ||||
6485 | image_create_info.extent.height = 32; | ||||
6486 | image_create_info.extent.depth = 1; | ||||
6487 | image_create_info.mipLevels = 1; | ||||
6488 | image_create_info.arrayLayers = 1; | ||||
6489 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
6490 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
6491 | image_create_info.usage = | ||||
6492 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; | ||||
6493 | image_create_info.flags = 0; | ||||
6494 | VkResult err = | ||||
6495 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
6496 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 3d09fd5 | 2016-07-06 08:12:56 -0600 | [diff] [blame] | 6497 | // Have to bind memory to image before recording cmd in cmd buffer using it |
6498 | VkMemoryRequirements mem_reqs; | ||||
6499 | VkDeviceMemory image_mem; | ||||
6500 | bool pass; | ||||
6501 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
6502 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
6503 | mem_alloc.pNext = NULL; | ||||
6504 | mem_alloc.memoryTypeIndex = 0; | ||||
6505 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
6506 | mem_alloc.allocationSize = mem_reqs.size; | ||||
6507 | pass = | ||||
6508 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
6509 | ASSERT_TRUE(pass); | ||||
6510 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); | ||||
6511 | ASSERT_VK_SUCCESS(err); | ||||
6512 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); | ||||
6513 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 11c8cea | 2016-06-28 17:44:21 -0600 | [diff] [blame] | 6514 | |
Tobin Ehlis | 11c8cea | 2016-06-28 17:44:21 -0600 | [diff] [blame] | 6515 | m_commandBuffer->BeginCommandBuffer(); |
Tobin Ehlis | 764d707 | 2016-07-01 12:54:29 -0600 | [diff] [blame] | 6516 | VkClearColorValue ccv; |
6517 | ccv.float32[0] = 1.0f; | ||||
6518 | ccv.float32[1] = 1.0f; | ||||
6519 | ccv.float32[2] = 1.0f; | ||||
6520 | ccv.float32[3] = 1.0f; | ||||
6521 | VkImageSubresourceRange isr = {}; | ||||
6522 | isr.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | 3d09fd5 | 2016-07-06 08:12:56 -0600 | [diff] [blame] | 6523 | isr.baseArrayLayer = 0; |
6524 | isr.baseMipLevel = 0; | ||||
Tobin Ehlis | 764d707 | 2016-07-01 12:54:29 -0600 | [diff] [blame] | 6525 | isr.layerCount = 1; |
6526 | isr.levelCount = 1; | ||||
6527 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), image, | ||||
6528 | VK_IMAGE_LAYOUT_GENERAL, &ccv, 1, &isr); | ||||
Tobin Ehlis | 11c8cea | 2016-06-28 17:44:21 -0600 | [diff] [blame] | 6529 | m_commandBuffer->EndCommandBuffer(); |
6530 | |||||
6531 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6532 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " that is invalid because bound image "); | ||||
6533 | // Destroy image dependency prior to submit to cause ERROR | ||||
6534 | vkDestroyImage(m_device->device(), image, NULL); | ||||
6535 | |||||
6536 | VkSubmitInfo submit_info = {}; | ||||
6537 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
6538 | submit_info.commandBufferCount = 1; | ||||
6539 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); | ||||
6540 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
6541 | |||||
6542 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 3d09fd5 | 2016-07-06 08:12:56 -0600 | [diff] [blame] | 6543 | vkFreeMemory(m_device->device(), image_mem, nullptr); |
Tobin Ehlis | 11c8cea | 2016-06-28 17:44:21 -0600 | [diff] [blame] | 6544 | } |
6545 | |||||
Tobin Ehlis | 85940f5 | 2016-07-07 16:57:21 -0600 | [diff] [blame^] | 6546 | TEST_F(VkLayerTest, InvalidCmdBufferEventDestroyed) { |
6547 | TEST_DESCRIPTION("Attempt to draw with a command buffer that is invalid " | ||||
6548 | "due to an event dependency being destroyed."); | ||||
6549 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6550 | |||||
6551 | VkEvent event; | ||||
6552 | VkEventCreateInfo evci = {}; | ||||
6553 | evci.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
6554 | VkResult result = vkCreateEvent(m_device->device(), &evci, NULL, &event); | ||||
6555 | ASSERT_VK_SUCCESS(result); | ||||
6556 | |||||
6557 | m_commandBuffer->BeginCommandBuffer(); | ||||
6558 | vkCmdSetEvent(m_commandBuffer->GetBufferHandle(), event, | ||||
6559 | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT); | ||||
6560 | m_commandBuffer->EndCommandBuffer(); | ||||
6561 | |||||
6562 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6563 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " that is invalid because bound event "); | ||||
6564 | // Destroy event dependency prior to submit to cause ERROR | ||||
6565 | vkDestroyEvent(m_device->device(), event, NULL); | ||||
6566 | |||||
6567 | VkSubmitInfo submit_info = {}; | ||||
6568 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
6569 | submit_info.commandBufferCount = 1; | ||||
6570 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); | ||||
6571 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
6572 | |||||
6573 | m_errorMonitor->VerifyFound(); | ||||
6574 | } | ||||
6575 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6576 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6577 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
6578 | // ObjectTracker should catch this. | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6579 | // Create a valid cmd buffer |
6580 | // call vkCmdBindPipeline w/ false Pipeline | ||||
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 6581 | uint64_t fake_pipeline_handle = 0xbaad6001; |
6582 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6583 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
6584 | "Invalid VkPipeline Object 0xbaad6001"); | ||||
6585 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6586 | BeginCommandBuffer(); | ||||
6587 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
6588 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); | ||||
6589 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 6590 | // Now issue a draw call with no pipeline bound |
6591 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6592 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6593 | "At Draw/Dispatch time no valid VkPipeline is bound!"); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6594 | |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 6595 | BeginCommandBuffer(); |
6596 | Draw(1, 0, 0, 0); | ||||
6597 | m_errorMonitor->VerifyFound(); | ||||
6598 | // Finally same check once more but with Dispatch/Compute | ||||
6599 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6600 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6601 | "At Draw/Dispatch time no valid VkPipeline is bound!"); | ||||
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 6602 | BeginCommandBuffer(); |
6603 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); | ||||
6604 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6605 | } |
6606 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6607 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
6608 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on | ||||
6609 | // CommandBuffer | ||||
6610 | VkResult err; | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6611 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6612 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6613 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6614 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6615 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 6616 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
6617 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6618 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6619 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
6620 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6621 | |
6622 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6623 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
6624 | ds_pool_ci.pNext = NULL; | ||||
6625 | ds_pool_ci.maxSets = 1; | ||||
6626 | ds_pool_ci.poolSizeCount = 1; | ||||
6627 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 6628 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6629 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6630 | err = |
6631 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6632 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6633 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6634 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6635 | dsl_binding.binding = 0; |
6636 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6637 | dsl_binding.descriptorCount = 1; | ||||
6638 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
6639 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6640 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6641 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6642 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
6643 | ds_layout_ci.pNext = NULL; | ||||
6644 | ds_layout_ci.bindingCount = 1; | ||||
6645 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6646 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6647 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
6648 | &ds_layout); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6649 | ASSERT_VK_SUCCESS(err); |
6650 | |||||
6651 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6652 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6653 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6654 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6655 | alloc_info.descriptorPool = ds_pool; |
6656 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6657 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
6658 | &descriptorSet); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6659 | ASSERT_VK_SUCCESS(err); |
6660 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6661 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6662 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
6663 | pipeline_layout_ci.pNext = NULL; | ||||
6664 | pipeline_layout_ci.setLayoutCount = 1; | ||||
6665 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6666 | |
6667 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6668 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
6669 | &pipeline_layout); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6670 | ASSERT_VK_SUCCESS(err); |
6671 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6672 | VkShaderObj vs(m_device, bindStateVertShaderText, |
6673 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6674 | // We shouldn't need a fragment shader but add it to be able to run |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6675 | // on more devices |
6676 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
6677 | VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6678 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 6679 | VkPipelineObj pipe(m_device); |
6680 | pipe.AddShader(&vs); | ||||
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6681 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6682 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 6683 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6684 | |
6685 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6686 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
6687 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
6688 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
6689 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
6690 | 1, &descriptorSet, 0, NULL); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 6691 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6692 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6693 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6694 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
6695 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
6696 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6697 | } |
6698 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6699 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6700 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6701 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6702 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6703 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6704 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
6705 | "descriptor with invalid buffer view"); | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6706 | |
6707 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6708 | VkDescriptorPoolSize ds_type_count = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6709 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
6710 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6711 | |
6712 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6713 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
6714 | ds_pool_ci.pNext = NULL; | ||||
6715 | ds_pool_ci.maxSets = 1; | ||||
6716 | ds_pool_ci.poolSizeCount = 1; | ||||
6717 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6718 | |
6719 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6720 | err = |
6721 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6722 | ASSERT_VK_SUCCESS(err); |
6723 | |||||
6724 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6725 | dsl_binding.binding = 0; |
6726 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; | ||||
6727 | dsl_binding.descriptorCount = 1; | ||||
6728 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
6729 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6730 | |
6731 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6732 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
6733 | ds_layout_ci.pNext = NULL; | ||||
6734 | ds_layout_ci.bindingCount = 1; | ||||
6735 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6736 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6737 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
6738 | &ds_layout); | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6739 | ASSERT_VK_SUCCESS(err); |
6740 | |||||
6741 | VkDescriptorSet descriptorSet; | ||||
6742 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6743 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6744 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6745 | alloc_info.descriptorPool = ds_pool; |
6746 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6747 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
6748 | &descriptorSet); | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6749 | ASSERT_VK_SUCCESS(err); |
6750 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6751 | VkBufferView view = |
6752 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6753 | VkWriteDescriptorSet descriptor_write; |
6754 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
6755 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
6756 | descriptor_write.dstSet = descriptorSet; | ||||
6757 | descriptor_write.dstBinding = 0; | ||||
6758 | descriptor_write.descriptorCount = 1; | ||||
6759 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; | ||||
6760 | descriptor_write.pTexelBufferView = &view; | ||||
6761 | |||||
6762 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
6763 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6764 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 6765 | |
6766 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
6767 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
6768 | } | ||||
6769 | |||||
Mark Young | d339ba3 | 2016-05-30 13:28:35 -0600 | [diff] [blame] | 6770 | TEST_F(VkLayerTest, CreateBufferViewNoMemoryBoundToBuffer) { |
6771 | TEST_DESCRIPTION("Attempt to create a buffer view with a buffer that has" | ||||
6772 | " no memory bound to it."); | ||||
6773 | |||||
6774 | VkResult err; | ||||
6775 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6776 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6777 | "vkCreateBufferView called with invalid memory "); | ||||
6778 | |||||
6779 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6780 | |||||
6781 | // Create a buffer with no bound memory and then attempt to create | ||||
6782 | // a buffer view. | ||||
6783 | VkBufferCreateInfo buff_ci = {}; | ||||
6784 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
6785 | buff_ci.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
6786 | buff_ci.size = 256; | ||||
6787 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
6788 | VkBuffer buffer; | ||||
6789 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); | ||||
6790 | ASSERT_VK_SUCCESS(err); | ||||
6791 | |||||
6792 | VkBufferViewCreateInfo buff_view_ci = {}; | ||||
6793 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; | ||||
6794 | buff_view_ci.buffer = buffer; | ||||
6795 | buff_view_ci.format = VK_FORMAT_R8_UNORM; | ||||
6796 | buff_view_ci.range = VK_WHOLE_SIZE; | ||||
6797 | VkBufferView buff_view; | ||||
6798 | err = | ||||
6799 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); | ||||
6800 | |||||
6801 | m_errorMonitor->VerifyFound(); | ||||
6802 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
6803 | // If last error is success, it still created the view, so delete it. | ||||
6804 | if (err == VK_SUCCESS) { | ||||
6805 | vkDestroyBufferView(m_device->device(), buff_view, NULL); | ||||
6806 | } | ||||
6807 | } | ||||
6808 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6809 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
6810 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error | ||||
6811 | // cases: | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6812 | // 1. No dynamicOffset supplied |
6813 | // 2. Too many dynamicOffsets supplied | ||||
6814 | // 3. Dynamic offset oversteps buffer being updated | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6815 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6816 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6817 | " requires 1 dynamicOffsets, but only " |
6818 | "0 dynamicOffsets are left in " | ||||
6819 | "pDynamicOffsets "); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6820 | |
6821 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6822 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
6823 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
6824 | |||||
6825 | VkDescriptorPoolSize ds_type_count = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6826 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
6827 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6828 | |
6829 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6830 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
6831 | ds_pool_ci.pNext = NULL; | ||||
6832 | ds_pool_ci.maxSets = 1; | ||||
6833 | ds_pool_ci.poolSizeCount = 1; | ||||
6834 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6835 | |
6836 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6837 | err = |
6838 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6839 | ASSERT_VK_SUCCESS(err); |
6840 | |||||
6841 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6842 | dsl_binding.binding = 0; |
6843 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; | ||||
6844 | dsl_binding.descriptorCount = 1; | ||||
6845 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
6846 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6847 | |
6848 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6849 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
6850 | ds_layout_ci.pNext = NULL; | ||||
6851 | ds_layout_ci.bindingCount = 1; | ||||
6852 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6853 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6854 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
6855 | &ds_layout); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6856 | ASSERT_VK_SUCCESS(err); |
6857 | |||||
6858 | VkDescriptorSet descriptorSet; | ||||
6859 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6860 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6861 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6862 | alloc_info.descriptorPool = ds_pool; |
6863 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6864 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
6865 | &descriptorSet); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6866 | ASSERT_VK_SUCCESS(err); |
6867 | |||||
6868 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6869 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
6870 | pipeline_layout_ci.pNext = NULL; | ||||
6871 | pipeline_layout_ci.setLayoutCount = 1; | ||||
6872 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6873 | |
6874 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6875 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
6876 | &pipeline_layout); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6877 | ASSERT_VK_SUCCESS(err); |
6878 | |||||
6879 | // Create a buffer to update the descriptor with | ||||
6880 | uint32_t qfi = 0; | ||||
6881 | VkBufferCreateInfo buffCI = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6882 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
6883 | buffCI.size = 1024; | ||||
6884 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
6885 | buffCI.queueFamilyIndexCount = 1; | ||||
6886 | buffCI.pQueueFamilyIndices = &qfi; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6887 | |
6888 | VkBuffer dyub; | ||||
6889 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); | ||||
6890 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6891 | // Allocate memory and bind to buffer so we can make it to the appropriate |
6892 | // error | ||||
6893 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
6894 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
6895 | mem_alloc.pNext = NULL; | ||||
6896 | mem_alloc.allocationSize = 1024; | ||||
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 6897 | mem_alloc.memoryTypeIndex = 0; |
6898 | |||||
6899 | VkMemoryRequirements memReqs; | ||||
6900 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); | ||||
6901 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, | ||||
6902 | 0); | ||||
6903 | if (!pass) { | ||||
6904 | vkDestroyBuffer(m_device->device(), dyub, NULL); | ||||
6905 | return; | ||||
6906 | } | ||||
6907 | |||||
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6908 | VkDeviceMemory mem; |
6909 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); | ||||
6910 | ASSERT_VK_SUCCESS(err); | ||||
6911 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); | ||||
6912 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6913 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
6914 | VkDescriptorBufferInfo buffInfo = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6915 | buffInfo.buffer = dyub; |
6916 | buffInfo.offset = 0; | ||||
6917 | buffInfo.range = 1024; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6918 | |
6919 | VkWriteDescriptorSet descriptor_write; | ||||
6920 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
6921 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
6922 | descriptor_write.dstSet = descriptorSet; | ||||
6923 | descriptor_write.dstBinding = 0; | ||||
6924 | descriptor_write.descriptorCount = 1; | ||||
6925 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; | ||||
6926 | descriptor_write.pBufferInfo = &buffInfo; | ||||
6927 | |||||
6928 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
6929 | |||||
6930 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6931 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
6932 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
6933 | 1, &descriptorSet, 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6934 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6935 | uint32_t pDynOff[2] = {512, 756}; |
6936 | // Now cause error b/c too many dynOffsets in array for # of dyn descriptors | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6937 | m_errorMonitor->SetDesiredFailureMsg( |
6938 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6939 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6940 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
6941 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
6942 | 1, &descriptorSet, 2, pDynOff); | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6943 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6944 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6945 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
6946 | " dynamic offset 512 combined with " | ||||
6947 | "offset 0 and range 1024 that " | ||||
6948 | "oversteps the buffer size of 1024"); | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6949 | // Create PSO to be used for draw-time errors below |
6950 | char const *vsSource = | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6951 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6952 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6953 | "out gl_PerVertex { \n" |
6954 | " vec4 gl_Position;\n" | ||||
6955 | "};\n" | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6956 | "void main(){\n" |
6957 | " gl_Position = vec4(1);\n" | ||||
6958 | "}\n"; | ||||
6959 | char const *fsSource = | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 6960 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6961 | "\n" |
6962 | "layout(location=0) out vec4 x;\n" | ||||
6963 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" | ||||
6964 | "void main(){\n" | ||||
6965 | " x = vec4(bar.y);\n" | ||||
6966 | "}\n"; | ||||
6967 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
6968 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
6969 | VkPipelineObj pipe(m_device); | ||||
6970 | pipe.AddShader(&vs); | ||||
6971 | pipe.AddShader(&fs); | ||||
6972 | pipe.AddColorAttachment(); | ||||
6973 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
6974 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6975 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
6976 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
6977 | // This update should succeed, but offset size of 512 will overstep buffer | ||||
6978 | // /w range 1024 & size 1024 | ||||
6979 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
6980 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
6981 | 1, &descriptorSet, 1, pDynOff); | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 6982 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6983 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6984 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6985 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 6986 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6987 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6988 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6989 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 6990 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
6991 | } | ||||
6992 | |||||
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6993 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6994 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 6995 | ASSERT_NO_FATAL_FAILURE(InitState()); |
6996 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
6997 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
6998 | |||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 6999 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7000 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7001 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
7002 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
7003 | pipeline_layout_ci.pushConstantRangeCount = 1; | ||||
7004 | pipeline_layout_ci.pPushConstantRanges = &pc_range; | ||||
7005 | |||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7006 | // |
7007 | // Check for invalid push constant ranges in pipeline layouts. | ||||
7008 | // | ||||
7009 | struct PipelineLayoutTestCase { | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7010 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7011 | char const *msg; |
7012 | }; | ||||
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7013 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7014 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
7015 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ | ||||
7016 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, | ||||
7017 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
7018 | "size 0."}, | ||||
7019 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, | ||||
7020 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
7021 | "size 1."}, | ||||
7022 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, | ||||
7023 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
7024 | "size 1."}, | ||||
7025 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, | ||||
7026 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
7027 | "size 0."}, | ||||
7028 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, | ||||
7029 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
7030 | "offset 1. Offset must"}, | ||||
7031 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, | ||||
7032 | "vkCreatePipelineLayout() call has push constants index 0 " | ||||
7033 | "with offset "}, | ||||
7034 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, | ||||
7035 | "vkCreatePipelineLayout() call has push constants " | ||||
7036 | "index 0 with offset "}, | ||||
7037 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, | ||||
7038 | "vkCreatePipelineLayout() call has push constants index 0 " | ||||
7039 | "with offset "}, | ||||
7040 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, | ||||
7041 | "vkCreatePipelineLayout() call has push " | ||||
7042 | "constants index 0 with offset "}, | ||||
7043 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, | ||||
7044 | "vkCreatePipelineLayout() call has push " | ||||
7045 | "constants index 0 with offset "}, | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7046 | }}; |
7047 | |||||
7048 | // Check for invalid offset and size | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7049 | for (const auto &iter : range_tests) { |
7050 | pc_range = iter.range; | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7051 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
7052 | iter.msg); | ||||
7053 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, | ||||
7054 | NULL, &pipeline_layout); | ||||
7055 | m_errorMonitor->VerifyFound(); | ||||
7056 | if (VK_SUCCESS == err) { | ||||
7057 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
7058 | } | ||||
7059 | } | ||||
7060 | |||||
7061 | // Check for invalid stage flag | ||||
7062 | pc_range.offset = 0; | ||||
7063 | pc_range.size = 16; | ||||
7064 | pc_range.stageFlags = 0; | ||||
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7065 | m_errorMonitor->SetDesiredFailureMsg( |
7066 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7067 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7068 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7069 | &pipeline_layout); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7070 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7071 | if (VK_SUCCESS == err) { |
7072 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
7073 | } | ||||
7074 | |||||
7075 | // Check for overlapping ranges | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7076 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7077 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7078 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7079 | char const *msg; |
7080 | }; | ||||
7081 | |||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7082 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7083 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
7084 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7085 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7086 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7087 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, | ||||
7088 | "vkCreatePipelineLayout() call has push constants with overlapping " | ||||
7089 | "ranges: 0:[0, 4), 1:[0, 4)"}, | ||||
7090 | { | ||||
7091 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7092 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, | ||||
7093 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, | ||||
7094 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, | ||||
7095 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, | ||||
7096 | "vkCreatePipelineLayout() call has push constants with " | ||||
7097 | "overlapping " | ||||
7098 | "ranges: 3:[12, 20), 4:[16, 20)", | ||||
7099 | }, | ||||
7100 | { | ||||
7101 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, | ||||
7102 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, | ||||
7103 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, | ||||
7104 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, | ||||
7105 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, | ||||
7106 | "vkCreatePipelineLayout() call has push constants with " | ||||
7107 | "overlapping " | ||||
7108 | "ranges: 0:[16, 20), 1:[12, 20)", | ||||
7109 | }, | ||||
7110 | { | ||||
7111 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, | ||||
7112 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, | ||||
7113 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, | ||||
7114 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, | ||||
7115 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, | ||||
7116 | "vkCreatePipelineLayout() call has push constants with " | ||||
7117 | "overlapping " | ||||
7118 | "ranges: 0:[16, 20), 3:[12, 20)", | ||||
7119 | }, | ||||
7120 | { | ||||
7121 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, | ||||
7122 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, | ||||
7123 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, | ||||
7124 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, | ||||
7125 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, | ||||
7126 | "vkCreatePipelineLayout() call has push constants with " | ||||
7127 | "overlapping " | ||||
7128 | "ranges: 0:[16, 20), 2:[4, 100)", | ||||
7129 | }}}; | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7130 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7131 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7132 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7133 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
7134 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7135 | iter.msg); |
7136 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, | ||||
7137 | NULL, &pipeline_layout); | ||||
7138 | m_errorMonitor->VerifyFound(); | ||||
7139 | if (VK_SUCCESS == err) { | ||||
7140 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
7141 | } | ||||
7142 | } | ||||
7143 | |||||
7144 | // Run some positive tests to make sure overlap checking in the layer is OK | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7145 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
7146 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7147 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, | ||||
7148 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, | ||||
7149 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, | ||||
7150 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, | ||||
7151 | ""}, | ||||
7152 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, | ||||
7153 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, | ||||
7154 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, | ||||
7155 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, | ||||
7156 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, | ||||
7157 | ""}}}; | ||||
7158 | for (const auto &iter : overlapping_range_tests_pos) { | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7159 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
7160 | m_errorMonitor->ExpectSuccess(); | ||||
7161 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, | ||||
7162 | NULL, &pipeline_layout); | ||||
7163 | m_errorMonitor->VerifyNotFound(); | ||||
7164 | if (VK_SUCCESS == err) { | ||||
7165 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
7166 | } | ||||
7167 | } | ||||
7168 | |||||
7169 | // | ||||
7170 | // CmdPushConstants tests | ||||
7171 | // | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7172 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7173 | |
7174 | // Check for invalid offset and size and if range is within layout range(s) | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7175 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
7176 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, | ||||
7177 | "vkCmdPushConstants() call has push constants with size 0. Size " | ||||
7178 | "must be greater than zero and a multiple of 4."}, | ||||
7179 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, | ||||
7180 | "vkCmdPushConstants() call has push constants with size 1. Size " | ||||
7181 | "must be greater than zero and a multiple of 4."}, | ||||
7182 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, | ||||
7183 | "vkCmdPushConstants() call has push constants with size 1. Size " | ||||
7184 | "must be greater than zero and a multiple of 4."}, | ||||
7185 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, | ||||
7186 | "vkCmdPushConstants() call has push constants with offset 1. " | ||||
7187 | "Offset must be a multiple of 4."}, | ||||
7188 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, | ||||
7189 | "vkCmdPushConstants() call has push constants with offset 1. " | ||||
7190 | "Offset must be a multiple of 4."}, | ||||
7191 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, | ||||
7192 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " | ||||
7193 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7194 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, | ||||
7195 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " | ||||
7196 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7197 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, | ||||
7198 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " | ||||
7199 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7200 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, | ||||
7201 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " | ||||
7202 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7203 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, | ||||
7204 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " | ||||
7205 | "any of the ranges in pipeline layout"}, | ||||
7206 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, | ||||
7207 | 0, 16}, | ||||
7208 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " | ||||
7209 | "any of the ranges in pipeline layout"}, | ||||
7210 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7211 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7212 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7213 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7214 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7215 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7216 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7217 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7218 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7219 | "vkCmdPushConstants() call has push constants with offset "}, |
7220 | }}; | ||||
7221 | |||||
7222 | // Two ranges for testing robustness | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7223 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7224 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7225 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7226 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7227 | pipeline_layout_ci.pushConstantRangeCount = |
7228 | sizeof(pc_range2) / sizeof(VkPushConstantRange); | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7229 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7230 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7231 | &pipeline_layout); | ||||
7232 | ASSERT_VK_SUCCESS(err); | ||||
7233 | BeginCommandBuffer(); | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7234 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7235 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
7236 | iter.msg); | ||||
7237 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7238 | iter.range.stageFlags, iter.range.offset, |
7239 | iter.range.size, dummy_values); | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7240 | m_errorMonitor->VerifyFound(); |
7241 | } | ||||
7242 | |||||
7243 | // Check for invalid stage flag | ||||
7244 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7245 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7246 | "vkCmdPushConstants() call has no stageFlags set."); | ||||
7247 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7248 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7249 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7250 | EndCommandBuffer(); |
7251 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); | ||||
7252 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7253 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7254 | // overlapping range tests with cmd |
7255 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ | ||||
7256 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, | ||||
7257 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " | ||||
7258 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7259 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, | ||||
7260 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " | ||||
7261 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7262 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, | ||||
7263 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " | ||||
7264 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7265 | }}; | ||||
7266 | const VkPushConstantRange pc_range3[] = { | ||||
7267 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, | ||||
7268 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, | ||||
7269 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7270 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, | ||||
7271 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, | ||||
7272 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, | ||||
7273 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, | ||||
7274 | }; | ||||
7275 | pipeline_layout_ci.pushConstantRangeCount = | ||||
7276 | sizeof(pc_range3) / sizeof(VkPushConstantRange); | ||||
7277 | pipeline_layout_ci.pPushConstantRanges = pc_range3; | ||||
7278 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
7279 | &pipeline_layout); | ||||
7280 | ASSERT_VK_SUCCESS(err); | ||||
7281 | BeginCommandBuffer(); | ||||
7282 | for (const auto &iter : cmd_overlap_tests) { | ||||
7283 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7284 | iter.msg); | ||||
7285 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, | ||||
7286 | iter.range.stageFlags, iter.range.offset, | ||||
7287 | iter.range.size, dummy_values); | ||||
7288 | m_errorMonitor->VerifyFound(); | ||||
7289 | } | ||||
7290 | EndCommandBuffer(); | ||||
7291 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); | ||||
7292 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
7293 | |||||
7294 | // positive overlapping range tests with cmd | ||||
7295 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ | ||||
7296 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, | ||||
7297 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, | ||||
7298 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, | ||||
7299 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, | ||||
7300 | }}; | ||||
7301 | const VkPushConstantRange pc_range4[] = { | ||||
7302 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, | ||||
7303 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, | ||||
7304 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, | ||||
7305 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7306 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, | ||||
7307 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, | ||||
7308 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, | ||||
7309 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, | ||||
7310 | }; | ||||
7311 | pipeline_layout_ci.pushConstantRangeCount = | ||||
7312 | sizeof(pc_range4) / sizeof(VkPushConstantRange); | ||||
7313 | pipeline_layout_ci.pPushConstantRanges = pc_range4; | ||||
7314 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
7315 | &pipeline_layout); | ||||
7316 | ASSERT_VK_SUCCESS(err); | ||||
7317 | BeginCommandBuffer(); | ||||
7318 | for (const auto &iter : cmd_overlap_tests_pos) { | ||||
7319 | m_errorMonitor->ExpectSuccess(); | ||||
7320 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, | ||||
7321 | iter.range.stageFlags, iter.range.offset, | ||||
7322 | iter.range.size, dummy_values); | ||||
7323 | m_errorMonitor->VerifyNotFound(); | ||||
7324 | } | ||||
7325 | EndCommandBuffer(); | ||||
7326 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); | ||||
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7327 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
7328 | } | ||||
7329 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7330 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7331 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7332 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7333 | |
7334 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7335 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
7336 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
7337 | |||||
Mike Stroyan | b8a6100 | 2016-06-20 16:00:28 -0600 | [diff] [blame] | 7338 | const VkFormat tex_format = VK_FORMAT_R8G8B8A8_UNORM; |
7339 | VkImageTiling tiling; | ||||
7340 | VkFormatProperties format_properties; | ||||
7341 | vkGetPhysicalDeviceFormatProperties(gpu(), tex_format, &format_properties); | ||||
7342 | if (format_properties.linearTilingFeatures & | ||||
7343 | VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) { | ||||
7344 | tiling = VK_IMAGE_TILING_LINEAR; | ||||
7345 | } else if (format_properties.optimalTilingFeatures & | ||||
7346 | VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) { | ||||
7347 | tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
7348 | } else { | ||||
7349 | printf("Device does not support VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT; " | ||||
7350 | "skipped.\n"); | ||||
7351 | return; | ||||
7352 | } | ||||
7353 | |||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7354 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
7355 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7356 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
7357 | ds_type_count[0].descriptorCount = 10; | ||||
7358 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
7359 | ds_type_count[1].descriptorCount = 2; | ||||
7360 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; | ||||
7361 | ds_type_count[2].descriptorCount = 2; | ||||
7362 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
7363 | ds_type_count[3].descriptorCount = 5; | ||||
7364 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT | ||||
7365 | // type | ||||
7366 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; | ||||
7367 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; | ||||
7368 | ds_type_count[4].descriptorCount = 2; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7369 | |
7370 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7371 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
7372 | ds_pool_ci.pNext = NULL; | ||||
7373 | ds_pool_ci.maxSets = 5; | ||||
7374 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; | ||||
7375 | ds_pool_ci.pPoolSizes = ds_type_count; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7376 | |
7377 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7378 | err = |
7379 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7380 | ASSERT_VK_SUCCESS(err); |
7381 | |||||
7382 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; | ||||
7383 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7384 | dsl_binding[0].binding = 0; |
7385 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
7386 | dsl_binding[0].descriptorCount = 5; | ||||
7387 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; | ||||
7388 | dsl_binding[0].pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7389 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7390 | // Create layout identical to set0 layout but w/ different stageFlags |
7391 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7392 | dsl_fs_stage_only.binding = 0; |
7393 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
7394 | dsl_fs_stage_only.descriptorCount = 5; | ||||
7395 | dsl_fs_stage_only.stageFlags = | ||||
7396 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at | ||||
7397 | // bind time | ||||
7398 | dsl_fs_stage_only.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7399 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7400 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
7401 | ds_layout_ci.pNext = NULL; | ||||
7402 | ds_layout_ci.bindingCount = 1; | ||||
7403 | ds_layout_ci.pBindings = dsl_binding; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7404 | static const uint32_t NUM_LAYOUTS = 4; |
7405 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7406 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7407 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
7408 | // layout for error case | ||||
7409 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
7410 | &ds_layout[0]); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7411 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 7412 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7413 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
7414 | &ds_layout_fs_only); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7415 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7416 | dsl_binding[0].binding = 0; |
7417 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7418 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 7419 | dsl_binding[1].binding = 1; |
7420 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; | ||||
7421 | dsl_binding[1].descriptorCount = 2; | ||||
7422 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; | ||||
7423 | dsl_binding[1].pImmutableSamplers = NULL; | ||||
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 7424 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7425 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7426 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
7427 | &ds_layout[1]); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7428 | ASSERT_VK_SUCCESS(err); |
7429 | dsl_binding[0].binding = 0; | ||||
7430 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7431 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7432 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7433 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
7434 | &ds_layout[2]); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7435 | ASSERT_VK_SUCCESS(err); |
7436 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7437 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7438 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
7439 | &ds_layout[3]); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7440 | ASSERT_VK_SUCCESS(err); |
7441 | |||||
7442 | static const uint32_t NUM_SETS = 4; | ||||
7443 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; | ||||
7444 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7445 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7446 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7447 | alloc_info.descriptorPool = ds_pool; |
7448 | alloc_info.pSetLayouts = ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7449 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
7450 | descriptorSet); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7451 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7452 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7453 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7454 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7455 | err = |
7456 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7457 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7458 | |
7459 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7460 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
7461 | pipeline_layout_ci.pNext = NULL; | ||||
7462 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; | ||||
7463 | pipeline_layout_ci.pSetLayouts = ds_layout; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7464 | |
7465 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7466 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7467 | &pipeline_layout); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7468 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7469 | // Create pipelineLayout with only one setLayout |
7470 | pipeline_layout_ci.setLayoutCount = 1; | ||||
7471 | VkPipelineLayout single_pipe_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7472 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7473 | &single_pipe_layout); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7474 | ASSERT_VK_SUCCESS(err); |
7475 | // Create pipelineLayout with 2 descriptor setLayout at index 0 | ||||
7476 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; | ||||
7477 | VkPipelineLayout pipe_layout_one_desc; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7478 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7479 | &pipe_layout_one_desc); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7480 | ASSERT_VK_SUCCESS(err); |
7481 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 | ||||
7482 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; | ||||
7483 | VkPipelineLayout pipe_layout_five_samp; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7484 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7485 | &pipe_layout_five_samp); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7486 | ASSERT_VK_SUCCESS(err); |
7487 | // Create pipelineLayout with UB type, but stageFlags for FS only | ||||
7488 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; | ||||
7489 | VkPipelineLayout pipe_layout_fs_only; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7490 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7491 | &pipe_layout_fs_only); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7492 | ASSERT_VK_SUCCESS(err); |
7493 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine | ||||
7494 | VkDescriptorSetLayout pl_bad_s0[2] = {}; | ||||
7495 | pl_bad_s0[0] = ds_layout_fs_only; | ||||
7496 | pl_bad_s0[1] = ds_layout[1]; | ||||
7497 | pipeline_layout_ci.setLayoutCount = 2; | ||||
7498 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; | ||||
7499 | VkPipelineLayout pipe_layout_bad_set0; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7500 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7501 | &pipe_layout_bad_set0); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7502 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7503 | |
7504 | // Create a buffer to update the descriptor with | ||||
7505 | uint32_t qfi = 0; | ||||
7506 | VkBufferCreateInfo buffCI = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7507 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
7508 | buffCI.size = 1024; | ||||
7509 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
7510 | buffCI.queueFamilyIndexCount = 1; | ||||
7511 | buffCI.pQueueFamilyIndices = &qfi; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7512 | |
7513 | VkBuffer dyub; | ||||
7514 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); | ||||
7515 | ASSERT_VK_SUCCESS(err); | ||||
7516 | // Correctly update descriptor to avoid "NOT_UPDATED" error | ||||
7517 | static const uint32_t NUM_BUFFS = 5; | ||||
7518 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7519 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7520 | buffInfo[i].buffer = dyub; |
7521 | buffInfo[i].offset = 0; | ||||
7522 | buffInfo[i].range = 1024; | ||||
7523 | } | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7524 | VkImage image; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7525 | const int32_t tex_width = 32; |
7526 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7527 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7528 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
7529 | image_create_info.pNext = NULL; | ||||
7530 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
7531 | image_create_info.format = tex_format; | ||||
7532 | image_create_info.extent.width = tex_width; | ||||
7533 | image_create_info.extent.height = tex_height; | ||||
7534 | image_create_info.extent.depth = 1; | ||||
7535 | image_create_info.mipLevels = 1; | ||||
7536 | image_create_info.arrayLayers = 1; | ||||
7537 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
Mike Stroyan | b8a6100 | 2016-06-20 16:00:28 -0600 | [diff] [blame] | 7538 | image_create_info.tiling = tiling; |
7539 | image_create_info.usage = | ||||
7540 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7541 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7542 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
7543 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7544 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7545 | VkMemoryRequirements memReqs; |
7546 | VkDeviceMemory imageMem; | ||||
7547 | bool pass; | ||||
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 7548 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7549 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
7550 | memAlloc.pNext = NULL; | ||||
7551 | memAlloc.allocationSize = 0; | ||||
7552 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 7553 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
7554 | memAlloc.allocationSize = memReqs.size; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7555 | pass = |
7556 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 7557 | ASSERT_TRUE(pass); |
7558 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); | ||||
7559 | ASSERT_VK_SUCCESS(err); | ||||
7560 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); | ||||
7561 | ASSERT_VK_SUCCESS(err); | ||||
7562 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7563 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7564 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
7565 | image_view_create_info.image = image; | ||||
7566 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
7567 | image_view_create_info.format = tex_format; | ||||
7568 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
7569 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
7570 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
7571 | image_view_create_info.subresourceRange.aspectMask = | ||||
7572 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7573 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7574 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7575 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
7576 | &view); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7577 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 7578 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7579 | imageInfo[0].imageView = view; |
7580 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
7581 | imageInfo[1].imageView = view; | ||||
7582 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 7583 | imageInfo[2].imageView = view; |
7584 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
7585 | imageInfo[3].imageView = view; | ||||
7586 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7587 | |
7588 | static const uint32_t NUM_SET_UPDATES = 3; | ||||
7589 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; | ||||
7590 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
7591 | descriptor_write[0].dstSet = descriptorSet[0]; | ||||
7592 | descriptor_write[0].dstBinding = 0; | ||||
7593 | descriptor_write[0].descriptorCount = 5; | ||||
7594 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
7595 | descriptor_write[0].pBufferInfo = buffInfo; | ||||
7596 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
7597 | descriptor_write[1].dstSet = descriptorSet[1]; | ||||
7598 | descriptor_write[1].dstBinding = 0; | ||||
7599 | descriptor_write[1].descriptorCount = 2; | ||||
7600 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
7601 | descriptor_write[1].pImageInfo = imageInfo; | ||||
7602 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
7603 | descriptor_write[2].dstSet = descriptorSet[1]; | ||||
7604 | descriptor_write[2].dstBinding = 1; | ||||
7605 | descriptor_write[2].descriptorCount = 2; | ||||
7606 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; | ||||
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 7607 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7608 | |
7609 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7610 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 7611 | // Create PSO to be used for draw-time errors below |
7612 | char const *vsSource = | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 7613 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 7614 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7615 | "out gl_PerVertex {\n" |
7616 | " vec4 gl_Position;\n" | ||||
7617 | "};\n" | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 7618 | "void main(){\n" |
7619 | " gl_Position = vec4(1);\n" | ||||
7620 | "}\n"; | ||||
7621 | char const *fsSource = | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 7622 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 7623 | "\n" |
7624 | "layout(location=0) out vec4 x;\n" | ||||
7625 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" | ||||
7626 | "void main(){\n" | ||||
7627 | " x = vec4(bar.y);\n" | ||||
7628 | "}\n"; | ||||
7629 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
7630 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7631 | VkPipelineObj pipe(m_device); |
7632 | pipe.AddShader(&vs); | ||||
7633 | pipe.AddShader(&fs); | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 7634 | pipe.AddColorAttachment(); |
7635 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7636 | |
7637 | BeginCommandBuffer(); | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 7638 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7639 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
7640 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
7641 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding | ||||
7642 | // of PSO | ||||
7643 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of | ||||
7644 | // cmd_pipeline.c | ||||
7645 | // due to the fact that cmd_alloc_dset_data() has not been called in | ||||
7646 | // cmd_bind_graphics_pipeline() | ||||
7647 | // TODO : Want to cause various binding incompatibility issues here to test | ||||
7648 | // DrawState | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7649 | // First cause various verify_layout_compatibility() fails |
7650 | // Second disturb early and late sets and verify INFO msgs | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7651 | // verify_set_layout_compatibility fail cases: |
7652 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7653 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 10fad69 | 2016-07-07 12:00:36 -0600 | [diff] [blame] | 7654 | "Invalid VkPipelineLayout Object "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7655 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
7656 | VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
7657 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, | ||||
7658 | &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7659 | m_errorMonitor->VerifyFound(); |
7660 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7661 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7662 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
7663 | " attempting to bind set to index 1"); | ||||
7664 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
7665 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, | ||||
7666 | 0, 2, &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7667 | m_errorMonitor->VerifyFound(); |
7668 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7669 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7670 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
7671 | // descriptors | ||||
7672 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7673 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 7674 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7675 | vkCmdBindDescriptorSets( |
7676 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
7677 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7678 | m_errorMonitor->VerifyFound(); |
7679 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7680 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
7681 | // 4. same # of descriptors but mismatch in type | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7682 | m_errorMonitor->SetDesiredFailureMsg( |
7683 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 7684 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7685 | vkCmdBindDescriptorSets( |
7686 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
7687 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7688 | m_errorMonitor->VerifyFound(); |
7689 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7690 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
7691 | // 5. same # of descriptors but mismatch in stageFlags | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7692 | m_errorMonitor->SetDesiredFailureMsg( |
7693 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 7694 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7695 | vkCmdBindDescriptorSets( |
7696 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
7697 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7698 | m_errorMonitor->VerifyFound(); |
7699 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7700 | // Cause INFO messages due to disturbing previously bound Sets |
7701 | // First bind sets 0 & 1 | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7702 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
7703 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
7704 | 2, &descriptorSet[0], 0, NULL); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7705 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7706 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7707 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7708 | " previously bound as set #0 was disturbed "); |
7709 | vkCmdBindDescriptorSets( | ||||
7710 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
7711 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7712 | m_errorMonitor->VerifyFound(); |
7713 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7714 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
7715 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
7716 | 2, &descriptorSet[0], 0, NULL); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7717 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7718 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7719 | " newly bound as set #0 so set #1 and " |
7720 | "any subsequent sets were disturbed "); | ||||
7721 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
7722 | VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
7723 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7724 | m_errorMonitor->VerifyFound(); |
7725 | |||||
Tobin Ehlis | 10fad69 | 2016-07-07 12:00:36 -0600 | [diff] [blame] | 7726 | // Now that we're done actively using the pipelineLayout that gfx pipeline |
7727 | // was created with, we should be able to delete it. Do that now to verify | ||||
7728 | // that validation obeys pipelineLayout lifetime | ||||
7729 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); | ||||
7730 | |||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 7731 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7732 | // 1. Error due to not binding required set (we actually use same code as |
7733 | // above to disturb set0) | ||||
7734 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
7735 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
7736 | 2, &descriptorSet[0], 0, NULL); | ||||
7737 | vkCmdBindDescriptorSets( | ||||
7738 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
7739 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); | ||||
7740 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7741 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7742 | " uses set #0 but that set is not bound."); | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 7743 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7744 | m_errorMonitor->VerifyFound(); |
7745 | |||||
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 7746 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7747 | // 2. Error due to bound set not being compatible with PSO's |
7748 | // VkPipelineLayout (diff stageFlags in this case) | ||||
7749 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
7750 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
7751 | 2, &descriptorSet[0], 0, NULL); | ||||
7752 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7753 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7754 | " bound as set #0 is not compatible with "); | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 7755 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7756 | m_errorMonitor->VerifyFound(); |
7757 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7758 | // Remaining clean-up |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7759 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7760 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
7761 | } | ||||
7762 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); | ||||
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 7763 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
7764 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 7765 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7766 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
7767 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7768 | vkFreeMemory(m_device->device(), imageMem, NULL); |
7769 | vkDestroyImage(m_device->device(), image, NULL); | ||||
7770 | vkDestroyImageView(m_device->device(), view, NULL); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7771 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 7772 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7773 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7774 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7775 | m_errorMonitor->SetDesiredFailureMsg( |
7776 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7777 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7778 | |
7779 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7780 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7781 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7782 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7783 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7784 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7785 | } |
7786 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7787 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
7788 | VkResult err; | ||||
7789 | VkCommandBuffer draw_cmd; | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7790 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7791 | m_errorMonitor->SetDesiredFailureMsg( |
7792 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 7793 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7794 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 7795 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 7796 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7797 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7798 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 7799 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7800 | cmd.commandPool = m_commandPool; |
7801 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; | ||||
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7802 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 7803 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7804 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7805 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 7806 | |
7807 | // Force the failure by not setting the Renderpass and Framebuffer fields | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7808 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7809 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7810 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 7811 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7812 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
7813 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; | ||||
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7814 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 7815 | |
7816 | // The error should be caught by validation of the BeginCommandBuffer call | ||||
7817 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); | ||||
7818 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7819 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7820 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 7821 | } |
7822 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7823 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 7824 | // Cause error due to Begin while recording CB |
7825 | // Then cause 2 errors for attempting to reset CB w/o having | ||||
7826 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from | ||||
7827 | // which CBs were allocated. Note that this bit is off by default. | ||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7828 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7829 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 7830 | |
7831 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7832 | |||||
7833 | // Calls AllocateCommandBuffers | ||||
7834 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); | ||||
7835 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7836 | // Force the failure by setting the Renderpass and Framebuffer fields with |
7837 | // (fake) data | ||||
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 7838 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7839 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 7840 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
7841 | cmd_buf_info.pNext = NULL; | ||||
7842 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; | ||||
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7843 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 7844 | |
7845 | // Begin CB to transition to recording state | ||||
7846 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); | ||||
7847 | // Can't re-begin. This should trigger error | ||||
7848 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7849 | m_errorMonitor->VerifyFound(); |
7850 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7851 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
7852 | "Attempt to reset command buffer "); | ||||
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 7853 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
7854 | // Reset attempt will trigger error due to incorrect CommandPool state | ||||
7855 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7856 | m_errorMonitor->VerifyFound(); |
7857 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7858 | m_errorMonitor->SetDesiredFailureMsg( |
7859 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7860 | " attempts to implicitly reset cmdBuffer created from "); | ||||
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 7861 | // Transition CB to RECORDED state |
7862 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); | ||||
7863 | // Now attempting to Begin will implicitly reset, which triggers error | ||||
7864 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7865 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 7866 | } |
7867 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7868 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7869 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7870 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7871 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7872 | m_errorMonitor->SetDesiredFailureMsg( |
7873 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7874 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
7875 | |||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7876 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7877 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7878 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7879 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7880 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
7881 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7882 | |
7883 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7884 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
7885 | ds_pool_ci.pNext = NULL; | ||||
7886 | ds_pool_ci.maxSets = 1; | ||||
7887 | ds_pool_ci.poolSizeCount = 1; | ||||
7888 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7889 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7890 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7891 | err = |
7892 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7893 | ASSERT_VK_SUCCESS(err); |
7894 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7895 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7896 | dsl_binding.binding = 0; |
7897 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
7898 | dsl_binding.descriptorCount = 1; | ||||
7899 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
7900 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7901 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7902 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7903 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
7904 | ds_layout_ci.pNext = NULL; | ||||
7905 | ds_layout_ci.bindingCount = 1; | ||||
7906 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7907 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7908 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7909 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
7910 | &ds_layout); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7911 | ASSERT_VK_SUCCESS(err); |
7912 | |||||
7913 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7914 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7915 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7916 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7917 | alloc_info.descriptorPool = ds_pool; |
7918 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7919 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
7920 | &descriptorSet); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7921 | ASSERT_VK_SUCCESS(err); |
7922 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7923 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7924 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
7925 | pipeline_layout_ci.setLayoutCount = 1; | ||||
7926 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7927 | |
7928 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7929 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7930 | &pipeline_layout); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7931 | ASSERT_VK_SUCCESS(err); |
7932 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7933 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7934 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7935 | |
7936 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7937 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
7938 | vp_state_ci.scissorCount = 1; | ||||
7939 | vp_state_ci.pScissors = ≻ | ||||
7940 | vp_state_ci.viewportCount = 1; | ||||
7941 | vp_state_ci.pViewports = &vp; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 7942 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7943 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
7944 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
7945 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; | ||||
7946 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; | ||||
7947 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; | ||||
7948 | rs_state_ci.depthClampEnable = VK_FALSE; | ||||
7949 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; | ||||
7950 | rs_state_ci.depthBiasEnable = VK_FALSE; | ||||
7951 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7952 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7953 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
7954 | gp_ci.pViewportState = &vp_state_ci; | ||||
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 7955 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7956 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
7957 | gp_ci.layout = pipeline_layout; | ||||
7958 | gp_ci.renderPass = renderPass(); | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7959 | |
7960 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7961 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
7962 | pc_ci.initialDataSize = 0; | ||||
7963 | pc_ci.pInitialData = 0; | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7964 | |
7965 | VkPipeline pipeline; | ||||
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 7966 | VkPipelineCache pipelineCache; |
7967 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7968 | err = |
7969 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 7970 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7971 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
7972 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7973 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7974 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7975 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7976 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
7977 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
7978 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
7979 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7980 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7981 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
7982 | TEST_F(VkLayerTest, InvalidPatchControlPoints) | ||||
7983 | { | ||||
7984 | // Attempt to Create Gfx Pipeline w/o a VS | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7985 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7986 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7987 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7988 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
7989 | primitive "); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7990 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7991 | ASSERT_NO_FATAL_FAILURE(InitState()); |
7992 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7993 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7994 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7995 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7996 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 7997 | |
7998 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
7999 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
8000 | ds_pool_ci.pNext = NULL; | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8001 | ds_pool_ci.poolSizeCount = 1; |
8002 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8003 | |
8004 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8005 | err = vkCreateDescriptorPool(m_device->device(), |
8006 | 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] | 8007 | ASSERT_VK_SUCCESS(err); |
8008 | |||||
8009 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8010 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8011 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 8012 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8013 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
8014 | dsl_binding.pImmutableSamplers = NULL; | ||||
8015 | |||||
8016 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8017 | ds_layout_ci.sType = |
8018 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8019 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8020 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 8021 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8022 | |
8023 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8024 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8025 | &ds_layout); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8026 | ASSERT_VK_SUCCESS(err); |
8027 | |||||
8028 | VkDescriptorSet descriptorSet; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8029 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
8030 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8031 | ASSERT_VK_SUCCESS(err); |
8032 | |||||
8033 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8034 | pipeline_layout_ci.sType = |
8035 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8036 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8037 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8038 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
8039 | |||||
8040 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8041 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8042 | &pipeline_layout); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8043 | ASSERT_VK_SUCCESS(err); |
8044 | |||||
8045 | VkPipelineShaderStageCreateInfo shaderStages[3]; | ||||
8046 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); | ||||
8047 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8048 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
8049 | this); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8050 | // Just using VS txt for Tess shaders as we don't care about functionality |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8051 | VkShaderObj |
8052 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, | ||||
8053 | this); | ||||
8054 | VkShaderObj | ||||
8055 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, | ||||
8056 | this); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8057 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8058 | shaderStages[0].sType = |
8059 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; | ||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8060 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8061 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8062 | shaderStages[1].sType = |
8063 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; | ||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8064 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8065 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8066 | shaderStages[2].sType = |
8067 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; | ||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8068 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8069 | shaderStages[2].shader = te.handle(); |
8070 | |||||
8071 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8072 | iaCI.sType = |
8073 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8074 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8075 | |
8076 | VkPipelineTessellationStateCreateInfo tsCI = {}; | ||||
8077 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; | ||||
8078 | tsCI.patchControlPoints = 0; // This will cause an error | ||||
8079 | |||||
8080 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
8081 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; | ||||
8082 | gp_ci.pNext = NULL; | ||||
8083 | gp_ci.stageCount = 3; | ||||
8084 | gp_ci.pStages = shaderStages; | ||||
8085 | gp_ci.pVertexInputState = NULL; | ||||
8086 | gp_ci.pInputAssemblyState = &iaCI; | ||||
8087 | gp_ci.pTessellationState = &tsCI; | ||||
8088 | gp_ci.pViewportState = NULL; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8089 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8090 | gp_ci.pMultisampleState = NULL; |
8091 | gp_ci.pDepthStencilState = NULL; | ||||
8092 | gp_ci.pColorBlendState = NULL; | ||||
8093 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
8094 | gp_ci.layout = pipeline_layout; | ||||
8095 | gp_ci.renderPass = renderPass(); | ||||
8096 | |||||
8097 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
8098 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; | ||||
8099 | pc_ci.pNext = NULL; | ||||
8100 | pc_ci.initialSize = 0; | ||||
8101 | pc_ci.initialData = 0; | ||||
8102 | pc_ci.maxSize = 0; | ||||
8103 | |||||
8104 | VkPipeline pipeline; | ||||
8105 | VkPipelineCache pipelineCache; | ||||
8106 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8107 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
8108 | &pipelineCache); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8109 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8110 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
8111 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8112 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8113 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8114 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8115 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
8116 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
8117 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8118 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8119 | } |
8120 | */ | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8121 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8122 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8123 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8124 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8125 | m_errorMonitor->SetDesiredFailureMsg( |
8126 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8127 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
8128 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8129 | ASSERT_NO_FATAL_FAILURE(InitState()); |
8130 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8131 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8132 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8133 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
8134 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8135 | |
8136 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8137 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8138 | ds_pool_ci.maxSets = 1; | ||||
8139 | ds_pool_ci.poolSizeCount = 1; | ||||
8140 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8141 | |
8142 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8143 | err = |
8144 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8145 | ASSERT_VK_SUCCESS(err); |
8146 | |||||
8147 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8148 | dsl_binding.binding = 0; |
8149 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8150 | dsl_binding.descriptorCount = 1; | ||||
8151 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8152 | |
8153 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8154 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
8155 | ds_layout_ci.bindingCount = 1; | ||||
8156 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8157 | |
8158 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8159 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8160 | &ds_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8161 | ASSERT_VK_SUCCESS(err); |
8162 | |||||
8163 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8164 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8165 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8166 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8167 | alloc_info.descriptorPool = ds_pool; |
8168 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8169 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
8170 | &descriptorSet); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8171 | ASSERT_VK_SUCCESS(err); |
8172 | |||||
8173 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8174 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
8175 | pipeline_layout_ci.setLayoutCount = 1; | ||||
8176 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8177 | |
8178 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8179 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8180 | &pipeline_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8181 | ASSERT_VK_SUCCESS(err); |
8182 | |||||
8183 | VkViewport vp = {}; // Just need dummy vp to point to | ||||
8184 | |||||
8185 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8186 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
8187 | vp_state_ci.scissorCount = 0; | ||||
8188 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error | ||||
8189 | vp_state_ci.pViewports = &vp; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8190 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 8191 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
8192 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
8193 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; | ||||
8194 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; | ||||
8195 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; | ||||
8196 | rs_state_ci.depthClampEnable = VK_FALSE; | ||||
8197 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; | ||||
8198 | rs_state_ci.depthBiasEnable = VK_FALSE; | ||||
8199 | |||||
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 8200 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8201 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8202 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8203 | VkShaderObj vs(m_device, bindStateVertShaderText, |
8204 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
8205 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
8206 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8207 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8208 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8209 | shaderStages[0] = vs.GetStageCreateInfo(); |
8210 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8211 | |
8212 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8213 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
8214 | gp_ci.stageCount = 2; | ||||
8215 | gp_ci.pStages = shaderStages; | ||||
8216 | gp_ci.pViewportState = &vp_state_ci; | ||||
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 8217 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8218 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
8219 | gp_ci.layout = pipeline_layout; | ||||
8220 | gp_ci.renderPass = renderPass(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8221 | |
8222 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8223 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8224 | |
8225 | VkPipeline pipeline; | ||||
8226 | VkPipelineCache pipelineCache; | ||||
8227 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8228 | err = |
8229 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8230 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8231 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
8232 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8233 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8234 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8235 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8236 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
8237 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
8238 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8239 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8240 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8241 | // Don't set viewport state in PSO. This is an error b/c we always need this |
8242 | // state | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8243 | // for the counts even if the data is going to be set dynamically. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8244 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8245 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8246 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8247 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8248 | m_errorMonitor->SetDesiredFailureMsg( |
8249 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8250 | "Gfx Pipeline pViewportState is null. Even if "); |
8251 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8252 | ASSERT_NO_FATAL_FAILURE(InitState()); |
8253 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8254 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8255 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8256 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
8257 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8258 | |
8259 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8260 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8261 | ds_pool_ci.maxSets = 1; | ||||
8262 | ds_pool_ci.poolSizeCount = 1; | ||||
8263 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8264 | |
8265 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8266 | err = |
8267 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8268 | ASSERT_VK_SUCCESS(err); |
8269 | |||||
8270 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8271 | dsl_binding.binding = 0; |
8272 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8273 | dsl_binding.descriptorCount = 1; | ||||
8274 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8275 | |
8276 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8277 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
8278 | ds_layout_ci.bindingCount = 1; | ||||
8279 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8280 | |
8281 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8282 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8283 | &ds_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8284 | ASSERT_VK_SUCCESS(err); |
8285 | |||||
8286 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8287 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8288 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8289 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8290 | alloc_info.descriptorPool = ds_pool; |
8291 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8292 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
8293 | &descriptorSet); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8294 | ASSERT_VK_SUCCESS(err); |
8295 | |||||
8296 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8297 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
8298 | pipeline_layout_ci.setLayoutCount = 1; | ||||
8299 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8300 | |
8301 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8302 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8303 | &pipeline_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8304 | ASSERT_VK_SUCCESS(err); |
8305 | |||||
8306 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; | ||||
8307 | // Set scissor as dynamic to avoid second error | ||||
8308 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8309 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
8310 | dyn_state_ci.dynamicStateCount = 1; | ||||
8311 | dyn_state_ci.pDynamicStates = &sc_state; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8312 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 8313 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8314 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8315 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8316 | VkShaderObj vs(m_device, bindStateVertShaderText, |
8317 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
8318 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
8319 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8320 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8321 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8322 | shaderStages[0] = vs.GetStageCreateInfo(); |
8323 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8324 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 8325 | |
8326 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; | ||||
8327 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
8328 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; | ||||
8329 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; | ||||
8330 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; | ||||
8331 | rs_state_ci.depthClampEnable = VK_FALSE; | ||||
8332 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; | ||||
8333 | rs_state_ci.depthBiasEnable = VK_FALSE; | ||||
8334 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8335 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8336 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
8337 | gp_ci.stageCount = 2; | ||||
8338 | gp_ci.pStages = shaderStages; | ||||
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 8339 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8340 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
8341 | // should cause validation error | ||||
8342 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
8343 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
8344 | gp_ci.layout = pipeline_layout; | ||||
8345 | gp_ci.renderPass = renderPass(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8346 | |
8347 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8348 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8349 | |
8350 | VkPipeline pipeline; | ||||
8351 | VkPipelineCache pipelineCache; | ||||
8352 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8353 | err = |
8354 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8355 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8356 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
8357 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8358 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8359 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8360 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8361 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
8362 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
8363 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8364 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8365 | } |
8366 | // Create PSO w/o non-zero viewportCount but no viewport data | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8367 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
8368 | // count | ||||
8369 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { | ||||
8370 | VkResult err; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8371 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8372 | m_errorMonitor->SetDesiredFailureMsg( |
8373 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8374 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
8375 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8376 | ASSERT_NO_FATAL_FAILURE(InitState()); |
8377 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8378 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8379 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8380 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
8381 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8382 | |
8383 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8384 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8385 | ds_pool_ci.maxSets = 1; | ||||
8386 | ds_pool_ci.poolSizeCount = 1; | ||||
8387 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8388 | |
8389 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8390 | err = |
8391 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8392 | ASSERT_VK_SUCCESS(err); |
8393 | |||||
8394 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8395 | dsl_binding.binding = 0; |
8396 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8397 | dsl_binding.descriptorCount = 1; | ||||
8398 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8399 | |
8400 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8401 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
8402 | ds_layout_ci.bindingCount = 1; | ||||
8403 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8404 | |
8405 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8406 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8407 | &ds_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8408 | ASSERT_VK_SUCCESS(err); |
8409 | |||||
8410 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8411 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8412 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8413 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8414 | alloc_info.descriptorPool = ds_pool; |
8415 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8416 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
8417 | &descriptorSet); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8418 | ASSERT_VK_SUCCESS(err); |
8419 | |||||
8420 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8421 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
8422 | pipeline_layout_ci.setLayoutCount = 1; | ||||
8423 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8424 | |
8425 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8426 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8427 | &pipeline_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8428 | ASSERT_VK_SUCCESS(err); |
8429 | |||||
8430 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8431 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
8432 | vp_state_ci.viewportCount = 1; | ||||
8433 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error | ||||
8434 | vp_state_ci.scissorCount = 1; | ||||
8435 | vp_state_ci.pScissors = | ||||
8436 | NULL; // Scissor is dynamic (below) so this won't cause error | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8437 | |
8438 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; | ||||
8439 | // Set scissor as dynamic to avoid that error | ||||
8440 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8441 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
8442 | dyn_state_ci.dynamicStateCount = 1; | ||||
8443 | dyn_state_ci.pDynamicStates = &sc_state; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8444 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 8445 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8446 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8447 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8448 | VkShaderObj vs(m_device, bindStateVertShaderText, |
8449 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
8450 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
8451 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8452 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8453 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8454 | shaderStages[0] = vs.GetStageCreateInfo(); |
8455 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8456 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 8457 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
8458 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; | ||||
8459 | vi_ci.pNext = nullptr; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8460 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 8461 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8462 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 8463 | vi_ci.pVertexAttributeDescriptions = nullptr; |
8464 | |||||
8465 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; | ||||
8466 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
8467 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; | ||||
8468 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8469 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8470 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 8471 | rs_ci.pNext = nullptr; |
8472 | |||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8473 | VkPipelineColorBlendAttachmentState att = {}; |
8474 | att.blendEnable = VK_FALSE; | ||||
8475 | att.colorWriteMask = 0xf; | ||||
8476 | |||||
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 8477 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
8478 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; | ||||
8479 | cb_ci.pNext = nullptr; | ||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8480 | cb_ci.attachmentCount = 1; |
8481 | cb_ci.pAttachments = &att; | ||||
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 8482 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8483 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8484 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
8485 | gp_ci.stageCount = 2; | ||||
8486 | gp_ci.pStages = shaderStages; | ||||
8487 | gp_ci.pVertexInputState = &vi_ci; | ||||
8488 | gp_ci.pInputAssemblyState = &ia_ci; | ||||
8489 | gp_ci.pViewportState = &vp_state_ci; | ||||
8490 | gp_ci.pRasterizationState = &rs_ci; | ||||
8491 | gp_ci.pColorBlendState = &cb_ci; | ||||
8492 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
8493 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
8494 | gp_ci.layout = pipeline_layout; | ||||
8495 | gp_ci.renderPass = renderPass(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8496 | |
8497 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8498 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8499 | |
8500 | VkPipeline pipeline; | ||||
8501 | VkPipelineCache pipelineCache; | ||||
8502 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8503 | err = |
8504 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8505 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8506 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
8507 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8508 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8509 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8510 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8511 | // Now hit second fail case where we set scissor w/ different count than PSO |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8512 | // First need to successfully create the PSO from above by setting |
8513 | // pViewports | ||||
8514 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8515 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8516 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " | ||||
8517 | "scissorCount is 1. These counts must match."); | ||||
8518 | |||||
8519 | VkViewport vp = {}; // Just need dummy vp to point to | ||||
8520 | vp_state_ci.pViewports = &vp; | ||||
8521 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
8522 | &gp_ci, NULL, &pipeline); | ||||
8523 | ASSERT_VK_SUCCESS(err); | ||||
8524 | BeginCommandBuffer(); | ||||
8525 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
8526 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); | ||||
8527 | VkRect2D scissors[2] = {}; // don't care about data | ||||
8528 | // Count of 2 doesn't match PSO count of 1 | ||||
8529 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); | ||||
8530 | Draw(1, 0, 0, 0); | ||||
8531 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8532 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8533 | |
8534 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); | ||||
8535 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
8536 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8537 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8538 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8539 | } |
8540 | // Create PSO w/o non-zero scissorCount but no scissor data | ||||
8541 | // Then run second test where dynamic viewportCount doesn't match PSO | ||||
8542 | // viewportCount | ||||
8543 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { | ||||
8544 | VkResult err; | ||||
8545 | |||||
8546 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8547 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8548 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); | ||||
8549 | |||||
8550 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
8551 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
8552 | |||||
8553 | VkDescriptorPoolSize ds_type_count = {}; | ||||
8554 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8555 | ds_type_count.descriptorCount = 1; | ||||
8556 | |||||
8557 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
8558 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
8559 | ds_pool_ci.maxSets = 1; | ||||
8560 | ds_pool_ci.poolSizeCount = 1; | ||||
8561 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
8562 | |||||
8563 | VkDescriptorPool ds_pool; | ||||
8564 | err = | ||||
8565 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
8566 | ASSERT_VK_SUCCESS(err); | ||||
8567 | |||||
8568 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
8569 | dsl_binding.binding = 0; | ||||
8570 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8571 | dsl_binding.descriptorCount = 1; | ||||
8572 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
8573 | |||||
8574 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
8575 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
8576 | ds_layout_ci.bindingCount = 1; | ||||
8577 | ds_layout_ci.pBindings = &dsl_binding; | ||||
8578 | |||||
8579 | VkDescriptorSetLayout ds_layout; | ||||
8580 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
8581 | &ds_layout); | ||||
8582 | ASSERT_VK_SUCCESS(err); | ||||
8583 | |||||
8584 | VkDescriptorSet descriptorSet; | ||||
8585 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
8586 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
8587 | alloc_info.descriptorSetCount = 1; | ||||
8588 | alloc_info.descriptorPool = ds_pool; | ||||
8589 | alloc_info.pSetLayouts = &ds_layout; | ||||
8590 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
8591 | &descriptorSet); | ||||
8592 | ASSERT_VK_SUCCESS(err); | ||||
8593 | |||||
8594 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
8595 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
8596 | pipeline_layout_ci.setLayoutCount = 1; | ||||
8597 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
8598 | |||||
8599 | VkPipelineLayout pipeline_layout; | ||||
8600 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
8601 | &pipeline_layout); | ||||
8602 | ASSERT_VK_SUCCESS(err); | ||||
8603 | |||||
8604 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
8605 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; | ||||
8606 | vp_state_ci.scissorCount = 1; | ||||
8607 | vp_state_ci.pScissors = | ||||
8608 | NULL; // Null scissor w/ count of 1 should cause error | ||||
8609 | vp_state_ci.viewportCount = 1; | ||||
8610 | vp_state_ci.pViewports = | ||||
8611 | NULL; // vp is dynamic (below) so this won't cause error | ||||
8612 | |||||
8613 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; | ||||
8614 | // Set scissor as dynamic to avoid that error | ||||
8615 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
8616 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; | ||||
8617 | dyn_state_ci.dynamicStateCount = 1; | ||||
8618 | dyn_state_ci.pDynamicStates = &vp_state; | ||||
8619 | |||||
8620 | VkPipelineShaderStageCreateInfo shaderStages[2]; | ||||
8621 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); | ||||
8622 | |||||
8623 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
8624 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
8625 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
8626 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8627 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8628 | // but add it to be able to run on more devices |
8629 | shaderStages[0] = vs.GetStageCreateInfo(); | ||||
8630 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
8631 | |||||
8632 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; | ||||
8633 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; | ||||
8634 | vi_ci.pNext = nullptr; | ||||
8635 | vi_ci.vertexBindingDescriptionCount = 0; | ||||
8636 | vi_ci.pVertexBindingDescriptions = nullptr; | ||||
8637 | vi_ci.vertexAttributeDescriptionCount = 0; | ||||
8638 | vi_ci.pVertexAttributeDescriptions = nullptr; | ||||
8639 | |||||
8640 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; | ||||
8641 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
8642 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; | ||||
8643 | |||||
8644 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; | ||||
8645 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
8646 | rs_ci.pNext = nullptr; | ||||
8647 | |||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8648 | VkPipelineColorBlendAttachmentState att = {}; |
8649 | att.blendEnable = VK_FALSE; | ||||
8650 | att.colorWriteMask = 0xf; | ||||
8651 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8652 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
8653 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; | ||||
8654 | cb_ci.pNext = nullptr; | ||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8655 | cb_ci.attachmentCount = 1; |
8656 | cb_ci.pAttachments = &att; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8657 | |
8658 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
8659 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; | ||||
8660 | gp_ci.stageCount = 2; | ||||
8661 | gp_ci.pStages = shaderStages; | ||||
8662 | gp_ci.pVertexInputState = &vi_ci; | ||||
8663 | gp_ci.pInputAssemblyState = &ia_ci; | ||||
8664 | gp_ci.pViewportState = &vp_state_ci; | ||||
8665 | gp_ci.pRasterizationState = &rs_ci; | ||||
8666 | gp_ci.pColorBlendState = &cb_ci; | ||||
8667 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
8668 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
8669 | gp_ci.layout = pipeline_layout; | ||||
8670 | gp_ci.renderPass = renderPass(); | ||||
8671 | |||||
8672 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
8673 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; | ||||
8674 | |||||
8675 | VkPipeline pipeline; | ||||
8676 | VkPipelineCache pipelineCache; | ||||
8677 | |||||
8678 | err = | ||||
8679 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
8680 | ASSERT_VK_SUCCESS(err); | ||||
8681 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
8682 | &gp_ci, NULL, &pipeline); | ||||
8683 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8684 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8685 | |
8686 | // Now hit second fail case where we set scissor w/ different count than PSO | ||||
8687 | // First need to successfully create the PSO from above by setting | ||||
8688 | // pViewports | ||||
8689 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8690 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8691 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " | ||||
8692 | "viewportCount is 1. These counts must match."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8693 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8694 | VkRect2D sc = {}; // Just need dummy vp to point to |
8695 | vp_state_ci.pScissors = ≻ | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8696 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
8697 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8698 | ASSERT_VK_SUCCESS(err); |
8699 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8700 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
8701 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8702 | VkViewport viewports[2] = {}; // don't care about data |
8703 | // Count of 2 doesn't match PSO count of 1 | ||||
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 8704 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8705 | Draw(1, 0, 0, 0); |
8706 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8707 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8708 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8709 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
8710 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
8711 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8712 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8713 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8714 | } |
8715 | |||||
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 8716 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
8717 | VkResult err; | ||||
8718 | |||||
8719 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 8720 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 8721 | |
8722 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
8723 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
8724 | |||||
8725 | VkDescriptorPoolSize ds_type_count = {}; | ||||
8726 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8727 | ds_type_count.descriptorCount = 1; | ||||
8728 | |||||
8729 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
8730 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
8731 | ds_pool_ci.maxSets = 1; | ||||
8732 | ds_pool_ci.poolSizeCount = 1; | ||||
8733 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
8734 | |||||
8735 | VkDescriptorPool ds_pool; | ||||
8736 | err = | ||||
8737 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
8738 | ASSERT_VK_SUCCESS(err); | ||||
8739 | |||||
8740 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
8741 | dsl_binding.binding = 0; | ||||
8742 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8743 | dsl_binding.descriptorCount = 1; | ||||
8744 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
8745 | |||||
8746 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
8747 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
8748 | ds_layout_ci.bindingCount = 1; | ||||
8749 | ds_layout_ci.pBindings = &dsl_binding; | ||||
8750 | |||||
8751 | VkDescriptorSetLayout ds_layout; | ||||
8752 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
8753 | &ds_layout); | ||||
8754 | ASSERT_VK_SUCCESS(err); | ||||
8755 | |||||
8756 | VkDescriptorSet descriptorSet; | ||||
8757 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
8758 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
8759 | alloc_info.descriptorSetCount = 1; | ||||
8760 | alloc_info.descriptorPool = ds_pool; | ||||
8761 | alloc_info.pSetLayouts = &ds_layout; | ||||
8762 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
8763 | &descriptorSet); | ||||
8764 | ASSERT_VK_SUCCESS(err); | ||||
8765 | |||||
8766 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
8767 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
8768 | pipeline_layout_ci.setLayoutCount = 1; | ||||
8769 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
8770 | |||||
8771 | VkPipelineLayout pipeline_layout; | ||||
8772 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
8773 | &pipeline_layout); | ||||
8774 | ASSERT_VK_SUCCESS(err); | ||||
8775 | |||||
8776 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
8777 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; | ||||
8778 | vp_state_ci.scissorCount = 1; | ||||
8779 | vp_state_ci.pScissors = NULL; | ||||
8780 | vp_state_ci.viewportCount = 1; | ||||
8781 | vp_state_ci.pViewports = NULL; | ||||
8782 | |||||
8783 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, | ||||
8784 | VK_DYNAMIC_STATE_SCISSOR, | ||||
8785 | VK_DYNAMIC_STATE_LINE_WIDTH}; | ||||
8786 | // Set scissor as dynamic to avoid that error | ||||
8787 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
8788 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; | ||||
8789 | dyn_state_ci.dynamicStateCount = 2; | ||||
8790 | dyn_state_ci.pDynamicStates = dynamic_states; | ||||
8791 | |||||
8792 | VkPipelineShaderStageCreateInfo shaderStages[2]; | ||||
8793 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); | ||||
8794 | |||||
8795 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
8796 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
8797 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
8798 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
8799 | this); // TODO - We shouldn't need a fragment shader | ||||
8800 | // but add it to be able to run on more devices | ||||
8801 | shaderStages[0] = vs.GetStageCreateInfo(); | ||||
8802 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
8803 | |||||
8804 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; | ||||
8805 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; | ||||
8806 | vi_ci.pNext = nullptr; | ||||
8807 | vi_ci.vertexBindingDescriptionCount = 0; | ||||
8808 | vi_ci.pVertexBindingDescriptions = nullptr; | ||||
8809 | vi_ci.vertexAttributeDescriptionCount = 0; | ||||
8810 | vi_ci.pVertexAttributeDescriptions = nullptr; | ||||
8811 | |||||
8812 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; | ||||
8813 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
8814 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; | ||||
8815 | |||||
8816 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; | ||||
8817 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
8818 | rs_ci.pNext = nullptr; | ||||
8819 | |||||
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 8820 | // Check too low (line width of -1.0f). |
8821 | rs_ci.lineWidth = -1.0f; | ||||
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 8822 | |
8823 | VkPipelineColorBlendAttachmentState att = {}; | ||||
8824 | att.blendEnable = VK_FALSE; | ||||
8825 | att.colorWriteMask = 0xf; | ||||
8826 | |||||
8827 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; | ||||
8828 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; | ||||
8829 | cb_ci.pNext = nullptr; | ||||
8830 | cb_ci.attachmentCount = 1; | ||||
8831 | cb_ci.pAttachments = &att; | ||||
8832 | |||||
8833 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
8834 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; | ||||
8835 | gp_ci.stageCount = 2; | ||||
8836 | gp_ci.pStages = shaderStages; | ||||
8837 | gp_ci.pVertexInputState = &vi_ci; | ||||
8838 | gp_ci.pInputAssemblyState = &ia_ci; | ||||
8839 | gp_ci.pViewportState = &vp_state_ci; | ||||
8840 | gp_ci.pRasterizationState = &rs_ci; | ||||
8841 | gp_ci.pColorBlendState = &cb_ci; | ||||
8842 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
8843 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
8844 | gp_ci.layout = pipeline_layout; | ||||
8845 | gp_ci.renderPass = renderPass(); | ||||
8846 | |||||
8847 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
8848 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; | ||||
8849 | |||||
8850 | VkPipeline pipeline; | ||||
8851 | VkPipelineCache pipelineCache; | ||||
8852 | |||||
8853 | err = | ||||
8854 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
8855 | ASSERT_VK_SUCCESS(err); | ||||
8856 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
8857 | &gp_ci, NULL, &pipeline); | ||||
8858 | |||||
8859 | m_errorMonitor->VerifyFound(); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8860 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 8861 | |
8862 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8863 | "Attempt to set lineWidth to 65536"); | ||||
8864 | |||||
8865 | // Check too high (line width of 65536.0f). | ||||
8866 | rs_ci.lineWidth = 65536.0f; | ||||
8867 | |||||
8868 | err = | ||||
8869 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
8870 | ASSERT_VK_SUCCESS(err); | ||||
8871 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
8872 | &gp_ci, NULL, &pipeline); | ||||
8873 | |||||
8874 | m_errorMonitor->VerifyFound(); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8875 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 8876 | |
8877 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 8878 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 8879 | |
8880 | dyn_state_ci.dynamicStateCount = 3; | ||||
8881 | |||||
8882 | rs_ci.lineWidth = 1.0f; | ||||
8883 | |||||
8884 | err = | ||||
8885 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
8886 | ASSERT_VK_SUCCESS(err); | ||||
8887 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
8888 | &gp_ci, NULL, &pipeline); | ||||
8889 | BeginCommandBuffer(); | ||||
8890 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
8891 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); | ||||
8892 | |||||
8893 | // Check too low with dynamic setting. | ||||
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 8894 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 8895 | m_errorMonitor->VerifyFound(); |
8896 | |||||
8897 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8898 | "Attempt to set lineWidth to 65536"); | ||||
8899 | |||||
8900 | // Check too high with dynamic setting. | ||||
8901 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); | ||||
8902 | m_errorMonitor->VerifyFound(); | ||||
8903 | EndCommandBuffer(); | ||||
8904 | |||||
8905 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); | ||||
8906 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
8907 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8908 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8909 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 8910 | } |
8911 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8912 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8913 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8914 | m_errorMonitor->SetDesiredFailureMsg( |
8915 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8916 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8917 | |
8918 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
8919 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8920 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8921 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8922 | // Don't care about RenderPass handle b/c error should be flagged before |
8923 | // that | ||||
8924 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, | ||||
8925 | VK_SUBPASS_CONTENTS_INLINE); | ||||
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8926 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8927 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 8928 | } |
8929 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8930 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8931 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8932 | m_errorMonitor->SetDesiredFailureMsg( |
8933 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8934 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8935 | |
8936 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
8937 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8938 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8939 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8940 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
8941 | // proper error | ||||
Chris Forbes | 38ae7c4 | 2016-06-21 20:51:44 +1200 | [diff] [blame] | 8942 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8943 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8944 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8945 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8946 | } |
8947 | |||||
Chris Forbes | 2eeabe3 | 2016-06-21 20:52:34 +1200 | [diff] [blame] | 8948 | TEST_F(VkLayerTest, RenderPassSecondaryCommandBuffersMultipleTimes) { |
8949 | m_errorMonitor->ExpectSuccess(); | ||||
8950 | |||||
8951 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
8952 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
8953 | |||||
8954 | BeginCommandBuffer(); // framework implicitly begins the renderpass. | ||||
8955 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); // end implicit. | ||||
8956 | |||||
8957 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, | ||||
8958 | VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); | ||||
8959 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); | ||||
8960 | m_errorMonitor->VerifyNotFound(); | ||||
8961 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, | ||||
8962 | VK_SUBPASS_CONTENTS_INLINE); | ||||
8963 | m_errorMonitor->VerifyNotFound(); | ||||
8964 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); | ||||
8965 | m_errorMonitor->VerifyNotFound(); | ||||
8966 | |||||
8967 | m_commandBuffer->EndCommandBuffer(); | ||||
8968 | m_errorMonitor->VerifyNotFound(); | ||||
8969 | } | ||||
8970 | |||||
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 8971 | TEST_F(VkLayerTest, RenderPassClearOpMismatch) { |
8972 | TEST_DESCRIPTION("Begin a renderPass where clearValueCount is less than" | ||||
8973 | "the number of renderPass attachments that use loadOp" | ||||
8974 | "VK_ATTACHMENT_LOAD_OP_CLEAR."); | ||||
8975 | |||||
8976 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
8977 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
8978 | |||||
8979 | // Create a renderPass with a single attachment that uses loadOp CLEAR | ||||
8980 | VkAttachmentReference attach = {}; | ||||
8981 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
8982 | VkSubpassDescription subpass = {}; | ||||
8983 | subpass.inputAttachmentCount = 1; | ||||
8984 | subpass.pInputAttachments = &attach; | ||||
8985 | VkRenderPassCreateInfo rpci = {}; | ||||
8986 | rpci.subpassCount = 1; | ||||
8987 | rpci.pSubpasses = &subpass; | ||||
8988 | rpci.attachmentCount = 1; | ||||
8989 | VkAttachmentDescription attach_desc = {}; | ||||
8990 | attach_desc.format = VK_FORMAT_UNDEFINED; | ||||
8991 | // Set loadOp to CLEAR | ||||
8992 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; | ||||
8993 | rpci.pAttachments = &attach_desc; | ||||
8994 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; | ||||
8995 | VkRenderPass rp; | ||||
8996 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
8997 | |||||
8998 | VkCommandBufferInheritanceInfo hinfo = {}; | ||||
8999 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; | ||||
9000 | hinfo.renderPass = VK_NULL_HANDLE; | ||||
9001 | hinfo.subpass = 0; | ||||
9002 | hinfo.framebuffer = VK_NULL_HANDLE; | ||||
9003 | hinfo.occlusionQueryEnable = VK_FALSE; | ||||
9004 | hinfo.queryFlags = 0; | ||||
9005 | hinfo.pipelineStatistics = 0; | ||||
9006 | VkCommandBufferBeginInfo info = {}; | ||||
9007 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; | ||||
9008 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
9009 | info.pInheritanceInfo = &hinfo; | ||||
9010 | |||||
9011 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); | ||||
9012 | VkRenderPassBeginInfo rp_begin = {}; | ||||
9013 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; | ||||
9014 | rp_begin.pNext = NULL; | ||||
9015 | rp_begin.renderPass = renderPass(); | ||||
9016 | rp_begin.framebuffer = framebuffer(); | ||||
9017 | rp_begin.clearValueCount = 0; // Should be 1 | ||||
9018 | |||||
9019 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9020 | " has a clearValueCount of 0 but the " | ||||
9021 | "actual number of attachments in " | ||||
9022 | "renderPass "); | ||||
9023 | |||||
9024 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, | ||||
9025 | VK_SUBPASS_CONTENTS_INLINE); | ||||
9026 | |||||
9027 | m_errorMonitor->VerifyFound(); | ||||
Mark Lobodzinski | 5c70ebd | 2016-06-09 13:45:00 -0600 | [diff] [blame] | 9028 | |
9029 | vkDestroyRenderPass(m_device->device(), rp, NULL); | ||||
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 9030 | } |
9031 | |||||
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 9032 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
9033 | |||||
9034 | TEST_DESCRIPTION("End a command buffer with an active render pass"); | ||||
9035 | |||||
9036 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9037 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9038 | "It is invalid to issue this call inside an active render pass"); | ||||
9039 | |||||
9040 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9041 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9042 | |||||
9043 | // The framework's BeginCommandBuffer calls CreateRenderPass | ||||
9044 | BeginCommandBuffer(); | ||||
9045 | |||||
9046 | // Call directly into vkEndCommandBuffer instead of the | ||||
9047 | // the framework's EndCommandBuffer, which inserts a | ||||
9048 | // vkEndRenderPass | ||||
9049 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); | ||||
9050 | |||||
9051 | m_errorMonitor->VerifyFound(); | ||||
9052 | |||||
9053 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY | ||||
9054 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT | ||||
9055 | } | ||||
9056 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9057 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9058 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9059 | m_errorMonitor->SetDesiredFailureMsg( |
9060 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9061 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9062 | |
9063 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9064 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9065 | |
9066 | // Renderpass is started here | ||||
9067 | BeginCommandBuffer(); | ||||
9068 | |||||
9069 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9070 | vk_testing::Buffer dstBuffer; |
9071 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9072 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9073 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9074 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9075 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9076 | } |
9077 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9078 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9079 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9080 | m_errorMonitor->SetDesiredFailureMsg( |
9081 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9082 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9083 | |
9084 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9085 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9086 | |
9087 | // Renderpass is started here | ||||
9088 | BeginCommandBuffer(); | ||||
9089 | |||||
9090 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9091 | vk_testing::Buffer dstBuffer; |
9092 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9093 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9094 | VkDeviceSize dstOffset = 0; |
9095 | VkDeviceSize dataSize = 1024; | ||||
Karl Schultz | ee34449 | 2016-07-11 15:09:57 -0600 | [diff] [blame] | 9096 | const void *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9097 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9098 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
9099 | dstOffset, dataSize, pData); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9100 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9101 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9102 | } |
9103 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9104 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9105 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9106 | m_errorMonitor->SetDesiredFailureMsg( |
9107 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9108 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9109 | |
9110 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9111 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9112 | |
9113 | // Renderpass is started here | ||||
9114 | BeginCommandBuffer(); | ||||
9115 | |||||
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 9116 | VkClearColorValue clear_color; |
9117 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9118 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
9119 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
9120 | const int32_t tex_width = 32; | ||||
9121 | const int32_t tex_height = 32; | ||||
9122 | VkImageCreateInfo image_create_info = {}; | ||||
9123 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
9124 | image_create_info.pNext = NULL; | ||||
9125 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
9126 | image_create_info.format = tex_format; | ||||
9127 | image_create_info.extent.width = tex_width; | ||||
9128 | image_create_info.extent.height = tex_height; | ||||
9129 | image_create_info.extent.depth = 1; | ||||
9130 | image_create_info.mipLevels = 1; | ||||
9131 | image_create_info.arrayLayers = 1; | ||||
9132 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
9133 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
9134 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9135 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9136 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9137 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
9138 | reqs); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9139 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9140 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
9141 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9142 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9143 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
9144 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9145 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9146 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9147 | } |
9148 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9149 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9150 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9151 | m_errorMonitor->SetDesiredFailureMsg( |
9152 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9153 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9154 | |
9155 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9156 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9157 | |
9158 | // Renderpass is started here | ||||
9159 | BeginCommandBuffer(); | ||||
9160 | |||||
9161 | VkClearDepthStencilValue clear_value = {0}; | ||||
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 9162 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9163 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
9164 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
9165 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
9166 | image_create_info.extent.width = 64; | ||||
9167 | image_create_info.extent.height = 64; | ||||
9168 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
9169 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9170 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9171 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9172 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
9173 | reqs); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9174 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9175 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
9176 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9177 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9178 | vkCmdClearDepthStencilImage( |
9179 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), | ||||
9180 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, | ||||
9181 | &range); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9182 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9183 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9184 | } |
9185 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9186 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 9187 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9188 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9189 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9190 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9191 | "vkCmdClearAttachments: This call " |
9192 | "must be issued inside an active " | ||||
9193 | "render pass"); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9194 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9195 | ASSERT_NO_FATAL_FAILURE(InitState()); |
9196 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9197 | |
9198 | // Start no RenderPass | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9199 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9200 | ASSERT_VK_SUCCESS(err); |
9201 | |||||
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 9202 | VkClearAttachment color_attachment; |
9203 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
9204 | color_attachment.clearValue.color.float32[0] = 0; | ||||
9205 | color_attachment.clearValue.color.float32[1] = 0; | ||||
9206 | color_attachment.clearValue.color.float32[2] = 0; | ||||
9207 | color_attachment.clearValue.color.float32[3] = 0; | ||||
9208 | color_attachment.colorAttachment = 0; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9209 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
9210 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, | ||||
9211 | &color_attachment, 1, &clear_rect); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9212 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9213 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9214 | } |
9215 | |||||
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 9216 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
9217 | // Try to add a buffer memory barrier with no buffer. | ||||
9218 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9219 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9220 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); | ||||
9221 | |||||
9222 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9223 | BeginCommandBuffer(); | ||||
9224 | |||||
9225 | VkBufferMemoryBarrier buf_barrier = {}; | ||||
9226 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; | ||||
9227 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
9228 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
9229 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
9230 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
9231 | buf_barrier.buffer = VK_NULL_HANDLE; | ||||
9232 | buf_barrier.offset = 0; | ||||
9233 | buf_barrier.size = VK_WHOLE_SIZE; | ||||
9234 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
9235 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, | ||||
9236 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); | ||||
9237 | |||||
9238 | m_errorMonitor->VerifyFound(); | ||||
9239 | } | ||||
9240 | |||||
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 9241 | TEST_F(VkLayerTest, InvalidBarriers) { |
9242 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); | ||||
9243 | |||||
9244 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9245 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); | ||||
9246 | |||||
9247 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9248 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9249 | |||||
9250 | VkMemoryBarrier mem_barrier = {}; | ||||
9251 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; | ||||
9252 | mem_barrier.pNext = NULL; | ||||
9253 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
9254 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
9255 | BeginCommandBuffer(); | ||||
9256 | // BeginCommandBuffer() starts a render pass | ||||
9257 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
9258 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
9259 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, | ||||
9260 | &mem_barrier, 0, nullptr, 0, nullptr); | ||||
9261 | m_errorMonitor->VerifyFound(); | ||||
9262 | |||||
9263 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9264 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9265 | "Image Layout cannot be transitioned to UNDEFINED"); | ||||
9266 | VkImageObj image(m_device); | ||||
9267 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
9268 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); | ||||
9269 | ASSERT_TRUE(image.initialized()); | ||||
9270 | VkImageMemoryBarrier img_barrier = {}; | ||||
9271 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; | ||||
9272 | img_barrier.pNext = NULL; | ||||
9273 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
9274 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
9275 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
9276 | // New layout can't be UNDEFINED | ||||
9277 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; | ||||
9278 | img_barrier.image = image.handle(); | ||||
9279 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
9280 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
9281 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
9282 | img_barrier.subresourceRange.baseArrayLayer = 0; | ||||
9283 | img_barrier.subresourceRange.baseMipLevel = 0; | ||||
9284 | img_barrier.subresourceRange.layerCount = 1; | ||||
9285 | img_barrier.subresourceRange.levelCount = 1; | ||||
9286 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
9287 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
9288 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
9289 | nullptr, 1, &img_barrier); | ||||
9290 | m_errorMonitor->VerifyFound(); | ||||
9291 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
9292 | |||||
9293 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9294 | "Subresource must have the sum of the " | ||||
9295 | "baseArrayLayer"); | ||||
9296 | // baseArrayLayer + layerCount must be <= image's arrayLayers | ||||
9297 | img_barrier.subresourceRange.baseArrayLayer = 1; | ||||
9298 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
9299 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
9300 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
9301 | nullptr, 1, &img_barrier); | ||||
9302 | m_errorMonitor->VerifyFound(); | ||||
9303 | img_barrier.subresourceRange.baseArrayLayer = 0; | ||||
9304 | |||||
9305 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9306 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9307 | "Subresource must have the sum of the baseMipLevel"); | ||||
9308 | // baseMipLevel + levelCount must be <= image's mipLevels | ||||
9309 | img_barrier.subresourceRange.baseMipLevel = 1; | ||||
9310 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
9311 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
9312 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
9313 | nullptr, 1, &img_barrier); | ||||
9314 | m_errorMonitor->VerifyFound(); | ||||
9315 | img_barrier.subresourceRange.baseMipLevel = 0; | ||||
9316 | |||||
9317 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9318 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9319 | "Buffer Barriers cannot be used during a render pass"); | ||||
9320 | vk_testing::Buffer buffer; | ||||
9321 | buffer.init(*m_device, 256); | ||||
9322 | VkBufferMemoryBarrier buf_barrier = {}; | ||||
9323 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; | ||||
9324 | buf_barrier.pNext = NULL; | ||||
9325 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
9326 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
9327 | buf_barrier.buffer = buffer.handle(); | ||||
9328 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
9329 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
9330 | buf_barrier.offset = 0; | ||||
9331 | buf_barrier.size = VK_WHOLE_SIZE; | ||||
9332 | // Can't send buffer barrier during a render pass | ||||
9333 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
9334 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
9335 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, | ||||
9336 | &buf_barrier, 0, nullptr); | ||||
9337 | m_errorMonitor->VerifyFound(); | ||||
9338 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); | ||||
9339 | |||||
9340 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9341 | "which is not less than total size"); | ||||
9342 | buf_barrier.offset = 257; | ||||
9343 | // Offset greater than total size | ||||
9344 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
9345 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
9346 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, | ||||
9347 | &buf_barrier, 0, nullptr); | ||||
9348 | m_errorMonitor->VerifyFound(); | ||||
9349 | buf_barrier.offset = 0; | ||||
9350 | |||||
9351 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9352 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); | ||||
9353 | buf_barrier.size = 257; | ||||
9354 | // Size greater than total size | ||||
9355 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
9356 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
9357 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, | ||||
9358 | &buf_barrier, 0, nullptr); | ||||
9359 | m_errorMonitor->VerifyFound(); | ||||
9360 | buf_barrier.size = VK_WHOLE_SIZE; | ||||
9361 | |||||
9362 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9363 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9364 | "Image is a depth and stencil format and thus must " | ||||
9365 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " | ||||
9366 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); | ||||
9367 | VkDepthStencilObj ds_image(m_device); | ||||
9368 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); | ||||
9369 | ASSERT_TRUE(ds_image.initialized()); | ||||
9370 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
9371 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
9372 | img_barrier.image = ds_image.handle(); | ||||
9373 | // Leave aspectMask at COLOR on purpose | ||||
9374 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
9375 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
9376 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
9377 | nullptr, 1, &img_barrier); | ||||
9378 | m_errorMonitor->VerifyFound(); | ||||
9379 | } | ||||
9380 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9381 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 9382 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9383 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 9384 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9385 | m_errorMonitor->SetDesiredFailureMsg( |
9386 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9387 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
9388 | |||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 9389 | ASSERT_NO_FATAL_FAILURE(InitState()); |
9390 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 9391 | uint32_t qfi = 0; |
9392 | VkBufferCreateInfo buffCI = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9393 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
9394 | buffCI.size = 1024; | ||||
9395 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; | ||||
9396 | buffCI.queueFamilyIndexCount = 1; | ||||
9397 | buffCI.pQueueFamilyIndices = &qfi; | ||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 9398 | |
9399 | VkBuffer ib; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9400 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 9401 | ASSERT_VK_SUCCESS(err); |
9402 | |||||
9403 | BeginCommandBuffer(); | ||||
9404 | ASSERT_VK_SUCCESS(err); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9405 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
9406 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 9407 | // Should error before calling to driver so don't care about actual data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9408 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
9409 | VK_INDEX_TYPE_UINT16); | ||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 9410 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9411 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9412 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9413 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 9414 | } |
9415 | |||||
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 9416 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
9417 | // Create an out-of-range queueFamilyIndex | ||||
9418 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9419 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 9420 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
9421 | "of the indices specified when the device was created, via the " | ||||
9422 | "VkDeviceQueueCreateInfo structure."); | ||||
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 9423 | |
9424 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9425 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9426 | VkBufferCreateInfo buffCI = {}; | ||||
9427 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
9428 | buffCI.size = 1024; | ||||
9429 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; | ||||
9430 | buffCI.queueFamilyIndexCount = 1; | ||||
9431 | // Introduce failure by specifying invalid queue_family_index | ||||
9432 | uint32_t qfi = 777; | ||||
9433 | buffCI.pQueueFamilyIndices = &qfi; | ||||
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 9434 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 9435 | |
9436 | VkBuffer ib; | ||||
9437 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); | ||||
9438 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9439 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 9440 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 9441 | } |
9442 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9443 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
9444 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be | ||||
9445 | // secondary) | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9446 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9447 | m_errorMonitor->SetDesiredFailureMsg( |
9448 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9449 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 9450 | |
9451 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9452 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 9453 | |
9454 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9455 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9456 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
9457 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); | ||||
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 9458 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9459 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 9460 | } |
9461 | |||||
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 9462 | TEST_F(VkLayerTest, DSUsageBitsErrors) { |
9463 | TEST_DESCRIPTION("Attempt to update descriptor sets for images and buffers " | ||||
9464 | "that do not have correct usage bits sets."); | ||||
9465 | VkResult err; | ||||
9466 | |||||
9467 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9468 | VkDescriptorPoolSize ds_type_count[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; | ||||
9469 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { | ||||
9470 | ds_type_count[i].type = VkDescriptorType(i); | ||||
9471 | ds_type_count[i].descriptorCount = 1; | ||||
9472 | } | ||||
9473 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
9474 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
9475 | ds_pool_ci.pNext = NULL; | ||||
9476 | ds_pool_ci.maxSets = VK_DESCRIPTOR_TYPE_RANGE_SIZE; | ||||
9477 | ds_pool_ci.poolSizeCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; | ||||
9478 | ds_pool_ci.pPoolSizes = ds_type_count; | ||||
9479 | |||||
9480 | VkDescriptorPool ds_pool; | ||||
9481 | err = | ||||
9482 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
9483 | ASSERT_VK_SUCCESS(err); | ||||
9484 | |||||
9485 | // Create 10 layouts where each has a single descriptor of different type | ||||
9486 | VkDescriptorSetLayoutBinding dsl_binding[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = | ||||
9487 | {}; | ||||
9488 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { | ||||
9489 | dsl_binding[i].binding = 0; | ||||
9490 | dsl_binding[i].descriptorType = VkDescriptorType(i); | ||||
9491 | dsl_binding[i].descriptorCount = 1; | ||||
9492 | dsl_binding[i].stageFlags = VK_SHADER_STAGE_ALL; | ||||
9493 | dsl_binding[i].pImmutableSamplers = NULL; | ||||
9494 | } | ||||
9495 | |||||
9496 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
9497 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
9498 | ds_layout_ci.pNext = NULL; | ||||
9499 | ds_layout_ci.bindingCount = 1; | ||||
9500 | VkDescriptorSetLayout ds_layouts[VK_DESCRIPTOR_TYPE_RANGE_SIZE]; | ||||
9501 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { | ||||
9502 | ds_layout_ci.pBindings = dsl_binding + i; | ||||
9503 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, | ||||
9504 | NULL, ds_layouts + i); | ||||
9505 | ASSERT_VK_SUCCESS(err); | ||||
9506 | } | ||||
9507 | VkDescriptorSet descriptor_sets[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; | ||||
9508 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
9509 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
9510 | alloc_info.descriptorSetCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; | ||||
9511 | alloc_info.descriptorPool = ds_pool; | ||||
9512 | alloc_info.pSetLayouts = ds_layouts; | ||||
9513 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
9514 | descriptor_sets); | ||||
9515 | ASSERT_VK_SUCCESS(err); | ||||
9516 | |||||
9517 | // Create a buffer & bufferView to be used for invalid updates | ||||
9518 | VkBufferCreateInfo buff_ci = {}; | ||||
9519 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
9520 | // This usage is not valid for any descriptor type | ||||
9521 | buff_ci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; | ||||
9522 | buff_ci.size = 256; | ||||
9523 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
9524 | VkBuffer buffer; | ||||
9525 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); | ||||
9526 | ASSERT_VK_SUCCESS(err); | ||||
9527 | |||||
9528 | VkBufferViewCreateInfo buff_view_ci = {}; | ||||
9529 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; | ||||
9530 | buff_view_ci.buffer = buffer; | ||||
9531 | buff_view_ci.format = VK_FORMAT_R8_UNORM; | ||||
9532 | buff_view_ci.range = VK_WHOLE_SIZE; | ||||
9533 | VkBufferView buff_view; | ||||
9534 | err = | ||||
9535 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); | ||||
9536 | ASSERT_VK_SUCCESS(err); | ||||
9537 | |||||
9538 | // Create an image to be used for invalid updates | ||||
9539 | VkImageCreateInfo image_ci = {}; | ||||
9540 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
9541 | image_ci.imageType = VK_IMAGE_TYPE_2D; | ||||
9542 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
9543 | image_ci.extent.width = 64; | ||||
9544 | image_ci.extent.height = 64; | ||||
9545 | image_ci.extent.depth = 1; | ||||
9546 | image_ci.mipLevels = 1; | ||||
9547 | image_ci.arrayLayers = 1; | ||||
9548 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
9549 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; | ||||
9550 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | ||||
9551 | // This usage is not valid for any descriptor type | ||||
9552 | image_ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
9553 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
9554 | VkImage image; | ||||
9555 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); | ||||
9556 | ASSERT_VK_SUCCESS(err); | ||||
9557 | // Bind memory to image | ||||
9558 | VkMemoryRequirements mem_reqs; | ||||
9559 | VkDeviceMemory image_mem; | ||||
9560 | bool pass; | ||||
9561 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
9562 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
9563 | mem_alloc.pNext = NULL; | ||||
9564 | mem_alloc.allocationSize = 0; | ||||
9565 | mem_alloc.memoryTypeIndex = 0; | ||||
9566 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
9567 | mem_alloc.allocationSize = mem_reqs.size; | ||||
9568 | pass = | ||||
9569 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
9570 | ASSERT_TRUE(pass); | ||||
9571 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); | ||||
9572 | ASSERT_VK_SUCCESS(err); | ||||
9573 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); | ||||
9574 | ASSERT_VK_SUCCESS(err); | ||||
9575 | // Now create view for image | ||||
9576 | VkImageViewCreateInfo image_view_ci = {}; | ||||
9577 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
9578 | image_view_ci.image = image; | ||||
9579 | image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
9580 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
9581 | image_view_ci.subresourceRange.layerCount = 1; | ||||
9582 | image_view_ci.subresourceRange.baseArrayLayer = 0; | ||||
9583 | image_view_ci.subresourceRange.levelCount = 1; | ||||
9584 | image_view_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
9585 | VkImageView image_view; | ||||
9586 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, | ||||
9587 | &image_view); | ||||
9588 | ASSERT_VK_SUCCESS(err); | ||||
9589 | |||||
9590 | VkDescriptorBufferInfo buff_info = {}; | ||||
9591 | buff_info.buffer = buffer; | ||||
9592 | VkDescriptorImageInfo img_info = {}; | ||||
9593 | img_info.imageView = image_view; | ||||
9594 | VkWriteDescriptorSet descriptor_write = {}; | ||||
9595 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
9596 | descriptor_write.dstBinding = 0; | ||||
9597 | descriptor_write.descriptorCount = 1; | ||||
9598 | descriptor_write.pTexelBufferView = &buff_view; | ||||
9599 | descriptor_write.pBufferInfo = &buff_info; | ||||
9600 | descriptor_write.pImageInfo = &img_info; | ||||
9601 | |||||
9602 | // These error messages align with VkDescriptorType struct | ||||
9603 | const char *error_msgs[] = { | ||||
9604 | "", // placeholder, no error for SAMPLER descriptor | ||||
9605 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", | ||||
9606 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", | ||||
9607 | " does not have VK_IMAGE_USAGE_STORAGE_BIT set.", | ||||
9608 | " does not have VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT set.", | ||||
9609 | " does not have VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT set.", | ||||
9610 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", | ||||
9611 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", | ||||
9612 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", | ||||
9613 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", | ||||
9614 | " does not have VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set."}; | ||||
9615 | // Start loop at 1 as SAMPLER desc type has no usage bit error | ||||
9616 | for (uint32_t i = 1; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { | ||||
9617 | descriptor_write.descriptorType = VkDescriptorType(i); | ||||
9618 | descriptor_write.dstSet = descriptor_sets[i]; | ||||
9619 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9620 | error_msgs[i]); | ||||
9621 | |||||
9622 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, | ||||
9623 | NULL); | ||||
9624 | |||||
9625 | m_errorMonitor->VerifyFound(); | ||||
9626 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[i], NULL); | ||||
9627 | } | ||||
9628 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[0], NULL); | ||||
9629 | vkDestroyImage(m_device->device(), image, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 9630 | vkFreeMemory(m_device->device(), image_mem, NULL); |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 9631 | vkDestroyImageView(m_device->device(), image_view, NULL); |
9632 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
9633 | vkDestroyBufferView(m_device->device(), buff_view, NULL); | ||||
9634 | vkFreeDescriptorSets(m_device->device(), ds_pool, | ||||
9635 | VK_DESCRIPTOR_TYPE_RANGE_SIZE, descriptor_sets); | ||||
9636 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
9637 | } | ||||
9638 | |||||
Tobin Ehlis | 585f66d | 2016-07-01 18:23:58 -0600 | [diff] [blame] | 9639 | TEST_F(VkLayerTest, DSBufferInfoErrors) { |
9640 | TEST_DESCRIPTION( | ||||
9641 | "Attempt to update buffer descriptor set that has incorrect " | ||||
9642 | "parameters in VkDescriptorBufferInfo struct. This includes:\n" | ||||
9643 | "1. offset value greater than buffer size\n" | ||||
9644 | "2. range value of 0\n" | ||||
9645 | "3. range value greater than buffer (size - offset)"); | ||||
9646 | VkResult err; | ||||
9647 | |||||
9648 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9649 | VkDescriptorPoolSize ds_type_count = {}; | ||||
9650 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
9651 | ds_type_count.descriptorCount = 1; | ||||
9652 | |||||
9653 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
9654 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
9655 | ds_pool_ci.pNext = NULL; | ||||
9656 | ds_pool_ci.maxSets = 1; | ||||
9657 | ds_pool_ci.poolSizeCount = 1; | ||||
9658 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
9659 | |||||
9660 | VkDescriptorPool ds_pool; | ||||
9661 | err = | ||||
9662 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
9663 | ASSERT_VK_SUCCESS(err); | ||||
9664 | |||||
9665 | // Create layout with single uniform buffer descriptor | ||||
9666 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
9667 | dsl_binding.binding = 0; | ||||
9668 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
9669 | dsl_binding.descriptorCount = 1; | ||||
9670 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
9671 | dsl_binding.pImmutableSamplers = NULL; | ||||
9672 | |||||
9673 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
9674 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
9675 | ds_layout_ci.pNext = NULL; | ||||
9676 | ds_layout_ci.bindingCount = 1; | ||||
9677 | ds_layout_ci.pBindings = &dsl_binding; | ||||
9678 | VkDescriptorSetLayout ds_layout; | ||||
9679 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
9680 | &ds_layout); | ||||
9681 | ASSERT_VK_SUCCESS(err); | ||||
9682 | |||||
9683 | VkDescriptorSet descriptor_set = {}; | ||||
9684 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
9685 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
9686 | alloc_info.descriptorSetCount = 1; | ||||
9687 | alloc_info.descriptorPool = ds_pool; | ||||
9688 | alloc_info.pSetLayouts = &ds_layout; | ||||
9689 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
9690 | &descriptor_set); | ||||
9691 | ASSERT_VK_SUCCESS(err); | ||||
9692 | |||||
9693 | // Create a buffer to be used for invalid updates | ||||
9694 | VkBufferCreateInfo buff_ci = {}; | ||||
9695 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
9696 | buff_ci.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
9697 | buff_ci.size = 256; | ||||
9698 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
9699 | VkBuffer buffer; | ||||
9700 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); | ||||
9701 | ASSERT_VK_SUCCESS(err); | ||||
9702 | // Have to bind memory to buffer before descriptor update | ||||
9703 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
9704 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
9705 | mem_alloc.pNext = NULL; | ||||
9706 | mem_alloc.allocationSize = 256; | ||||
9707 | mem_alloc.memoryTypeIndex = 0; | ||||
9708 | |||||
9709 | VkMemoryRequirements mem_reqs; | ||||
9710 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); | ||||
9711 | bool pass = | ||||
9712 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
9713 | if (!pass) { | ||||
9714 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
9715 | return; | ||||
9716 | } | ||||
9717 | |||||
9718 | VkDeviceMemory mem; | ||||
9719 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); | ||||
9720 | ASSERT_VK_SUCCESS(err); | ||||
9721 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
9722 | ASSERT_VK_SUCCESS(err); | ||||
9723 | |||||
9724 | VkDescriptorBufferInfo buff_info = {}; | ||||
9725 | buff_info.buffer = buffer; | ||||
9726 | // First make offset 1 larger than buffer size | ||||
9727 | buff_info.offset = 257; | ||||
9728 | buff_info.range = VK_WHOLE_SIZE; | ||||
9729 | VkWriteDescriptorSet descriptor_write = {}; | ||||
9730 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
9731 | descriptor_write.dstBinding = 0; | ||||
9732 | descriptor_write.descriptorCount = 1; | ||||
9733 | descriptor_write.pTexelBufferView = nullptr; | ||||
9734 | descriptor_write.pBufferInfo = &buff_info; | ||||
9735 | descriptor_write.pImageInfo = nullptr; | ||||
9736 | |||||
9737 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
9738 | descriptor_write.dstSet = descriptor_set; | ||||
9739 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9740 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9741 | " offset of 257 is greater than buffer "); | ||||
9742 | |||||
9743 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
9744 | |||||
9745 | m_errorMonitor->VerifyFound(); | ||||
9746 | // Now cause error due to range of 0 | ||||
9747 | buff_info.offset = 0; | ||||
9748 | buff_info.range = 0; | ||||
9749 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9750 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9751 | " range is not VK_WHOLE_SIZE and is zero, which is not allowed."); | ||||
9752 | |||||
9753 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
9754 | |||||
9755 | m_errorMonitor->VerifyFound(); | ||||
9756 | // Now cause error due to range exceeding buffer size - offset | ||||
9757 | buff_info.offset = 128; | ||||
9758 | buff_info.range = 200; | ||||
9759 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9760 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9761 | " range is 200 which is greater than buffer size "); | ||||
9762 | |||||
9763 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
9764 | |||||
9765 | m_errorMonitor->VerifyFound(); | ||||
Mark Lobodzinski | 4bb5409 | 2016-07-06 14:27:19 -0600 | [diff] [blame] | 9766 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 585f66d | 2016-07-01 18:23:58 -0600 | [diff] [blame] | 9767 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
9768 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
9769 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set); | ||||
9770 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
9771 | } | ||||
9772 | |||||
Tobin Ehlis | 2fc296b | 2016-06-15 14:05:27 -0600 | [diff] [blame] | 9773 | TEST_F(VkLayerTest, DSAspectBitsErrors) { |
9774 | // TODO : Initially only catching case where DEPTH & STENCIL aspect bits | ||||
9775 | // are set, but could expand this test to hit more cases. | ||||
9776 | TEST_DESCRIPTION("Attempt to update descriptor sets for images " | ||||
9777 | "that do not have correct aspect bits sets."); | ||||
9778 | VkResult err; | ||||
9779 | |||||
9780 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9781 | VkDescriptorPoolSize ds_type_count = {}; | ||||
9782 | ds_type_count.type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; | ||||
9783 | ds_type_count.descriptorCount = 1; | ||||
9784 | |||||
9785 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
9786 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
9787 | ds_pool_ci.pNext = NULL; | ||||
9788 | ds_pool_ci.maxSets = 5; | ||||
9789 | ds_pool_ci.poolSizeCount = 1; | ||||
9790 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
9791 | |||||
9792 | VkDescriptorPool ds_pool; | ||||
9793 | err = | ||||
9794 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
9795 | ASSERT_VK_SUCCESS(err); | ||||
9796 | |||||
9797 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
9798 | dsl_binding.binding = 0; | ||||
9799 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; | ||||
9800 | dsl_binding.descriptorCount = 1; | ||||
9801 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
9802 | dsl_binding.pImmutableSamplers = NULL; | ||||
9803 | |||||
9804 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
9805 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
9806 | ds_layout_ci.pNext = NULL; | ||||
9807 | ds_layout_ci.bindingCount = 1; | ||||
9808 | ds_layout_ci.pBindings = &dsl_binding; | ||||
9809 | VkDescriptorSetLayout ds_layout; | ||||
9810 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
9811 | &ds_layout); | ||||
9812 | ASSERT_VK_SUCCESS(err); | ||||
9813 | |||||
9814 | VkDescriptorSet descriptor_set = {}; | ||||
9815 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
9816 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
9817 | alloc_info.descriptorSetCount = 1; | ||||
9818 | alloc_info.descriptorPool = ds_pool; | ||||
9819 | alloc_info.pSetLayouts = &ds_layout; | ||||
9820 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
9821 | &descriptor_set); | ||||
9822 | ASSERT_VK_SUCCESS(err); | ||||
9823 | |||||
9824 | // Create an image to be used for invalid updates | ||||
9825 | VkImageCreateInfo image_ci = {}; | ||||
9826 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
9827 | image_ci.imageType = VK_IMAGE_TYPE_2D; | ||||
9828 | image_ci.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
9829 | image_ci.extent.width = 64; | ||||
9830 | image_ci.extent.height = 64; | ||||
9831 | image_ci.extent.depth = 1; | ||||
9832 | image_ci.mipLevels = 1; | ||||
9833 | image_ci.arrayLayers = 1; | ||||
9834 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
9835 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; | ||||
9836 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | ||||
9837 | image_ci.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
9838 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
9839 | VkImage image; | ||||
9840 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); | ||||
9841 | ASSERT_VK_SUCCESS(err); | ||||
9842 | // Bind memory to image | ||||
9843 | VkMemoryRequirements mem_reqs; | ||||
9844 | VkDeviceMemory image_mem; | ||||
9845 | bool pass; | ||||
9846 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
9847 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
9848 | mem_alloc.pNext = NULL; | ||||
9849 | mem_alloc.allocationSize = 0; | ||||
9850 | mem_alloc.memoryTypeIndex = 0; | ||||
9851 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
9852 | mem_alloc.allocationSize = mem_reqs.size; | ||||
9853 | pass = | ||||
9854 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
9855 | ASSERT_TRUE(pass); | ||||
9856 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); | ||||
9857 | ASSERT_VK_SUCCESS(err); | ||||
9858 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); | ||||
9859 | ASSERT_VK_SUCCESS(err); | ||||
9860 | // Now create view for image | ||||
9861 | VkImageViewCreateInfo image_view_ci = {}; | ||||
9862 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
9863 | image_view_ci.image = image; | ||||
9864 | image_view_ci.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
9865 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
9866 | image_view_ci.subresourceRange.layerCount = 1; | ||||
9867 | image_view_ci.subresourceRange.baseArrayLayer = 0; | ||||
9868 | image_view_ci.subresourceRange.levelCount = 1; | ||||
9869 | // Setting both depth & stencil aspect bits is illegal for descriptor | ||||
9870 | image_view_ci.subresourceRange.aspectMask = | ||||
9871 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; | ||||
9872 | |||||
9873 | VkImageView image_view; | ||||
9874 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, | ||||
9875 | &image_view); | ||||
9876 | ASSERT_VK_SUCCESS(err); | ||||
9877 | |||||
9878 | VkDescriptorImageInfo img_info = {}; | ||||
9879 | img_info.imageView = image_view; | ||||
9880 | VkWriteDescriptorSet descriptor_write = {}; | ||||
9881 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
9882 | descriptor_write.dstBinding = 0; | ||||
9883 | descriptor_write.descriptorCount = 1; | ||||
9884 | descriptor_write.pTexelBufferView = NULL; | ||||
9885 | descriptor_write.pBufferInfo = NULL; | ||||
9886 | descriptor_write.pImageInfo = &img_info; | ||||
9887 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; | ||||
9888 | descriptor_write.dstSet = descriptor_set; | ||||
9889 | const char *error_msg = " please only set either VK_IMAGE_ASPECT_DEPTH_BIT " | ||||
9890 | "or VK_IMAGE_ASPECT_STENCIL_BIT "; | ||||
9891 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9892 | error_msg); | ||||
9893 | |||||
9894 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
9895 | |||||
9896 | m_errorMonitor->VerifyFound(); | ||||
9897 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
9898 | vkDestroyImage(m_device->device(), image, NULL); | ||||
9899 | vkFreeMemory(m_device->device(), image_mem, NULL); | ||||
9900 | vkDestroyImageView(m_device->device(), image_view, NULL); | ||||
9901 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set); | ||||
9902 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
9903 | } | ||||
9904 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9905 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 9906 | // Create DS w/ layout of one type and attempt Update w/ mis-matched type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9907 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9908 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9909 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 9910 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
9911 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " | ||||
9912 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9913 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9914 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9915 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9916 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9917 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
9918 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9919 | |
9920 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9921 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
9922 | ds_pool_ci.pNext = NULL; | ||||
9923 | ds_pool_ci.maxSets = 1; | ||||
9924 | ds_pool_ci.poolSizeCount = 1; | ||||
9925 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9926 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9927 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9928 | err = |
9929 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9930 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9931 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9932 | dsl_binding.binding = 0; |
9933 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
9934 | dsl_binding.descriptorCount = 1; | ||||
9935 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
9936 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9937 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9938 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9939 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
9940 | ds_layout_ci.pNext = NULL; | ||||
9941 | ds_layout_ci.bindingCount = 1; | ||||
9942 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 9943 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9944 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9945 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
9946 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9947 | ASSERT_VK_SUCCESS(err); |
9948 | |||||
9949 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9950 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9951 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9952 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9953 | alloc_info.descriptorPool = ds_pool; |
9954 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9955 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
9956 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9957 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9958 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 9959 | VkSamplerCreateInfo sampler_ci = {}; |
9960 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; | ||||
9961 | sampler_ci.pNext = NULL; | ||||
9962 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
9963 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
9964 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
9965 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
9966 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
9967 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
9968 | sampler_ci.mipLodBias = 1.0; | ||||
9969 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
9970 | sampler_ci.maxAnisotropy = 1; | ||||
9971 | sampler_ci.compareEnable = VK_FALSE; | ||||
9972 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
9973 | sampler_ci.minLod = 1.0; | ||||
9974 | sampler_ci.maxLod = 1.0; | ||||
9975 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
9976 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
9977 | VkSampler sampler; | ||||
9978 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); | ||||
9979 | ASSERT_VK_SUCCESS(err); | ||||
9980 | |||||
9981 | VkDescriptorImageInfo info = {}; | ||||
9982 | info.sampler = sampler; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9983 | |
9984 | VkWriteDescriptorSet descriptor_write; | ||||
9985 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
9986 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9987 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9988 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 9989 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9990 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 9991 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 9992 | |
9993 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
9994 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9995 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 9996 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9997 | vkDestroySampler(m_device->device(), sampler, NULL); |
9998 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
9999 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 10000 | } |
10001 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10002 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 10003 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10004 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10005 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10006 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 10007 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
10008 | " binding #0 with 1 total descriptors but update of 1 descriptors " | ||||
10009 | "starting at binding offset of 0 combined with update array element " | ||||
10010 | "offset of 1 oversteps the size of this descriptor set."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10011 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10012 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10013 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10014 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10015 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
10016 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10017 | |
10018 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10019 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
10020 | ds_pool_ci.pNext = NULL; | ||||
10021 | ds_pool_ci.maxSets = 1; | ||||
10022 | ds_pool_ci.poolSizeCount = 1; | ||||
10023 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10024 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10025 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10026 | err = |
10027 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10028 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10029 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10030 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10031 | dsl_binding.binding = 0; |
10032 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10033 | dsl_binding.descriptorCount = 1; | ||||
10034 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10035 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10036 | |
10037 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10038 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
10039 | ds_layout_ci.pNext = NULL; | ||||
10040 | ds_layout_ci.bindingCount = 1; | ||||
10041 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10042 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10043 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10044 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
10045 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10046 | ASSERT_VK_SUCCESS(err); |
10047 | |||||
10048 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10049 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10050 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10051 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 10052 | alloc_info.descriptorPool = ds_pool; |
10053 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10054 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
10055 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10056 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10057 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 10058 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
10059 | VkDescriptorBufferInfo buff_info = {}; | ||||
10060 | buff_info.buffer = | ||||
10061 | VkBuffer(0); // Don't care about buffer handle for this test | ||||
10062 | buff_info.offset = 0; | ||||
10063 | buff_info.range = 1024; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10064 | |
10065 | VkWriteDescriptorSet descriptor_write; | ||||
10066 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
10067 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10068 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10069 | descriptor_write.dstArrayElement = |
10070 | 1; /* This index out of bounds for the update */ | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 10071 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 10072 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
10073 | descriptor_write.pBufferInfo = &buff_info; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10074 | |
10075 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10076 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10077 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 10078 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10079 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
10080 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 10081 | } |
10082 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10083 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
10084 | // Create layout w/ count of 1 and attempt update to that layout w/ binding | ||||
10085 | // index 2 | ||||
10086 | VkResult err; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10087 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 10088 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
10089 | " does not have binding 2."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10090 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10091 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10092 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10093 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10094 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
10095 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10096 | |
10097 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10098 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
10099 | ds_pool_ci.pNext = NULL; | ||||
10100 | ds_pool_ci.maxSets = 1; | ||||
10101 | ds_pool_ci.poolSizeCount = 1; | ||||
10102 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 10103 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10104 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10105 | err = |
10106 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10107 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10108 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10109 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10110 | dsl_binding.binding = 0; |
10111 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10112 | dsl_binding.descriptorCount = 1; | ||||
10113 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10114 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10115 | |
10116 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10117 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
10118 | ds_layout_ci.pNext = NULL; | ||||
10119 | ds_layout_ci.bindingCount = 1; | ||||
10120 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10121 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10122 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
10123 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10124 | ASSERT_VK_SUCCESS(err); |
10125 | |||||
10126 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10127 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10128 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10129 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 10130 | alloc_info.descriptorPool = ds_pool; |
10131 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10132 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
10133 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10134 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10135 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10136 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10137 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
10138 | sampler_ci.pNext = NULL; | ||||
10139 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
10140 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
10141 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
10142 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10143 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10144 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10145 | sampler_ci.mipLodBias = 1.0; | ||||
10146 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
10147 | sampler_ci.maxAnisotropy = 1; | ||||
10148 | sampler_ci.compareEnable = VK_FALSE; | ||||
10149 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
10150 | sampler_ci.minLod = 1.0; | ||||
10151 | sampler_ci.maxLod = 1.0; | ||||
10152 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
10153 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10154 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10155 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10156 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10157 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10158 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 10159 | VkDescriptorImageInfo info = {}; |
10160 | info.sampler = sampler; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10161 | |
10162 | VkWriteDescriptorSet descriptor_write; | ||||
10163 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
10164 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10165 | descriptor_write.dstSet = descriptorSet; |
10166 | descriptor_write.dstBinding = 2; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 10167 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10168 | // 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] | 10169 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 10170 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10171 | |
10172 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10173 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10174 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 10175 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10176 | vkDestroySampler(m_device->device(), sampler, NULL); |
10177 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
10178 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 10179 | } |
10180 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10181 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
10182 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* | ||||
10183 | // types | ||||
10184 | VkResult err; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10185 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10186 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 10187 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10188 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10189 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10190 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10191 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10192 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
10193 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10194 | |
10195 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10196 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
10197 | ds_pool_ci.pNext = NULL; | ||||
10198 | ds_pool_ci.maxSets = 1; | ||||
10199 | ds_pool_ci.poolSizeCount = 1; | ||||
10200 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 10201 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10202 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10203 | err = |
10204 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10205 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10206 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10207 | dsl_binding.binding = 0; |
10208 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10209 | dsl_binding.descriptorCount = 1; | ||||
10210 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10211 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10212 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10213 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10214 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
10215 | ds_layout_ci.pNext = NULL; | ||||
10216 | ds_layout_ci.bindingCount = 1; | ||||
10217 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10218 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10219 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10220 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
10221 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10222 | ASSERT_VK_SUCCESS(err); |
10223 | |||||
10224 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10225 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10226 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10227 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 10228 | alloc_info.descriptorPool = ds_pool; |
10229 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10230 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
10231 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10232 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10233 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10234 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10235 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
10236 | sampler_ci.pNext = NULL; | ||||
10237 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
10238 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
10239 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
10240 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10241 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10242 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10243 | sampler_ci.mipLodBias = 1.0; | ||||
10244 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
10245 | sampler_ci.maxAnisotropy = 1; | ||||
10246 | sampler_ci.compareEnable = VK_FALSE; | ||||
10247 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
10248 | sampler_ci.minLod = 1.0; | ||||
10249 | sampler_ci.maxLod = 1.0; | ||||
10250 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
10251 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10252 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10253 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10254 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10255 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 10256 | VkDescriptorImageInfo info = {}; |
10257 | info.sampler = sampler; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10258 | |
10259 | VkWriteDescriptorSet descriptor_write; | ||||
10260 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10261 | descriptor_write.sType = |
10262 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10263 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 10264 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10265 | // 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] | 10266 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 10267 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10268 | |
10269 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10270 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10271 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 10272 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10273 | vkDestroySampler(m_device->device(), sampler, NULL); |
10274 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
10275 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 10276 | } |
10277 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10278 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10279 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10280 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10281 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10282 | m_errorMonitor->SetDesiredFailureMsg( |
10283 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 10284 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10285 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10286 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10287 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
10288 | // code | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10289 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10290 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
10291 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10292 | |
10293 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10294 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
10295 | ds_pool_ci.pNext = NULL; | ||||
10296 | ds_pool_ci.maxSets = 1; | ||||
10297 | ds_pool_ci.poolSizeCount = 1; | ||||
10298 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10299 | |
10300 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10301 | err = |
10302 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10303 | ASSERT_VK_SUCCESS(err); |
10304 | |||||
10305 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10306 | dsl_binding.binding = 0; |
10307 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
10308 | dsl_binding.descriptorCount = 1; | ||||
10309 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10310 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10311 | |
10312 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10313 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
10314 | ds_layout_ci.pNext = NULL; | ||||
10315 | ds_layout_ci.bindingCount = 1; | ||||
10316 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10317 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10318 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
10319 | &ds_layout); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10320 | ASSERT_VK_SUCCESS(err); |
10321 | |||||
10322 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10323 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10324 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10325 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10326 | alloc_info.descriptorPool = ds_pool; |
10327 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10328 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
10329 | &descriptorSet); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10330 | ASSERT_VK_SUCCESS(err); |
10331 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10332 | VkSampler sampler = |
10333 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10334 | |
10335 | VkDescriptorImageInfo descriptor_info; | ||||
10336 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); | ||||
10337 | descriptor_info.sampler = sampler; | ||||
10338 | |||||
10339 | VkWriteDescriptorSet descriptor_write; | ||||
10340 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
10341 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10342 | descriptor_write.dstSet = descriptorSet; |
10343 | descriptor_write.dstBinding = 0; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 10344 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10345 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
10346 | descriptor_write.pImageInfo = &descriptor_info; | ||||
10347 | |||||
10348 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10349 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10350 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10351 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10352 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
10353 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10354 | } |
10355 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10356 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
10357 | // Create a single combined Image/Sampler descriptor and send it an invalid | ||||
10358 | // imageView | ||||
10359 | VkResult err; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10360 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 10361 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
10362 | "Attempted write update to combined " | ||||
10363 | "image sampler descriptor failed due " | ||||
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 10364 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10365 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10366 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10367 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10368 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
10369 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10370 | |
10371 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10372 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
10373 | ds_pool_ci.pNext = NULL; | ||||
10374 | ds_pool_ci.maxSets = 1; | ||||
10375 | ds_pool_ci.poolSizeCount = 1; | ||||
10376 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10377 | |
10378 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10379 | err = |
10380 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10381 | ASSERT_VK_SUCCESS(err); |
10382 | |||||
10383 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10384 | dsl_binding.binding = 0; |
10385 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; | ||||
10386 | dsl_binding.descriptorCount = 1; | ||||
10387 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10388 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10389 | |
10390 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10391 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
10392 | ds_layout_ci.pNext = NULL; | ||||
10393 | ds_layout_ci.bindingCount = 1; | ||||
10394 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10395 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10396 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
10397 | &ds_layout); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10398 | ASSERT_VK_SUCCESS(err); |
10399 | |||||
10400 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10401 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10402 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10403 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10404 | alloc_info.descriptorPool = ds_pool; |
10405 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10406 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
10407 | &descriptorSet); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10408 | ASSERT_VK_SUCCESS(err); |
10409 | |||||
10410 | VkSamplerCreateInfo sampler_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10411 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
10412 | sampler_ci.pNext = NULL; | ||||
10413 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
10414 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
10415 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
10416 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10417 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10418 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10419 | sampler_ci.mipLodBias = 1.0; | ||||
10420 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
10421 | sampler_ci.maxAnisotropy = 1; | ||||
10422 | sampler_ci.compareEnable = VK_FALSE; | ||||
10423 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
10424 | sampler_ci.minLod = 1.0; | ||||
10425 | sampler_ci.maxLod = 1.0; | ||||
10426 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
10427 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10428 | |
10429 | VkSampler sampler; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10430 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10431 | ASSERT_VK_SUCCESS(err); |
10432 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10433 | VkImageView view = |
10434 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10435 | |
10436 | VkDescriptorImageInfo descriptor_info; | ||||
10437 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); | ||||
10438 | descriptor_info.sampler = sampler; | ||||
10439 | descriptor_info.imageView = view; | ||||
10440 | |||||
10441 | VkWriteDescriptorSet descriptor_write; | ||||
10442 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
10443 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10444 | descriptor_write.dstSet = descriptorSet; |
10445 | descriptor_write.dstBinding = 0; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 10446 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10447 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
10448 | descriptor_write.pImageInfo = &descriptor_info; | ||||
10449 | |||||
10450 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10451 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10452 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10453 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10454 | vkDestroySampler(m_device->device(), sampler, NULL); |
10455 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
10456 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10457 | } |
10458 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10459 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
10460 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update | ||||
10461 | // into the other | ||||
10462 | VkResult err; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10463 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 10464 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
10465 | " binding #1 with type " | ||||
10466 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " | ||||
10467 | "not match."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10468 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10469 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10470 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10471 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10472 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
10473 | ds_type_count[0].descriptorCount = 1; | ||||
10474 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
10475 | ds_type_count[1].descriptorCount = 1; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10476 | |
10477 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10478 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
10479 | ds_pool_ci.pNext = NULL; | ||||
10480 | ds_pool_ci.maxSets = 1; | ||||
10481 | ds_pool_ci.poolSizeCount = 2; | ||||
10482 | ds_pool_ci.pPoolSizes = ds_type_count; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10483 | |
10484 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10485 | err = |
10486 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10487 | ASSERT_VK_SUCCESS(err); |
10488 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10489 | dsl_binding[0].binding = 0; |
10490 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10491 | dsl_binding[0].descriptorCount = 1; | ||||
10492 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; | ||||
10493 | dsl_binding[0].pImmutableSamplers = NULL; | ||||
10494 | dsl_binding[1].binding = 1; | ||||
10495 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
10496 | dsl_binding[1].descriptorCount = 1; | ||||
10497 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; | ||||
10498 | dsl_binding[1].pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10499 | |
10500 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10501 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
10502 | ds_layout_ci.pNext = NULL; | ||||
10503 | ds_layout_ci.bindingCount = 2; | ||||
10504 | ds_layout_ci.pBindings = dsl_binding; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10505 | |
10506 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10507 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
10508 | &ds_layout); | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10509 | ASSERT_VK_SUCCESS(err); |
10510 | |||||
10511 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10512 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10513 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10514 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10515 | alloc_info.descriptorPool = ds_pool; |
10516 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10517 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
10518 | &descriptorSet); | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10519 | ASSERT_VK_SUCCESS(err); |
10520 | |||||
10521 | VkSamplerCreateInfo sampler_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10522 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
10523 | sampler_ci.pNext = NULL; | ||||
10524 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
10525 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
10526 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
10527 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10528 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10529 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10530 | sampler_ci.mipLodBias = 1.0; | ||||
10531 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
10532 | sampler_ci.maxAnisotropy = 1; | ||||
10533 | sampler_ci.compareEnable = VK_FALSE; | ||||
10534 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
10535 | sampler_ci.minLod = 1.0; | ||||
10536 | sampler_ci.maxLod = 1.0; | ||||
10537 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
10538 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10539 | |
10540 | VkSampler sampler; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10541 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10542 | ASSERT_VK_SUCCESS(err); |
10543 | |||||
10544 | VkDescriptorImageInfo info = {}; | ||||
10545 | info.sampler = sampler; | ||||
10546 | |||||
10547 | VkWriteDescriptorSet descriptor_write; | ||||
10548 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); | ||||
10549 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10550 | descriptor_write.dstSet = descriptorSet; |
10551 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 10552 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10553 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
10554 | descriptor_write.pImageInfo = &info; | ||||
10555 | // This write update should succeed | ||||
10556 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10557 | // Now perform a copy update that fails due to type mismatch | ||||
10558 | VkCopyDescriptorSet copy_ds_update; | ||||
10559 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); | ||||
10560 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; | ||||
10561 | copy_ds_update.srcSet = descriptorSet; | ||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 10562 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10563 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10564 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 10565 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10566 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
10567 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10568 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10569 | // Now perform a copy update that fails due to binding out of bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10570 | m_errorMonitor->SetDesiredFailureMsg( |
10571 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 10572 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10573 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
10574 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; | ||||
10575 | copy_ds_update.srcSet = descriptorSet; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10576 | copy_ds_update.srcBinding = |
10577 | 3; // ERROR : Invalid binding for matching layout | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10578 | copy_ds_update.dstSet = descriptorSet; |
10579 | copy_ds_update.dstBinding = 0; | ||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 10580 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10581 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
10582 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10583 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10584 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10585 | // Now perform a copy update that fails due to binding out of bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10586 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 10587 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
10588 | "update array offset of 0 and update of " | ||||
10589 | "5 descriptors oversteps total number " | ||||
10590 | "of descriptors in set: 2."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10591 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10592 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
10593 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; | ||||
10594 | copy_ds_update.srcSet = descriptorSet; | ||||
10595 | copy_ds_update.srcBinding = 1; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10596 | copy_ds_update.dstSet = descriptorSet; |
10597 | copy_ds_update.dstBinding = 0; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10598 | copy_ds_update.descriptorCount = |
10599 | 5; // ERROR copy 5 descriptors (out of bounds for layout) | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10600 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
10601 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10602 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10603 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10604 | vkDestroySampler(m_device->device(), sampler, NULL); |
10605 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
10606 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 10607 | } |
10608 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10609 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
10610 | // Create CommandBuffer where MSAA samples doesn't match RenderPass | ||||
10611 | // sampleCount | ||||
10612 | VkResult err; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10613 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10614 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10615 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10616 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10617 | ASSERT_NO_FATAL_FAILURE(InitState()); |
10618 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10619 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10620 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 10621 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10622 | |
10623 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10624 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
10625 | ds_pool_ci.pNext = NULL; | ||||
10626 | ds_pool_ci.maxSets = 1; | ||||
10627 | ds_pool_ci.poolSizeCount = 1; | ||||
10628 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 10629 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10630 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10631 | err = |
10632 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10633 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10634 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10635 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 10636 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10637 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 10638 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10639 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
10640 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10641 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10642 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
10643 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
10644 | ds_layout_ci.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 10645 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 10646 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10647 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10648 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10649 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
10650 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10651 | ASSERT_VK_SUCCESS(err); |
10652 | |||||
10653 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10654 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10655 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10656 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 10657 | alloc_info.descriptorPool = ds_pool; |
10658 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10659 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
10660 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10661 | ASSERT_VK_SUCCESS(err); |
10662 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10663 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10664 | pipe_ms_state_ci.sType = |
10665 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
10666 | pipe_ms_state_ci.pNext = NULL; | ||||
10667 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; | ||||
10668 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
10669 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
10670 | pipe_ms_state_ci.pSampleMask = NULL; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10671 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10672 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10673 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
10674 | pipeline_layout_ci.pNext = NULL; | ||||
10675 | pipeline_layout_ci.setLayoutCount = 1; | ||||
10676 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10677 | |
10678 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10679 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
10680 | &pipeline_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10681 | ASSERT_VK_SUCCESS(err); |
10682 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10683 | VkShaderObj vs(m_device, bindStateVertShaderText, |
10684 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
10685 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
10686 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10687 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10688 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 10689 | VkPipelineObj pipe(m_device); |
10690 | pipe.AddShader(&vs); | ||||
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 10691 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 10692 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 10693 | pipe.SetMSAA(&pipe_ms_state_ci); |
10694 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10695 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 10696 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10697 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
10698 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10699 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 10700 | // Render triangle (the error should trigger on the attempt to draw). |
10701 | Draw(3, 1, 0, 0); | ||||
10702 | |||||
10703 | // Finalize recording of the command buffer | ||||
10704 | EndCommandBuffer(); | ||||
10705 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10706 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 10707 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10708 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
10709 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
10710 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 10711 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 10712 | |
Tobin Ehlis | 85aa15a | 2016-06-15 10:52:37 -0600 | [diff] [blame] | 10713 | TEST_F(VkLayerTest, RenderPassIncompatible) { |
10714 | TEST_DESCRIPTION("Hit RenderPass incompatible cases. " | ||||
10715 | "Initial case is drawing with an active renderpass that's " | ||||
10716 | "not compatible with the bound PSO's creation renderpass"); | ||||
10717 | VkResult err; | ||||
10718 | |||||
10719 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10720 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
10721 | |||||
10722 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
10723 | dsl_binding.binding = 0; | ||||
10724 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10725 | dsl_binding.descriptorCount = 1; | ||||
10726 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10727 | dsl_binding.pImmutableSamplers = NULL; | ||||
10728 | |||||
10729 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
10730 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
10731 | ds_layout_ci.pNext = NULL; | ||||
10732 | ds_layout_ci.bindingCount = 1; | ||||
10733 | ds_layout_ci.pBindings = &dsl_binding; | ||||
10734 | |||||
10735 | VkDescriptorSetLayout ds_layout; | ||||
10736 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
10737 | &ds_layout); | ||||
10738 | ASSERT_VK_SUCCESS(err); | ||||
10739 | |||||
10740 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
10741 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
10742 | pipeline_layout_ci.pNext = NULL; | ||||
10743 | pipeline_layout_ci.setLayoutCount = 1; | ||||
10744 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
10745 | |||||
10746 | VkPipelineLayout pipeline_layout; | ||||
10747 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
10748 | &pipeline_layout); | ||||
10749 | ASSERT_VK_SUCCESS(err); | ||||
10750 | |||||
10751 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
10752 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
10753 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
10754 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
10755 | this); // We shouldn't need a fragment shader | ||||
10756 | // but add it to be able to run on more devices | ||||
10757 | // Create a renderpass that will be incompatible with default renderpass | ||||
10758 | VkAttachmentReference attach = {}; | ||||
10759 | attach.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
10760 | VkAttachmentReference color_att = {}; | ||||
10761 | color_att.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
10762 | VkSubpassDescription subpass = {}; | ||||
10763 | subpass.inputAttachmentCount = 1; | ||||
10764 | subpass.pInputAttachments = &attach; | ||||
10765 | subpass.colorAttachmentCount = 1; | ||||
10766 | subpass.pColorAttachments = &color_att; | ||||
10767 | VkRenderPassCreateInfo rpci = {}; | ||||
10768 | rpci.subpassCount = 1; | ||||
10769 | rpci.pSubpasses = &subpass; | ||||
10770 | rpci.attachmentCount = 1; | ||||
10771 | VkAttachmentDescription attach_desc = {}; | ||||
10772 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
Cody Northrop | bd16af1 | 2016-06-21 09:25:48 -0600 | [diff] [blame] | 10773 | // Format incompatible with PSO RP color attach format B8G8R8A8_UNORM |
10774 | attach_desc.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
Tobin Ehlis | 85aa15a | 2016-06-15 10:52:37 -0600 | [diff] [blame] | 10775 | rpci.pAttachments = &attach_desc; |
10776 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; | ||||
10777 | VkRenderPass rp; | ||||
10778 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
10779 | VkPipelineObj pipe(m_device); | ||||
10780 | pipe.AddShader(&vs); | ||||
10781 | pipe.AddShader(&fs); | ||||
10782 | pipe.AddColorAttachment(); | ||||
10783 | VkViewport view_port = {}; | ||||
10784 | m_viewports.push_back(view_port); | ||||
10785 | pipe.SetViewport(m_viewports); | ||||
10786 | VkRect2D rect = {}; | ||||
10787 | m_scissors.push_back(rect); | ||||
10788 | pipe.SetScissor(m_scissors); | ||||
10789 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
10790 | |||||
10791 | VkCommandBufferInheritanceInfo cbii = {}; | ||||
10792 | cbii.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; | ||||
10793 | cbii.renderPass = rp; | ||||
10794 | cbii.subpass = 0; | ||||
10795 | VkCommandBufferBeginInfo cbbi = {}; | ||||
10796 | cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
10797 | cbbi.pInheritanceInfo = &cbii; | ||||
10798 | vkBeginCommandBuffer(m_commandBuffer->handle(), &cbbi); | ||||
10799 | VkRenderPassBeginInfo rpbi = {}; | ||||
10800 | rpbi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; | ||||
10801 | rpbi.framebuffer = m_framebuffer; | ||||
10802 | rpbi.renderPass = rp; | ||||
10803 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rpbi, | ||||
10804 | VK_SUBPASS_CONTENTS_INLINE); | ||||
10805 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
10806 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
10807 | |||||
10808 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10809 | " is incompatible w/ gfx pipeline "); | ||||
10810 | // Render triangle (the error should trigger on the attempt to draw). | ||||
10811 | Draw(3, 1, 0, 0); | ||||
10812 | |||||
10813 | // Finalize recording of the command buffer | ||||
10814 | EndCommandBuffer(); | ||||
10815 | |||||
10816 | m_errorMonitor->VerifyFound(); | ||||
10817 | |||||
10818 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
10819 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
10820 | vkDestroyRenderPass(m_device->device(), rp, NULL); | ||||
10821 | } | ||||
10822 | |||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 10823 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
10824 | // Create Pipeline where the number of blend attachments doesn't match the | ||||
10825 | // number of color attachments. In this case, we don't add any color | ||||
10826 | // blend attachments even though we have a color attachment. | ||||
10827 | VkResult err; | ||||
10828 | |||||
10829 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 10830 | "Render pass subpass 0 mismatch with blending state defined and blend state attachment"); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 10831 | |
10832 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10833 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
10834 | VkDescriptorPoolSize ds_type_count = {}; | ||||
10835 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10836 | ds_type_count.descriptorCount = 1; | ||||
10837 | |||||
10838 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
10839 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
10840 | ds_pool_ci.pNext = NULL; | ||||
10841 | ds_pool_ci.maxSets = 1; | ||||
10842 | ds_pool_ci.poolSizeCount = 1; | ||||
10843 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
10844 | |||||
10845 | VkDescriptorPool ds_pool; | ||||
10846 | err = | ||||
10847 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
10848 | ASSERT_VK_SUCCESS(err); | ||||
10849 | |||||
10850 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
10851 | dsl_binding.binding = 0; | ||||
10852 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10853 | dsl_binding.descriptorCount = 1; | ||||
10854 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10855 | dsl_binding.pImmutableSamplers = NULL; | ||||
10856 | |||||
10857 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
10858 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
10859 | ds_layout_ci.pNext = NULL; | ||||
10860 | ds_layout_ci.bindingCount = 1; | ||||
10861 | ds_layout_ci.pBindings = &dsl_binding; | ||||
10862 | |||||
10863 | VkDescriptorSetLayout ds_layout; | ||||
10864 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
10865 | &ds_layout); | ||||
10866 | ASSERT_VK_SUCCESS(err); | ||||
10867 | |||||
10868 | VkDescriptorSet descriptorSet; | ||||
10869 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
10870 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
10871 | alloc_info.descriptorSetCount = 1; | ||||
10872 | alloc_info.descriptorPool = ds_pool; | ||||
10873 | alloc_info.pSetLayouts = &ds_layout; | ||||
10874 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
10875 | &descriptorSet); | ||||
10876 | ASSERT_VK_SUCCESS(err); | ||||
10877 | |||||
10878 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; | ||||
10879 | pipe_ms_state_ci.sType = | ||||
10880 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
10881 | pipe_ms_state_ci.pNext = NULL; | ||||
10882 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; | ||||
10883 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
10884 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
10885 | pipe_ms_state_ci.pSampleMask = NULL; | ||||
10886 | |||||
10887 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
10888 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
10889 | pipeline_layout_ci.pNext = NULL; | ||||
10890 | pipeline_layout_ci.setLayoutCount = 1; | ||||
10891 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
10892 | |||||
10893 | VkPipelineLayout pipeline_layout; | ||||
10894 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
10895 | &pipeline_layout); | ||||
10896 | ASSERT_VK_SUCCESS(err); | ||||
10897 | |||||
10898 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
10899 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
10900 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
10901 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10902 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 10903 | // but add it to be able to run on more devices |
10904 | VkPipelineObj pipe(m_device); | ||||
10905 | pipe.AddShader(&vs); | ||||
10906 | pipe.AddShader(&fs); | ||||
10907 | pipe.SetMSAA(&pipe_ms_state_ci); | ||||
10908 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
10909 | |||||
10910 | BeginCommandBuffer(); | ||||
10911 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
10912 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
10913 | |||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 10914 | // Render triangle (the error should trigger on the attempt to draw). |
10915 | Draw(3, 1, 0, 0); | ||||
10916 | |||||
10917 | // Finalize recording of the command buffer | ||||
10918 | EndCommandBuffer(); | ||||
10919 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10920 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 10921 | |
10922 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
10923 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
10924 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
10925 | } | ||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 10926 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 10927 | TEST_F(VkLayerTest, MissingClearAttachment) { |
10928 | TEST_DESCRIPTION("Points to a wrong colorAttachment index in a VkClearAttachment " | ||||
10929 | "structure passed to vkCmdClearAttachments"); | ||||
10930 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10931 | "vkCmdClearAttachments() attachment index 1 not found in attachment " | ||||
10932 | "reference array of active subpass 0"); | ||||
10933 | |||||
10934 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailCmdClearAttachments); | ||||
10935 | m_errorMonitor->VerifyFound(); | ||||
10936 | } | ||||
10937 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10938 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
10939 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior | ||||
10940 | // to issuing a Draw | ||||
10941 | VkResult err; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 10942 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10943 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 10944 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10945 | "vkCmdClearAttachments() issued on CB object "); |
10946 | |||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 10947 | ASSERT_NO_FATAL_FAILURE(InitState()); |
10948 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10949 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10950 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10951 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
10952 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10953 | |
10954 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10955 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
10956 | ds_pool_ci.pNext = NULL; | ||||
10957 | ds_pool_ci.maxSets = 1; | ||||
10958 | ds_pool_ci.poolSizeCount = 1; | ||||
10959 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10960 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 10961 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10962 | err = |
10963 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 10964 | ASSERT_VK_SUCCESS(err); |
10965 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10966 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10967 | dsl_binding.binding = 0; |
10968 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10969 | dsl_binding.descriptorCount = 1; | ||||
10970 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10971 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 10972 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10973 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10974 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
10975 | ds_layout_ci.pNext = NULL; | ||||
10976 | ds_layout_ci.bindingCount = 1; | ||||
10977 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10978 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 10979 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10980 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
10981 | &ds_layout); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 10982 | ASSERT_VK_SUCCESS(err); |
10983 | |||||
10984 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10985 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10986 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10987 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 10988 | alloc_info.descriptorPool = ds_pool; |
10989 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10990 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
10991 | &descriptorSet); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 10992 | ASSERT_VK_SUCCESS(err); |
10993 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10994 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10995 | pipe_ms_state_ci.sType = |
10996 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
10997 | pipe_ms_state_ci.pNext = NULL; | ||||
10998 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; | ||||
10999 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
11000 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
11001 | pipe_ms_state_ci.pSampleMask = NULL; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11002 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11003 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11004 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
11005 | pipeline_layout_ci.pNext = NULL; | ||||
11006 | pipeline_layout_ci.setLayoutCount = 1; | ||||
11007 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11008 | |
11009 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11010 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
11011 | &pipeline_layout); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11012 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 11013 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11014 | VkShaderObj vs(m_device, bindStateVertShaderText, |
11015 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11016 | // We shouldn't need a fragment shader but add it to be able to run |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11017 | // on more devices |
11018 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
11019 | VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11020 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 11021 | VkPipelineObj pipe(m_device); |
11022 | pipe.AddShader(&vs); | ||||
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 11023 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 11024 | pipe.SetMSAA(&pipe_ms_state_ci); |
11025 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 11026 | |
11027 | BeginCommandBuffer(); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11028 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11029 | // Main thing we care about for this test is that the VkImage obj we're |
11030 | // clearing matches Color Attachment of FB | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11031 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 11032 | VkClearAttachment color_attachment; |
11033 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
11034 | color_attachment.clearValue.color.float32[0] = 1.0; | ||||
11035 | color_attachment.clearValue.color.float32[1] = 1.0; | ||||
11036 | color_attachment.clearValue.color.float32[2] = 1.0; | ||||
11037 | color_attachment.clearValue.color.float32[3] = 1.0; | ||||
11038 | color_attachment.colorAttachment = 0; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11039 | VkClearRect clear_rect = { |
11040 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11041 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11042 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
11043 | &color_attachment, 1, &clear_rect); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11044 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11045 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 11046 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11047 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
11048 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
11049 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11050 | } |
11051 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11052 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
11053 | VkResult err; | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11054 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11055 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 11056 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 11057 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11058 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11059 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 11060 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11061 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11062 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11063 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11064 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
11065 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11066 | |
11067 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11068 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
11069 | ds_pool_ci.pNext = NULL; | ||||
11070 | ds_pool_ci.maxSets = 1; | ||||
11071 | ds_pool_ci.poolSizeCount = 1; | ||||
11072 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11073 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 11074 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11075 | err = |
11076 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11077 | ASSERT_VK_SUCCESS(err); |
11078 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11079 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11080 | dsl_binding.binding = 0; |
11081 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
11082 | dsl_binding.descriptorCount = 1; | ||||
11083 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
11084 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11085 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11086 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11087 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
11088 | ds_layout_ci.pNext = NULL; | ||||
11089 | ds_layout_ci.bindingCount = 1; | ||||
11090 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11091 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11092 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11093 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
11094 | &ds_layout); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11095 | ASSERT_VK_SUCCESS(err); |
11096 | |||||
11097 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11098 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11099 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11100 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 11101 | alloc_info.descriptorPool = ds_pool; |
11102 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11103 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
11104 | &descriptorSet); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11105 | ASSERT_VK_SUCCESS(err); |
11106 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11107 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11108 | pipe_ms_state_ci.sType = |
11109 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
11110 | pipe_ms_state_ci.pNext = NULL; | ||||
11111 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; | ||||
11112 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
11113 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
11114 | pipe_ms_state_ci.pSampleMask = NULL; | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11115 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11116 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11117 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
11118 | pipeline_layout_ci.pNext = NULL; | ||||
11119 | pipeline_layout_ci.setLayoutCount = 1; | ||||
11120 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
11121 | VkPipelineLayout pipeline_layout; | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11122 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11123 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
11124 | &pipeline_layout); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11125 | ASSERT_VK_SUCCESS(err); |
11126 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11127 | VkShaderObj vs(m_device, bindStateVertShaderText, |
11128 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
11129 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
11130 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11131 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11132 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 11133 | VkPipelineObj pipe(m_device); |
11134 | pipe.AddShader(&vs); | ||||
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 11135 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 11136 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 11137 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 11138 | pipe.SetViewport(m_viewports); |
11139 | pipe.SetScissor(m_scissors); | ||||
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 11140 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 11141 | |
11142 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11143 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
11144 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 11145 | // Don't care about actual data, just need to get to draw to flag error |
11146 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11147 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
11148 | (const void *)&vbo_data); | ||||
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 11149 | 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] | 11150 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11151 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11152 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 11153 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11154 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
11155 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
11156 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11157 | } |
Mark Mueller | dfe3755 | 2016-07-07 14:47:42 -0600 | [diff] [blame] | 11158 | |
11159 | TEST_F(VkLayerTest, VertexBufferInvalid) { | ||||
11160 | TEST_DESCRIPTION("Submit a command buffer using deleted vertex buffer, " | ||||
11161 | "delete a buffer twice, use an invalid offset for each " | ||||
11162 | "buffer type, and attempt to bind a null buffer"); | ||||
11163 | |||||
11164 | const char *deleted_buffer_in_command_buffer = "Cannot submit cmd buffer " | ||||
11165 | "using deleted buffer "; | ||||
11166 | const char *double_destroy_message = "Cannot free buffer 0x"; | ||||
11167 | const char *invalid_offset_message = "vkBindBufferMemory(): " | ||||
11168 | "memoryOffset is 0x"; | ||||
11169 | const char *invalid_storage_buffer_offset_message = "vkBindBufferMemory(): " | ||||
11170 | "storage memoryOffset " | ||||
11171 | "is 0x"; | ||||
11172 | const char *invalid_texel_buffer_offset_message = "vkBindBufferMemory(): " | ||||
11173 | "texel memoryOffset " | ||||
11174 | "is 0x"; | ||||
11175 | const char *invalid_uniform_buffer_offset_message = "vkBindBufferMemory(): " | ||||
11176 | "uniform memoryOffset " | ||||
11177 | "is 0x"; | ||||
11178 | const char *bind_null_buffer_message = "In vkBindBufferMemory, attempting" | ||||
11179 | " to Bind Obj(0x"; | ||||
11180 | const char *free_invalid_buffer_message = "Request to delete memory " | ||||
11181 | "object 0x"; | ||||
11182 | |||||
11183 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
11184 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
11185 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11186 | |||||
11187 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; | ||||
11188 | pipe_ms_state_ci.sType = | ||||
11189 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
11190 | pipe_ms_state_ci.pNext = NULL; | ||||
11191 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; | ||||
11192 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
11193 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
11194 | pipe_ms_state_ci.pSampleMask = nullptr; | ||||
11195 | |||||
11196 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
11197 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
11198 | VkPipelineLayout pipeline_layout; | ||||
11199 | |||||
11200 | VkResult err = vkCreatePipelineLayout(m_device->device(), | ||||
11201 | &pipeline_layout_ci, nullptr, | ||||
11202 | &pipeline_layout); | ||||
11203 | ASSERT_VK_SUCCESS(err); | ||||
11204 | |||||
11205 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
11206 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
11207 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
11208 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
11209 | this); | ||||
11210 | VkPipelineObj pipe(m_device); | ||||
11211 | pipe.AddShader(&vs); | ||||
11212 | pipe.AddShader(&fs); | ||||
11213 | pipe.AddColorAttachment(); | ||||
11214 | pipe.SetMSAA(&pipe_ms_state_ci); | ||||
11215 | pipe.SetViewport(m_viewports); | ||||
11216 | pipe.SetScissor(m_scissors); | ||||
11217 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
11218 | |||||
11219 | BeginCommandBuffer(); | ||||
11220 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
11221 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
11222 | |||||
11223 | { | ||||
11224 | // Create and bind a vertex buffer in a reduced scope, which will cause | ||||
11225 | // it to be deleted upon leaving this scope | ||||
11226 | const float vbo_data[3] = {1.f, 0.f, 1.f}; | ||||
11227 | VkVerticesObj draw_verticies(m_device, 1, 1, sizeof(vbo_data), | ||||
11228 | 3, vbo_data); | ||||
11229 | draw_verticies.BindVertexBuffers(m_commandBuffer->handle()); | ||||
11230 | draw_verticies.AddVertexInputToPipe(pipe); | ||||
11231 | } | ||||
11232 | |||||
11233 | Draw(1, 0, 0, 0); | ||||
11234 | |||||
11235 | EndCommandBuffer(); | ||||
11236 | |||||
11237 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11238 | deleted_buffer_in_command_buffer); | ||||
11239 | QueueCommandBuffer(false); | ||||
11240 | m_errorMonitor->VerifyFound(); | ||||
11241 | |||||
11242 | { | ||||
11243 | // Create and bind a vertex buffer in a reduced scope, and delete it | ||||
11244 | // twice, the second through the destructor | ||||
11245 | VkBufferTest buffer_test(m_device, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, | ||||
11246 | VkBufferTest::eDoubleDelete); | ||||
11247 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11248 | double_destroy_message); | ||||
11249 | buffer_test.TestDoubleDestroy(); | ||||
11250 | } | ||||
11251 | m_errorMonitor->VerifyFound(); | ||||
11252 | |||||
11253 | if (VkBufferTest:: | ||||
11254 | GetTestConditionValid(m_device, | ||||
11255 | VkBufferTest::eInvalidMemoryOffset)) { | ||||
11256 | // Create and bind a memory buffer with an invalid offset. | ||||
11257 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11258 | invalid_offset_message); | ||||
11259 | VkBufferTest buffer_test(m_device, | ||||
11260 | VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, | ||||
11261 | VkBufferTest::eInvalidMemoryOffset); | ||||
11262 | (void) buffer_test; | ||||
11263 | m_errorMonitor->VerifyFound(); | ||||
11264 | } | ||||
11265 | |||||
11266 | if (VkBufferTest:: | ||||
11267 | GetTestConditionValid(m_device, | ||||
11268 | VkBufferTest::eInvalidDeviceOffset, | ||||
11269 | VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT)) { | ||||
11270 | // Create and bind a memory buffer with an invalid offset again, | ||||
11271 | // but look for a texel buffer message. | ||||
11272 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11273 | invalid_texel_buffer_offset_message); | ||||
11274 | VkBufferTest buffer_test(m_device, | ||||
11275 | VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, | ||||
11276 | VkBufferTest::eInvalidDeviceOffset); | ||||
11277 | (void) buffer_test; | ||||
11278 | m_errorMonitor->VerifyFound(); | ||||
11279 | } | ||||
11280 | |||||
11281 | if (VkBufferTest:: | ||||
11282 | GetTestConditionValid(m_device, | ||||
11283 | VkBufferTest::eInvalidDeviceOffset, | ||||
11284 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) { | ||||
11285 | // Create and bind a memory buffer with an invalid offset again, but | ||||
11286 | // look for a uniform buffer message. | ||||
11287 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11288 | invalid_uniform_buffer_offset_message); | ||||
11289 | VkBufferTest buffer_test(m_device, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, | ||||
11290 | VkBufferTest::eInvalidDeviceOffset); | ||||
11291 | (void) buffer_test; | ||||
11292 | m_errorMonitor->VerifyFound(); | ||||
11293 | } | ||||
11294 | |||||
11295 | if (VkBufferTest:: | ||||
11296 | GetTestConditionValid(m_device, | ||||
11297 | VkBufferTest::eInvalidDeviceOffset, | ||||
11298 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)) { | ||||
11299 | // Create and bind a memory buffer with an invalid offset again, but | ||||
11300 | // look for a storage buffer message. | ||||
11301 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11302 | invalid_storage_buffer_offset_message); | ||||
11303 | VkBufferTest buffer_test(m_device, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, | ||||
11304 | VkBufferTest::eInvalidDeviceOffset); | ||||
11305 | (void) buffer_test; | ||||
11306 | m_errorMonitor->VerifyFound(); | ||||
11307 | } | ||||
11308 | |||||
11309 | { | ||||
11310 | // Attempt to bind a null buffer. | ||||
11311 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11312 | bind_null_buffer_message); | ||||
11313 | VkBufferTest buffer_test(m_device, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, | ||||
11314 | VkBufferTest::eBindNullBuffer); | ||||
11315 | (void) buffer_test; | ||||
11316 | m_errorMonitor->VerifyFound(); | ||||
11317 | } | ||||
11318 | |||||
11319 | { | ||||
11320 | // Attempt to use an invalid handle to delete a buffer. | ||||
11321 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11322 | free_invalid_buffer_message); | ||||
11323 | VkBufferTest buffer_test(m_device, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, | ||||
11324 | VkBufferTest::eFreeInvalidHandle); | ||||
11325 | (void) buffer_test; | ||||
11326 | } | ||||
11327 | m_errorMonitor->VerifyFound(); | ||||
11328 | |||||
11329 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
11330 | } | ||||
11331 | |||||
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 11332 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
11333 | TEST_F(VkLayerTest, InvalidImageLayout) { | ||||
11334 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " | ||||
11335 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" | ||||
11336 | "images in the wrong layout when they're copied or transitioned."); | ||||
11337 | // 3 in ValidateCmdBufImageLayouts | ||||
11338 | // * -1 Attempt to submit cmd buf w/ deleted image | ||||
11339 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource | ||||
11340 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource | ||||
11341 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11342 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
11343 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); | ||||
11344 | |||||
11345 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
11346 | // Create src & dst images to use for copy operations | ||||
11347 | VkImage src_image; | ||||
11348 | VkImage dst_image; | ||||
11349 | |||||
11350 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
11351 | const int32_t tex_width = 32; | ||||
11352 | const int32_t tex_height = 32; | ||||
11353 | |||||
11354 | VkImageCreateInfo image_create_info = {}; | ||||
11355 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
11356 | image_create_info.pNext = NULL; | ||||
11357 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
11358 | image_create_info.format = tex_format; | ||||
11359 | image_create_info.extent.width = tex_width; | ||||
11360 | image_create_info.extent.height = tex_height; | ||||
11361 | image_create_info.extent.depth = 1; | ||||
11362 | image_create_info.mipLevels = 1; | ||||
11363 | image_create_info.arrayLayers = 4; | ||||
11364 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
11365 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
11366 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
11367 | image_create_info.flags = 0; | ||||
11368 | |||||
11369 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); | ||||
11370 | ASSERT_VK_SUCCESS(err); | ||||
11371 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); | ||||
11372 | ASSERT_VK_SUCCESS(err); | ||||
11373 | |||||
11374 | BeginCommandBuffer(); | ||||
11375 | VkImageCopy copyRegion; | ||||
11376 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
11377 | copyRegion.srcSubresource.mipLevel = 0; | ||||
11378 | copyRegion.srcSubresource.baseArrayLayer = 0; | ||||
11379 | copyRegion.srcSubresource.layerCount = 1; | ||||
11380 | copyRegion.srcOffset.x = 0; | ||||
11381 | copyRegion.srcOffset.y = 0; | ||||
11382 | copyRegion.srcOffset.z = 0; | ||||
11383 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
11384 | copyRegion.dstSubresource.mipLevel = 0; | ||||
11385 | copyRegion.dstSubresource.baseArrayLayer = 0; | ||||
11386 | copyRegion.dstSubresource.layerCount = 1; | ||||
11387 | copyRegion.dstOffset.x = 0; | ||||
11388 | copyRegion.dstOffset.y = 0; | ||||
11389 | copyRegion.dstOffset.z = 0; | ||||
11390 | copyRegion.extent.width = 1; | ||||
11391 | copyRegion.extent.height = 1; | ||||
11392 | copyRegion.extent.depth = 1; | ||||
11393 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
11394 | m_errorMonitor->VerifyFound(); | ||||
11395 | // Now cause error due to src image layout changing | ||||
11396 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11397 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11398 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); | ||||
11399 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
11400 | m_errorMonitor->VerifyFound(); | ||||
11401 | // Final src error is due to bad layout type | ||||
11402 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11403 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11404 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); | ||||
11405 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
11406 | m_errorMonitor->VerifyFound(); | ||||
11407 | // Now verify same checks for dst | ||||
11408 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11409 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
11410 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); | ||||
11411 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
11412 | m_errorMonitor->VerifyFound(); | ||||
11413 | // Now cause error due to src image layout changing | ||||
11414 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11415 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11416 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); | ||||
11417 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); | ||||
11418 | m_errorMonitor->VerifyFound(); | ||||
11419 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11420 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11421 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); | ||||
11422 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); | ||||
11423 | m_errorMonitor->VerifyFound(); | ||||
11424 | // Now cause error due to bad image layout transition in PipelineBarrier | ||||
11425 | VkImageMemoryBarrier image_barrier[1] = {}; | ||||
11426 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; | ||||
11427 | image_barrier[0].image = src_image; | ||||
11428 | image_barrier[0].subresourceRange.layerCount = 2; | ||||
11429 | image_barrier[0].subresourceRange.levelCount = 2; | ||||
11430 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
11431 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11432 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11433 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); | ||||
11434 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); | ||||
11435 | m_errorMonitor->VerifyFound(); | ||||
11436 | |||||
11437 | // Finally some layout errors at RenderPass create time | ||||
11438 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. | ||||
11439 | VkAttachmentReference attach = {}; | ||||
11440 | // perf warning for GENERAL layout w/ non-DS input attachment | ||||
11441 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
11442 | VkSubpassDescription subpass = {}; | ||||
11443 | subpass.inputAttachmentCount = 1; | ||||
11444 | subpass.pInputAttachments = &attach; | ||||
11445 | VkRenderPassCreateInfo rpci = {}; | ||||
11446 | rpci.subpassCount = 1; | ||||
11447 | rpci.pSubpasses = &subpass; | ||||
11448 | rpci.attachmentCount = 1; | ||||
11449 | VkAttachmentDescription attach_desc = {}; | ||||
11450 | attach_desc.format = VK_FORMAT_UNDEFINED; | ||||
11451 | rpci.pAttachments = &attach_desc; | ||||
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 11452 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 11453 | VkRenderPass rp; |
11454 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11455 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
11456 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); | ||||
11457 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
11458 | m_errorMonitor->VerifyFound(); | ||||
11459 | // error w/ non-general layout | ||||
11460 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; | ||||
11461 | |||||
11462 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11463 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11464 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); | ||||
11465 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
11466 | m_errorMonitor->VerifyFound(); | ||||
11467 | subpass.inputAttachmentCount = 0; | ||||
11468 | subpass.colorAttachmentCount = 1; | ||||
11469 | subpass.pColorAttachments = &attach; | ||||
11470 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
11471 | // perf warning for GENERAL layout on color attachment | ||||
11472 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11473 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
11474 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); | ||||
11475 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
11476 | m_errorMonitor->VerifyFound(); | ||||
11477 | // error w/ non-color opt or GENERAL layout for color attachment | ||||
11478 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; | ||||
11479 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11480 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11481 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); | ||||
11482 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
11483 | m_errorMonitor->VerifyFound(); | ||||
11484 | subpass.colorAttachmentCount = 0; | ||||
11485 | subpass.pDepthStencilAttachment = &attach; | ||||
11486 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
11487 | // perf warning for GENERAL layout on DS attachment | ||||
11488 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11489 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
11490 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); | ||||
11491 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
11492 | m_errorMonitor->VerifyFound(); | ||||
11493 | // error w/ non-ds opt or GENERAL layout for color attachment | ||||
11494 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; | ||||
11495 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11496 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11497 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); | ||||
11498 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
11499 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 11500 | // For this error we need a valid renderpass so create default one |
11501 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; | ||||
11502 | attach.attachment = 0; | ||||
11503 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
11504 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
11505 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; | ||||
11506 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; | ||||
11507 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; | ||||
11508 | // Can't do a CLEAR load on READ_ONLY initialLayout | ||||
11509 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; | ||||
11510 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; | ||||
11511 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
11512 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11513 | " with invalid first layout " | ||||
11514 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" | ||||
11515 | "ONLY_OPTIMAL"); | ||||
11516 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
11517 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 11518 | |
11519 | vkDestroyImage(m_device->device(), src_image, NULL); | ||||
11520 | vkDestroyImage(m_device->device(), dst_image, NULL); | ||||
11521 | } | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 11522 | #endif // DRAW_STATE_TESTS |
11523 | |||||
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 11524 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11525 | #if GTEST_IS_THREADSAFE |
11526 | struct thread_data_struct { | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11527 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11528 | VkEvent event; |
11529 | bool bailout; | ||||
11530 | }; | ||||
11531 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11532 | extern "C" void *AddToCommandBuffer(void *arg) { |
11533 | struct thread_data_struct *data = (struct thread_data_struct *)arg; | ||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11534 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11535 | for (int i = 0; i < 10000; i++) { |
11536 | vkCmdSetEvent(data->commandBuffer, data->event, | ||||
11537 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); | ||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11538 | if (data->bailout) { |
11539 | break; | ||||
11540 | } | ||||
11541 | } | ||||
11542 | return NULL; | ||||
11543 | } | ||||
11544 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11545 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 11546 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11547 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11548 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
11549 | "THREADING ERROR"); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11550 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11551 | ASSERT_NO_FATAL_FAILURE(InitState()); |
11552 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
11553 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11554 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11555 | // Calls AllocateCommandBuffers |
11556 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); | ||||
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 11557 | |
11558 | // Avoid creating RenderPass | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11559 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11560 | |
11561 | VkEventCreateInfo event_info; | ||||
11562 | VkEvent event; | ||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11563 | VkResult err; |
11564 | |||||
11565 | memset(&event_info, 0, sizeof(event_info)); | ||||
11566 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
11567 | |||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11568 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11569 | ASSERT_VK_SUCCESS(err); |
11570 | |||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11571 | err = vkResetEvent(device(), event); |
11572 | ASSERT_VK_SUCCESS(err); | ||||
11573 | |||||
11574 | struct thread_data_struct data; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11575 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11576 | data.event = event; |
11577 | data.bailout = false; | ||||
11578 | m_errorMonitor->SetBailout(&data.bailout); | ||||
11579 | // Add many entries to command buffer from another thread. | ||||
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 11580 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11581 | // Add many entries to command buffer from this thread at the same time. |
11582 | AddToCommandBuffer(&data); | ||||
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 11583 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 11584 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11585 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11586 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 11587 | m_errorMonitor->SetBailout(NULL); |
11588 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11589 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11590 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11591 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 11592 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 11593 | #endif // GTEST_IS_THREADSAFE |
11594 | #endif // THREADING_TESTS | ||||
11595 | |||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11596 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11597 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11598 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 11599 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11600 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11601 | ASSERT_NO_FATAL_FAILURE(InitState()); |
11602 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11603 | |||||
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11604 | VkShaderModule module; |
11605 | VkShaderModuleCreateInfo moduleCreateInfo; | ||||
11606 | struct icd_spv_header spv; | ||||
11607 | |||||
11608 | spv.magic = ICD_SPV_MAGIC; | ||||
11609 | spv.version = ICD_SPV_VERSION; | ||||
11610 | spv.gen_magic = 0; | ||||
11611 | |||||
11612 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; | ||||
11613 | moduleCreateInfo.pNext = NULL; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11614 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11615 | moduleCreateInfo.codeSize = 4; |
11616 | moduleCreateInfo.flags = 0; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11617 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11618 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11619 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11620 | } |
11621 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11622 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11623 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 11624 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11625 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11626 | ASSERT_NO_FATAL_FAILURE(InitState()); |
11627 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11628 | |||||
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11629 | VkShaderModule module; |
11630 | VkShaderModuleCreateInfo moduleCreateInfo; | ||||
11631 | struct icd_spv_header spv; | ||||
11632 | |||||
11633 | spv.magic = ~ICD_SPV_MAGIC; | ||||
11634 | spv.version = ICD_SPV_VERSION; | ||||
11635 | spv.gen_magic = 0; | ||||
11636 | |||||
11637 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; | ||||
11638 | moduleCreateInfo.pNext = NULL; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11639 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11640 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
11641 | moduleCreateInfo.flags = 0; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11642 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11643 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11644 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11645 | } |
11646 | |||||
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 11647 | #if 0 |
11648 | // Not currently covered by SPIRV-Tools validator | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11649 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11650 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 11651 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11652 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11653 | ASSERT_NO_FATAL_FAILURE(InitState()); |
11654 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11655 | |||||
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11656 | VkShaderModule module; |
11657 | VkShaderModuleCreateInfo moduleCreateInfo; | ||||
11658 | struct icd_spv_header spv; | ||||
11659 | |||||
11660 | spv.magic = ICD_SPV_MAGIC; | ||||
11661 | spv.version = ~ICD_SPV_VERSION; | ||||
11662 | spv.gen_magic = 0; | ||||
11663 | |||||
11664 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; | ||||
11665 | moduleCreateInfo.pNext = NULL; | ||||
11666 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11667 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11668 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
11669 | moduleCreateInfo.flags = 0; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11670 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11671 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11672 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11673 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 11674 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 11675 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11676 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 11677 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11678 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11679 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11680 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 11681 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11682 | |
11683 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11684 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11685 | "\n" |
11686 | "layout(location=0) out float x;\n" | ||||
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11687 | "out gl_PerVertex {\n" |
11688 | " vec4 gl_Position;\n" | ||||
11689 | "};\n" | ||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11690 | "void main(){\n" |
11691 | " gl_Position = vec4(1);\n" | ||||
11692 | " x = 0;\n" | ||||
11693 | "}\n"; | ||||
11694 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11695 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11696 | "\n" |
11697 | "layout(location=0) out vec4 color;\n" | ||||
11698 | "void main(){\n" | ||||
11699 | " color = vec4(1);\n" | ||||
11700 | "}\n"; | ||||
11701 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11702 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
11703 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11704 | |
11705 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11706 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11707 | pipe.AddShader(&vs); |
11708 | pipe.AddShader(&fs); | ||||
11709 | |||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11710 | VkDescriptorSetObj descriptorSet(m_device); |
11711 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11712 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11713 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11714 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11715 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11716 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11717 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 11718 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11719 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11720 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11721 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11722 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 11723 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 11724 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 11725 | |
11726 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11727 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 11728 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11729 | "out gl_PerVertex {\n" |
11730 | " vec4 gl_Position;\n" | ||||
11731 | "};\n" | ||||
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 11732 | "void main(){\n" |
11733 | " gl_Position = vec4(1);\n" | ||||
11734 | "}\n"; | ||||
11735 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11736 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 11737 | "\n" |
11738 | "layout(location=0) in float x;\n" | ||||
11739 | "layout(location=0) out vec4 color;\n" | ||||
11740 | "void main(){\n" | ||||
11741 | " color = vec4(x);\n" | ||||
11742 | "}\n"; | ||||
11743 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11744 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
11745 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 11746 | |
11747 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11748 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 11749 | pipe.AddShader(&vs); |
11750 | pipe.AddShader(&fs); | ||||
11751 | |||||
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 11752 | VkDescriptorSetObj descriptorSet(m_device); |
11753 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11754 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 11755 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11756 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 11757 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11758 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 11759 | } |
11760 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11761 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 11762 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11763 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 11764 | |
11765 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
11766 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11767 | |||||
11768 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11769 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 11770 | "\n" |
11771 | "out gl_PerVertex {\n" | ||||
11772 | " vec4 gl_Position;\n" | ||||
11773 | "};\n" | ||||
11774 | "void main(){\n" | ||||
11775 | " gl_Position = vec4(1);\n" | ||||
11776 | "}\n"; | ||||
11777 | char const *fsSource = | ||||
11778 | "#version 450\n" | ||||
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 11779 | "\n" |
11780 | "in block { layout(location=0) float x; } ins;\n" | ||||
11781 | "layout(location=0) out vec4 color;\n" | ||||
11782 | "void main(){\n" | ||||
11783 | " color = vec4(ins.x);\n" | ||||
11784 | "}\n"; | ||||
11785 | |||||
11786 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
11787 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
11788 | |||||
11789 | VkPipelineObj pipe(m_device); | ||||
11790 | pipe.AddColorAttachment(); | ||||
11791 | pipe.AddShader(&vs); | ||||
11792 | pipe.AddShader(&fs); | ||||
11793 | |||||
11794 | VkDescriptorSetObj descriptorSet(m_device); | ||||
11795 | descriptorSet.AppendDummy(); | ||||
11796 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
11797 | |||||
11798 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
11799 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11800 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 11801 | } |
11802 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11803 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 11804 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 11805 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11806 | "output arr[2] of float32' vs 'ptr to " |
11807 | "input arr[3] of float32'"); | ||||
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 11808 | |
11809 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
11810 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11811 | |||||
11812 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11813 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 11814 | "\n" |
11815 | "layout(location=0) out float x[2];\n" | ||||
11816 | "out gl_PerVertex {\n" | ||||
11817 | " vec4 gl_Position;\n" | ||||
11818 | "};\n" | ||||
11819 | "void main(){\n" | ||||
11820 | " x[0] = 0; x[1] = 0;\n" | ||||
11821 | " gl_Position = vec4(1);\n" | ||||
11822 | "}\n"; | ||||
11823 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11824 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 11825 | "\n" |
11826 | "layout(location=0) in float x[3];\n" | ||||
11827 | "layout(location=0) out vec4 color;\n" | ||||
11828 | "void main(){\n" | ||||
11829 | " color = vec4(x[0] + x[1] + x[2]);\n" | ||||
11830 | "}\n"; | ||||
11831 | |||||
11832 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
11833 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
11834 | |||||
11835 | VkPipelineObj pipe(m_device); | ||||
11836 | pipe.AddColorAttachment(); | ||||
11837 | pipe.AddShader(&vs); | ||||
11838 | pipe.AddShader(&fs); | ||||
11839 | |||||
11840 | VkDescriptorSetObj descriptorSet(m_device); | ||||
11841 | descriptorSet.AppendDummy(); | ||||
11842 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
11843 | |||||
11844 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
11845 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11846 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 11847 | } |
11848 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11849 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11850 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11851 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11852 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 11853 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 11854 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 11855 | |
11856 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11857 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 11858 | "\n" |
11859 | "layout(location=0) out int x;\n" | ||||
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 11860 | "out gl_PerVertex {\n" |
11861 | " vec4 gl_Position;\n" | ||||
11862 | "};\n" | ||||
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 11863 | "void main(){\n" |
11864 | " x = 0;\n" | ||||
11865 | " gl_Position = vec4(1);\n" | ||||
11866 | "}\n"; | ||||
11867 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 11868 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 11869 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11870 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 11871 | "layout(location=0) out vec4 color;\n" |
11872 | "void main(){\n" | ||||
11873 | " color = vec4(x);\n" | ||||
11874 | "}\n"; | ||||
11875 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 11876 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
11877 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 11878 | |
11879 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 11880 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 11881 | pipe.AddShader(&vs); |
11882 | pipe.AddShader(&fs); | ||||
11883 | |||||
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 11884 | VkDescriptorSetObj descriptorSet(m_device); |
11885 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11886 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 11887 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 11888 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 11889 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11890 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 11891 | } |
11892 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11893 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 11894 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11895 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 11896 | |
11897 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
11898 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11899 | |||||
11900 | char const *vsSource = | ||||
11901 | "#version 450\n" | ||||
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 11902 | "\n" |
11903 | "out block { layout(location=0) int x; } outs;\n" | ||||
11904 | "out gl_PerVertex {\n" | ||||
11905 | " vec4 gl_Position;\n" | ||||
11906 | "};\n" | ||||
11907 | "void main(){\n" | ||||
11908 | " outs.x = 0;\n" | ||||
11909 | " gl_Position = vec4(1);\n" | ||||
11910 | "}\n"; | ||||
11911 | char const *fsSource = | ||||
11912 | "#version 450\n" | ||||
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 11913 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11914 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 11915 | "layout(location=0) out vec4 color;\n" |
11916 | "void main(){\n" | ||||
11917 | " color = vec4(ins.x);\n" | ||||
11918 | "}\n"; | ||||
11919 | |||||
11920 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
11921 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
11922 | |||||
11923 | VkPipelineObj pipe(m_device); | ||||
11924 | pipe.AddColorAttachment(); | ||||
11925 | pipe.AddShader(&vs); | ||||
11926 | pipe.AddShader(&fs); | ||||
11927 | |||||
11928 | VkDescriptorSetObj descriptorSet(m_device); | ||||
11929 | descriptorSet.AppendDummy(); | ||||
11930 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
11931 | |||||
11932 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
11933 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11934 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 11935 | } |
11936 | |||||
11937 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { | ||||
11938 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11939 | "location 0.0 which is not written by vertex shader"); | ||||
11940 | |||||
11941 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
11942 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11943 | |||||
11944 | char const *vsSource = | ||||
11945 | "#version 450\n" | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 11946 | "\n" |
11947 | "out block { layout(location=1) float x; } outs;\n" | ||||
11948 | "out gl_PerVertex {\n" | ||||
11949 | " vec4 gl_Position;\n" | ||||
11950 | "};\n" | ||||
11951 | "void main(){\n" | ||||
11952 | " outs.x = 0;\n" | ||||
11953 | " gl_Position = vec4(1);\n" | ||||
11954 | "}\n"; | ||||
11955 | char const *fsSource = | ||||
11956 | "#version 450\n" | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 11957 | "\n" |
11958 | "in block { layout(location=0) float x; } ins;\n" | ||||
11959 | "layout(location=0) out vec4 color;\n" | ||||
11960 | "void main(){\n" | ||||
11961 | " color = vec4(ins.x);\n" | ||||
11962 | "}\n"; | ||||
11963 | |||||
11964 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
11965 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
11966 | |||||
11967 | VkPipelineObj pipe(m_device); | ||||
11968 | pipe.AddColorAttachment(); | ||||
11969 | pipe.AddShader(&vs); | ||||
11970 | pipe.AddShader(&fs); | ||||
11971 | |||||
11972 | VkDescriptorSetObj descriptorSet(m_device); | ||||
11973 | descriptorSet.AppendDummy(); | ||||
11974 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
11975 | |||||
11976 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
11977 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11978 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 11979 | } |
11980 | |||||
11981 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { | ||||
11982 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11983 | "location 0.1 which is not written by vertex shader"); | ||||
11984 | |||||
11985 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
11986 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11987 | |||||
11988 | char const *vsSource = | ||||
11989 | "#version 450\n" | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 11990 | "\n" |
11991 | "out block { layout(location=0, component=0) float x; } outs;\n" | ||||
11992 | "out gl_PerVertex {\n" | ||||
11993 | " vec4 gl_Position;\n" | ||||
11994 | "};\n" | ||||
11995 | "void main(){\n" | ||||
11996 | " outs.x = 0;\n" | ||||
11997 | " gl_Position = vec4(1);\n" | ||||
11998 | "}\n"; | ||||
11999 | char const *fsSource = | ||||
12000 | "#version 450\n" | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 12001 | "\n" |
12002 | "in block { layout(location=0, component=1) float x; } ins;\n" | ||||
12003 | "layout(location=0) out vec4 color;\n" | ||||
12004 | "void main(){\n" | ||||
12005 | " color = vec4(ins.x);\n" | ||||
12006 | "}\n"; | ||||
12007 | |||||
12008 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12009 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12010 | |||||
12011 | VkPipelineObj pipe(m_device); | ||||
12012 | pipe.AddColorAttachment(); | ||||
12013 | pipe.AddShader(&vs); | ||||
12014 | pipe.AddShader(&fs); | ||||
12015 | |||||
12016 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12017 | descriptorSet.AppendDummy(); | ||||
12018 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12019 | |||||
12020 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12021 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12022 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 12023 | } |
12024 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12025 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 12026 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12027 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12028 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12029 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 12030 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12031 | |
12032 | VkVertexInputBindingDescription input_binding; | ||||
12033 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
12034 | |||||
12035 | VkVertexInputAttributeDescription input_attrib; | ||||
12036 | memset(&input_attrib, 0, sizeof(input_attrib)); | ||||
12037 | input_attrib.format = VK_FORMAT_R32_SFLOAT; | ||||
12038 | |||||
12039 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12040 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12041 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12042 | "out gl_PerVertex {\n" |
12043 | " vec4 gl_Position;\n" | ||||
12044 | "};\n" | ||||
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12045 | "void main(){\n" |
12046 | " gl_Position = vec4(1);\n" | ||||
12047 | "}\n"; | ||||
12048 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12049 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12050 | "\n" |
12051 | "layout(location=0) out vec4 color;\n" | ||||
12052 | "void main(){\n" | ||||
12053 | " color = vec4(1);\n" | ||||
12054 | "}\n"; | ||||
12055 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 12056 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
12057 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12058 | |
12059 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 12060 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12061 | pipe.AddShader(&vs); |
12062 | pipe.AddShader(&fs); | ||||
12063 | |||||
12064 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
12065 | pipe.AddVertexInputAttribs(&input_attrib, 1); | ||||
12066 | |||||
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12067 | VkDescriptorSetObj descriptorSet(m_device); |
12068 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12069 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12070 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 12071 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12072 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12073 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12074 | } |
12075 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12076 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 12077 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12078 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 12079 | |
12080 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12081 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12082 | |||||
12083 | VkVertexInputBindingDescription input_binding; | ||||
12084 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
12085 | |||||
12086 | VkVertexInputAttributeDescription input_attrib; | ||||
12087 | memset(&input_attrib, 0, sizeof(input_attrib)); | ||||
12088 | input_attrib.format = VK_FORMAT_R32_SFLOAT; | ||||
12089 | |||||
12090 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12091 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 12092 | "\n" |
12093 | "layout(location=1) in float x;\n" | ||||
12094 | "out gl_PerVertex {\n" | ||||
12095 | " vec4 gl_Position;\n" | ||||
12096 | "};\n" | ||||
12097 | "void main(){\n" | ||||
12098 | " gl_Position = vec4(x);\n" | ||||
12099 | "}\n"; | ||||
12100 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12101 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 12102 | "\n" |
12103 | "layout(location=0) out vec4 color;\n" | ||||
12104 | "void main(){\n" | ||||
12105 | " color = vec4(1);\n" | ||||
12106 | "}\n"; | ||||
12107 | |||||
12108 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12109 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12110 | |||||
12111 | VkPipelineObj pipe(m_device); | ||||
12112 | pipe.AddColorAttachment(); | ||||
12113 | pipe.AddShader(&vs); | ||||
12114 | pipe.AddShader(&fs); | ||||
12115 | |||||
12116 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
12117 | pipe.AddVertexInputAttribs(&input_attrib, 1); | ||||
12118 | |||||
12119 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12120 | descriptorSet.AppendDummy(); | ||||
12121 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12122 | |||||
12123 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12124 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12125 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 12126 | } |
12127 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12128 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
12129 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12130 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12131 | "VS consumes input at location 0 but not provided"); |
12132 | |||||
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 12133 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 12134 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 12135 | |
12136 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12137 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 12138 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12139 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12140 | "out gl_PerVertex {\n" |
12141 | " vec4 gl_Position;\n" | ||||
12142 | "};\n" | ||||
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 12143 | "void main(){\n" |
12144 | " gl_Position = x;\n" | ||||
12145 | "}\n"; | ||||
12146 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12147 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 12148 | "\n" |
12149 | "layout(location=0) out vec4 color;\n" | ||||
12150 | "void main(){\n" | ||||
12151 | " color = vec4(1);\n" | ||||
12152 | "}\n"; | ||||
12153 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 12154 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
12155 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 12156 | |
12157 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 12158 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 12159 | pipe.AddShader(&vs); |
12160 | pipe.AddShader(&fs); | ||||
12161 | |||||
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 12162 | VkDescriptorSetObj descriptorSet(m_device); |
12163 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12164 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 12165 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 12166 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 12167 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12168 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 12169 | } |
12170 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12171 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
12172 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12173 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12174 | "location 0 does not match VS input type"); |
12175 | |||||
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 12176 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 12177 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 12178 | |
12179 | VkVertexInputBindingDescription input_binding; | ||||
12180 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
12181 | |||||
12182 | VkVertexInputAttributeDescription input_attrib; | ||||
12183 | memset(&input_attrib, 0, sizeof(input_attrib)); | ||||
12184 | input_attrib.format = VK_FORMAT_R32_SFLOAT; | ||||
12185 | |||||
12186 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12187 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 12188 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12189 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12190 | "out gl_PerVertex {\n" |
12191 | " vec4 gl_Position;\n" | ||||
12192 | "};\n" | ||||
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 12193 | "void main(){\n" |
12194 | " gl_Position = vec4(x);\n" | ||||
12195 | "}\n"; | ||||
12196 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12197 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 12198 | "\n" |
12199 | "layout(location=0) out vec4 color;\n" | ||||
12200 | "void main(){\n" | ||||
12201 | " color = vec4(1);\n" | ||||
12202 | "}\n"; | ||||
12203 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 12204 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
12205 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 12206 | |
12207 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 12208 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 12209 | pipe.AddShader(&vs); |
12210 | pipe.AddShader(&fs); | ||||
12211 | |||||
12212 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
12213 | pipe.AddVertexInputAttribs(&input_attrib, 1); | ||||
12214 | |||||
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 12215 | VkDescriptorSetObj descriptorSet(m_device); |
12216 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12217 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 12218 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 12219 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 12220 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12221 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 12222 | } |
12223 | |||||
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 12224 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
12225 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12226 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12227 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); | ||||
12228 | |||||
12229 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12230 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12231 | |||||
12232 | char const *vsSource = | ||||
12233 | "#version 450\n" | ||||
12234 | "\n" | ||||
12235 | "out gl_PerVertex {\n" | ||||
12236 | " vec4 gl_Position;\n" | ||||
12237 | "};\n" | ||||
12238 | "void main(){\n" | ||||
12239 | " gl_Position = vec4(1);\n" | ||||
12240 | "}\n"; | ||||
12241 | char const *fsSource = | ||||
12242 | "#version 450\n" | ||||
12243 | "\n" | ||||
12244 | "layout(location=0) out vec4 color;\n" | ||||
12245 | "void main(){\n" | ||||
12246 | " color = vec4(1);\n" | ||||
12247 | "}\n"; | ||||
12248 | |||||
12249 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12250 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12251 | |||||
12252 | VkPipelineObj pipe(m_device); | ||||
12253 | pipe.AddColorAttachment(); | ||||
12254 | pipe.AddShader(&vs); | ||||
12255 | pipe.AddShader(&vs); | ||||
12256 | pipe.AddShader(&fs); | ||||
12257 | |||||
12258 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12259 | descriptorSet.AppendDummy(); | ||||
12260 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12261 | |||||
12262 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12263 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12264 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 12265 | } |
12266 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12267 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12268 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 12269 | |
12270 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12271 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12272 | |||||
12273 | VkVertexInputBindingDescription input_binding; | ||||
12274 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
12275 | |||||
12276 | VkVertexInputAttributeDescription input_attribs[2]; | ||||
12277 | memset(input_attribs, 0, sizeof(input_attribs)); | ||||
12278 | |||||
12279 | for (int i = 0; i < 2; i++) { | ||||
12280 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; | ||||
12281 | input_attribs[i].location = i; | ||||
12282 | } | ||||
12283 | |||||
12284 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12285 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 12286 | "\n" |
12287 | "layout(location=0) in mat2x4 x;\n" | ||||
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12288 | "out gl_PerVertex {\n" |
12289 | " vec4 gl_Position;\n" | ||||
12290 | "};\n" | ||||
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 12291 | "void main(){\n" |
12292 | " gl_Position = x[0] + x[1];\n" | ||||
12293 | "}\n"; | ||||
12294 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12295 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 12296 | "\n" |
12297 | "layout(location=0) out vec4 color;\n" | ||||
12298 | "void main(){\n" | ||||
12299 | " color = vec4(1);\n" | ||||
12300 | "}\n"; | ||||
12301 | |||||
12302 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12303 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12304 | |||||
12305 | VkPipelineObj pipe(m_device); | ||||
12306 | pipe.AddColorAttachment(); | ||||
12307 | pipe.AddShader(&vs); | ||||
12308 | pipe.AddShader(&fs); | ||||
12309 | |||||
12310 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
12311 | pipe.AddVertexInputAttribs(input_attribs, 2); | ||||
12312 | |||||
12313 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12314 | descriptorSet.AppendDummy(); | ||||
12315 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12316 | |||||
12317 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12318 | |||||
12319 | /* expect success */ | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12320 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 12321 | } |
12322 | |||||
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 12323 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
12324 | { | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12325 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 12326 | |
12327 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12328 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12329 | |||||
12330 | VkVertexInputBindingDescription input_binding; | ||||
12331 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
12332 | |||||
12333 | VkVertexInputAttributeDescription input_attribs[2]; | ||||
12334 | memset(input_attribs, 0, sizeof(input_attribs)); | ||||
12335 | |||||
12336 | for (int i = 0; i < 2; i++) { | ||||
12337 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; | ||||
12338 | input_attribs[i].location = i; | ||||
12339 | } | ||||
12340 | |||||
12341 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12342 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 12343 | "\n" |
12344 | "layout(location=0) in vec4 x[2];\n" | ||||
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12345 | "out gl_PerVertex {\n" |
12346 | " vec4 gl_Position;\n" | ||||
12347 | "};\n" | ||||
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 12348 | "void main(){\n" |
12349 | " gl_Position = x[0] + x[1];\n" | ||||
12350 | "}\n"; | ||||
12351 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12352 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 12353 | "\n" |
12354 | "layout(location=0) out vec4 color;\n" | ||||
12355 | "void main(){\n" | ||||
12356 | " color = vec4(1);\n" | ||||
12357 | "}\n"; | ||||
12358 | |||||
12359 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12360 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12361 | |||||
12362 | VkPipelineObj pipe(m_device); | ||||
12363 | pipe.AddColorAttachment(); | ||||
12364 | pipe.AddShader(&vs); | ||||
12365 | pipe.AddShader(&fs); | ||||
12366 | |||||
12367 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
12368 | pipe.AddVertexInputAttribs(input_attribs, 2); | ||||
12369 | |||||
12370 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12371 | descriptorSet.AppendDummy(); | ||||
12372 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12373 | |||||
12374 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12375 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12376 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 12377 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 12378 | |
Chris Forbes | bc290ce | 2016-07-06 12:01:49 +1200 | [diff] [blame] | 12379 | TEST_F(VkLayerTest, CreatePipelineAttribComponents) |
12380 | { | ||||
12381 | m_errorMonitor->ExpectSuccess(); | ||||
12382 | |||||
12383 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12384 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12385 | |||||
12386 | VkVertexInputBindingDescription input_binding; | ||||
12387 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
12388 | |||||
12389 | VkVertexInputAttributeDescription input_attribs[3]; | ||||
12390 | memset(input_attribs, 0, sizeof(input_attribs)); | ||||
12391 | |||||
12392 | for (int i = 0; i < 3; i++) { | ||||
12393 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; | ||||
12394 | input_attribs[i].location = i; | ||||
12395 | } | ||||
12396 | |||||
12397 | char const *vsSource = | ||||
12398 | "#version 450\n" | ||||
12399 | "\n" | ||||
12400 | "layout(location=0) in vec4 x;\n" | ||||
12401 | "layout(location=1) in vec3 y1;\n" | ||||
12402 | "layout(location=1, component=3) in float y2;\n" | ||||
12403 | "layout(location=2) in vec4 z;\n" | ||||
12404 | "out gl_PerVertex {\n" | ||||
12405 | " vec4 gl_Position;\n" | ||||
12406 | "};\n" | ||||
12407 | "void main(){\n" | ||||
12408 | " gl_Position = x + vec4(y1, y2) + z;\n" | ||||
12409 | "}\n"; | ||||
12410 | char const *fsSource = | ||||
12411 | "#version 450\n" | ||||
12412 | "\n" | ||||
12413 | "layout(location=0) out vec4 color;\n" | ||||
12414 | "void main(){\n" | ||||
12415 | " color = vec4(1);\n" | ||||
12416 | "}\n"; | ||||
12417 | |||||
12418 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12419 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12420 | |||||
12421 | VkPipelineObj pipe(m_device); | ||||
12422 | pipe.AddColorAttachment(); | ||||
12423 | pipe.AddShader(&vs); | ||||
12424 | pipe.AddShader(&fs); | ||||
12425 | |||||
12426 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
12427 | pipe.AddVertexInputAttribs(input_attribs, 3); | ||||
12428 | |||||
12429 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12430 | descriptorSet.AppendDummy(); | ||||
12431 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12432 | |||||
12433 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12434 | |||||
12435 | m_errorMonitor->VerifyNotFound(); | ||||
12436 | } | ||||
12437 | |||||
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 12438 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
12439 | { | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12440 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 12441 | |
12442 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12443 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12444 | |||||
12445 | char const *vsSource = | ||||
12446 | "#version 450\n" | ||||
12447 | "out gl_PerVertex {\n" | ||||
12448 | " vec4 gl_Position;\n" | ||||
12449 | "};\n" | ||||
12450 | "void main(){\n" | ||||
12451 | " gl_Position = vec4(0);\n" | ||||
12452 | "}\n"; | ||||
12453 | char const *fsSource = | ||||
12454 | "#version 450\n" | ||||
12455 | "\n" | ||||
12456 | "layout(location=0) out vec4 color;\n" | ||||
12457 | "void main(){\n" | ||||
12458 | " color = vec4(1);\n" | ||||
12459 | "}\n"; | ||||
12460 | |||||
12461 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12462 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12463 | |||||
12464 | VkPipelineObj pipe(m_device); | ||||
12465 | pipe.AddColorAttachment(); | ||||
12466 | pipe.AddShader(&vs); | ||||
12467 | pipe.AddShader(&fs); | ||||
12468 | |||||
12469 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12470 | descriptorSet.AppendDummy(); | ||||
12471 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12472 | |||||
12473 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12474 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12475 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 12476 | } |
12477 | |||||
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 12478 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
12479 | { | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12480 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 12481 | |
12482 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block | ||||
12483 | |||||
12484 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12485 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12486 | |||||
12487 | char const *vsSource = | ||||
12488 | "#version 450\n" | ||||
12489 | "out gl_PerVertex {\n" | ||||
12490 | " vec4 gl_Position;\n" | ||||
12491 | "};\n" | ||||
12492 | "layout(location=0) out vec3 x;\n" | ||||
12493 | "layout(location=1) out ivec3 y;\n" | ||||
12494 | "layout(location=2) out vec3 z;\n" | ||||
12495 | "void main(){\n" | ||||
12496 | " gl_Position = vec4(0);\n" | ||||
12497 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" | ||||
12498 | "}\n"; | ||||
12499 | char const *fsSource = | ||||
12500 | "#version 450\n" | ||||
12501 | "\n" | ||||
12502 | "layout(location=0) out vec4 color;\n" | ||||
12503 | "layout(location=0) in float x;\n" | ||||
12504 | "layout(location=1) flat in int y;\n" | ||||
12505 | "layout(location=2) in vec2 z;\n" | ||||
12506 | "void main(){\n" | ||||
12507 | " color = vec4(1 + x + y + z.x);\n" | ||||
12508 | "}\n"; | ||||
12509 | |||||
12510 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12511 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12512 | |||||
12513 | VkPipelineObj pipe(m_device); | ||||
12514 | pipe.AddColorAttachment(); | ||||
12515 | pipe.AddShader(&vs); | ||||
12516 | pipe.AddShader(&fs); | ||||
12517 | |||||
12518 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12519 | descriptorSet.AppendDummy(); | ||||
12520 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12521 | |||||
Mike Stroyan | 255e958 | 2016-06-24 09:49:32 -0600 | [diff] [blame] | 12522 | VkResult err = VK_SUCCESS; |
12523 | err = | ||||
12524 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12525 | ASSERT_VK_SUCCESS(err); | ||||
12526 | |||||
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 12527 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12528 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 12529 | } |
12530 | |||||
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 12531 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
12532 | { | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12533 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 12534 | |
12535 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12536 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12537 | |||||
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 12538 | if (!m_device->phy().features().tessellationShader) { |
12539 | printf("Device does not support tessellation shaders; skipped.\n"); | ||||
12540 | return; | ||||
12541 | } | ||||
12542 | |||||
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 12543 | char const *vsSource = |
12544 | "#version 450\n" | ||||
12545 | "void main(){}\n"; | ||||
12546 | char const *tcsSource = | ||||
12547 | "#version 450\n" | ||||
12548 | "layout(location=0) out int x[];\n" | ||||
12549 | "layout(vertices=3) out;\n" | ||||
12550 | "void main(){\n" | ||||
12551 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" | ||||
12552 | " gl_TessLevelInner[0] = 1;\n" | ||||
12553 | " x[gl_InvocationID] = gl_InvocationID;\n" | ||||
12554 | "}\n"; | ||||
12555 | char const *tesSource = | ||||
12556 | "#version 450\n" | ||||
12557 | "layout(triangles, equal_spacing, cw) in;\n" | ||||
12558 | "layout(location=0) in int x[];\n" | ||||
12559 | "out gl_PerVertex { vec4 gl_Position; };\n" | ||||
12560 | "void main(){\n" | ||||
12561 | " gl_Position.xyz = gl_TessCoord;\n" | ||||
12562 | " gl_Position.w = x[0] + x[1] + x[2];\n" | ||||
12563 | "}\n"; | ||||
12564 | char const *fsSource = | ||||
12565 | "#version 450\n" | ||||
12566 | "layout(location=0) out vec4 color;\n" | ||||
12567 | "void main(){\n" | ||||
12568 | " color = vec4(1);\n" | ||||
12569 | "}\n"; | ||||
12570 | |||||
12571 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12572 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); | ||||
12573 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); | ||||
12574 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12575 | |||||
12576 | VkPipelineInputAssemblyStateCreateInfo iasci{ | ||||
12577 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, | ||||
12578 | nullptr, | ||||
12579 | 0, | ||||
12580 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, | ||||
12581 | VK_FALSE}; | ||||
12582 | |||||
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 12583 | VkPipelineTessellationStateCreateInfo tsci{ |
12584 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, | ||||
12585 | nullptr, | ||||
12586 | 0, | ||||
12587 | 3}; | ||||
12588 | |||||
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 12589 | VkPipelineObj pipe(m_device); |
12590 | pipe.SetInputAssembly(&iasci); | ||||
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 12591 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 12592 | pipe.AddColorAttachment(); |
12593 | pipe.AddShader(&vs); | ||||
12594 | pipe.AddShader(&tcs); | ||||
12595 | pipe.AddShader(&tes); | ||||
12596 | pipe.AddShader(&fs); | ||||
12597 | |||||
12598 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12599 | descriptorSet.AppendDummy(); | ||||
12600 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12601 | |||||
12602 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12603 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12604 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 12605 | } |
12606 | |||||
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 12607 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
12608 | { | ||||
12609 | m_errorMonitor->ExpectSuccess(); | ||||
12610 | |||||
12611 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12612 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12613 | |||||
12614 | if (!m_device->phy().features().geometryShader) { | ||||
12615 | printf("Device does not support geometry shaders; skipped.\n"); | ||||
12616 | return; | ||||
12617 | } | ||||
12618 | |||||
12619 | char const *vsSource = | ||||
12620 | "#version 450\n" | ||||
12621 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" | ||||
12622 | "void main(){\n" | ||||
12623 | " vs_out.x = vec4(1);\n" | ||||
12624 | "}\n"; | ||||
12625 | char const *gsSource = | ||||
12626 | "#version 450\n" | ||||
12627 | "layout(triangles) in;\n" | ||||
12628 | "layout(triangle_strip, max_vertices=3) out;\n" | ||||
12629 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" | ||||
12630 | "out gl_PerVertex { vec4 gl_Position; };\n" | ||||
12631 | "void main() {\n" | ||||
12632 | " gl_Position = gs_in[0].x;\n" | ||||
12633 | " EmitVertex();\n" | ||||
12634 | "}\n"; | ||||
12635 | char const *fsSource = | ||||
12636 | "#version 450\n" | ||||
12637 | "layout(location=0) out vec4 color;\n" | ||||
12638 | "void main(){\n" | ||||
12639 | " color = vec4(1);\n" | ||||
12640 | "}\n"; | ||||
12641 | |||||
12642 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12643 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); | ||||
12644 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12645 | |||||
12646 | VkPipelineObj pipe(m_device); | ||||
12647 | pipe.AddColorAttachment(); | ||||
12648 | pipe.AddShader(&vs); | ||||
12649 | pipe.AddShader(&gs); | ||||
12650 | pipe.AddShader(&fs); | ||||
12651 | |||||
12652 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12653 | descriptorSet.AppendDummy(); | ||||
12654 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12655 | |||||
12656 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12657 | |||||
12658 | m_errorMonitor->VerifyNotFound(); | ||||
12659 | } | ||||
12660 | |||||
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 12661 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
12662 | { | ||||
12663 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12664 | "is per-vertex in tessellation control shader stage " | ||||
12665 | "but per-patch in tessellation evaluation shader stage"); | ||||
12666 | |||||
12667 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12668 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12669 | |||||
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 12670 | if (!m_device->phy().features().tessellationShader) { |
12671 | printf("Device does not support tessellation shaders; skipped.\n"); | ||||
12672 | return; | ||||
12673 | } | ||||
12674 | |||||
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 12675 | char const *vsSource = |
12676 | "#version 450\n" | ||||
12677 | "void main(){}\n"; | ||||
12678 | char const *tcsSource = | ||||
12679 | "#version 450\n" | ||||
12680 | "layout(location=0) out int x[];\n" | ||||
12681 | "layout(vertices=3) out;\n" | ||||
12682 | "void main(){\n" | ||||
12683 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" | ||||
12684 | " gl_TessLevelInner[0] = 1;\n" | ||||
12685 | " x[gl_InvocationID] = gl_InvocationID;\n" | ||||
12686 | "}\n"; | ||||
12687 | char const *tesSource = | ||||
12688 | "#version 450\n" | ||||
12689 | "layout(triangles, equal_spacing, cw) in;\n" | ||||
12690 | "layout(location=0) patch in int x;\n" | ||||
12691 | "out gl_PerVertex { vec4 gl_Position; };\n" | ||||
12692 | "void main(){\n" | ||||
12693 | " gl_Position.xyz = gl_TessCoord;\n" | ||||
12694 | " gl_Position.w = x;\n" | ||||
12695 | "}\n"; | ||||
12696 | char const *fsSource = | ||||
12697 | "#version 450\n" | ||||
12698 | "layout(location=0) out vec4 color;\n" | ||||
12699 | "void main(){\n" | ||||
12700 | " color = vec4(1);\n" | ||||
12701 | "}\n"; | ||||
12702 | |||||
12703 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12704 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); | ||||
12705 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); | ||||
12706 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12707 | |||||
12708 | VkPipelineInputAssemblyStateCreateInfo iasci{ | ||||
12709 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, | ||||
12710 | nullptr, | ||||
12711 | 0, | ||||
12712 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, | ||||
12713 | VK_FALSE}; | ||||
12714 | |||||
12715 | VkPipelineTessellationStateCreateInfo tsci{ | ||||
12716 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, | ||||
12717 | nullptr, | ||||
12718 | 0, | ||||
12719 | 3}; | ||||
12720 | |||||
12721 | VkPipelineObj pipe(m_device); | ||||
12722 | pipe.SetInputAssembly(&iasci); | ||||
12723 | pipe.SetTessellation(&tsci); | ||||
12724 | pipe.AddColorAttachment(); | ||||
12725 | pipe.AddShader(&vs); | ||||
12726 | pipe.AddShader(&tcs); | ||||
12727 | pipe.AddShader(&tes); | ||||
12728 | pipe.AddShader(&fs); | ||||
12729 | |||||
12730 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12731 | descriptorSet.AppendDummy(); | ||||
12732 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12733 | |||||
12734 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12735 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12736 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 12737 | } |
12738 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12739 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
12740 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12741 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12742 | "Duplicate vertex input binding descriptions for binding 0"); |
12743 | |||||
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 12744 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 12745 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 12746 | |
12747 | /* Two binding descriptions for binding 0 */ | ||||
12748 | VkVertexInputBindingDescription input_bindings[2]; | ||||
12749 | memset(input_bindings, 0, sizeof(input_bindings)); | ||||
12750 | |||||
12751 | VkVertexInputAttributeDescription input_attrib; | ||||
12752 | memset(&input_attrib, 0, sizeof(input_attrib)); | ||||
12753 | input_attrib.format = VK_FORMAT_R32_SFLOAT; | ||||
12754 | |||||
12755 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12756 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 12757 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12758 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12759 | "out gl_PerVertex {\n" |
12760 | " vec4 gl_Position;\n" | ||||
12761 | "};\n" | ||||
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 12762 | "void main(){\n" |
12763 | " gl_Position = vec4(x);\n" | ||||
12764 | "}\n"; | ||||
12765 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12766 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 12767 | "\n" |
12768 | "layout(location=0) out vec4 color;\n" | ||||
12769 | "void main(){\n" | ||||
12770 | " color = vec4(1);\n" | ||||
12771 | "}\n"; | ||||
12772 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 12773 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
12774 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 12775 | |
12776 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 12777 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 12778 | pipe.AddShader(&vs); |
12779 | pipe.AddShader(&fs); | ||||
12780 | |||||
12781 | pipe.AddVertexInputBindings(input_bindings, 2); | ||||
12782 | pipe.AddVertexInputAttribs(&input_attrib, 1); | ||||
12783 | |||||
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 12784 | VkDescriptorSetObj descriptorSet(m_device); |
12785 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12786 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 12787 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 12788 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 12789 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12790 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 12791 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 12792 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 12793 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
12794 | m_errorMonitor->ExpectSuccess(); | ||||
12795 | |||||
12796 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12797 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12798 | |||||
Chris Forbes | 91cf3a8 | 2016-06-28 17:51:35 +1200 | [diff] [blame] | 12799 | if (!m_device->phy().features().shaderFloat64) { |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 12800 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
12801 | return; | ||||
12802 | } | ||||
12803 | |||||
12804 | VkVertexInputBindingDescription input_bindings[1]; | ||||
12805 | memset(input_bindings, 0, sizeof(input_bindings)); | ||||
12806 | |||||
12807 | VkVertexInputAttributeDescription input_attribs[4]; | ||||
12808 | memset(input_attribs, 0, sizeof(input_attribs)); | ||||
12809 | input_attribs[0].location = 0; | ||||
12810 | input_attribs[0].offset = 0; | ||||
12811 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; | ||||
12812 | input_attribs[1].location = 2; | ||||
12813 | input_attribs[1].offset = 32; | ||||
12814 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; | ||||
12815 | input_attribs[2].location = 4; | ||||
12816 | input_attribs[2].offset = 64; | ||||
12817 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; | ||||
12818 | input_attribs[3].location = 6; | ||||
12819 | input_attribs[3].offset = 96; | ||||
12820 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; | ||||
12821 | |||||
12822 | char const *vsSource = | ||||
12823 | "#version 450\n" | ||||
12824 | "\n" | ||||
12825 | "layout(location=0) in dmat4 x;\n" | ||||
12826 | "out gl_PerVertex {\n" | ||||
12827 | " vec4 gl_Position;\n" | ||||
12828 | "};\n" | ||||
12829 | "void main(){\n" | ||||
12830 | " gl_Position = vec4(x[0][0]);\n" | ||||
12831 | "}\n"; | ||||
12832 | char const *fsSource = | ||||
12833 | "#version 450\n" | ||||
12834 | "\n" | ||||
12835 | "layout(location=0) out vec4 color;\n" | ||||
12836 | "void main(){\n" | ||||
12837 | " color = vec4(1);\n" | ||||
12838 | "}\n"; | ||||
12839 | |||||
12840 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12841 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12842 | |||||
12843 | VkPipelineObj pipe(m_device); | ||||
12844 | pipe.AddColorAttachment(); | ||||
12845 | pipe.AddShader(&vs); | ||||
12846 | pipe.AddShader(&fs); | ||||
12847 | |||||
12848 | pipe.AddVertexInputBindings(input_bindings, 1); | ||||
12849 | pipe.AddVertexInputAttribs(input_attribs, 4); | ||||
12850 | |||||
12851 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12852 | descriptorSet.AppendDummy(); | ||||
12853 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12854 | |||||
12855 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12856 | |||||
12857 | m_errorMonitor->VerifyNotFound(); | ||||
12858 | } | ||||
12859 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12860 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 12861 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12862 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12863 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 12864 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 12865 | |
12866 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12867 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 12868 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12869 | "out gl_PerVertex {\n" |
12870 | " vec4 gl_Position;\n" | ||||
12871 | "};\n" | ||||
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 12872 | "void main(){\n" |
12873 | " gl_Position = vec4(1);\n" | ||||
12874 | "}\n"; | ||||
12875 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12876 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 12877 | "\n" |
12878 | "void main(){\n" | ||||
12879 | "}\n"; | ||||
12880 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 12881 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
12882 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 12883 | |
12884 | VkPipelineObj pipe(m_device); | ||||
12885 | pipe.AddShader(&vs); | ||||
12886 | pipe.AddShader(&fs); | ||||
12887 | |||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 12888 | /* set up CB 0, not written */ |
12889 | pipe.AddColorAttachment(); | ||||
12890 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 12891 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 12892 | VkDescriptorSetObj descriptorSet(m_device); |
12893 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12894 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 12895 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 12896 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 12897 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12898 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 12899 | } |
12900 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12901 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12902 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 12903 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12904 | "FS writes to output location 1 with no matching attachment"); |
12905 | |||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 12906 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 12907 | |
12908 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12909 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 12910 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12911 | "out gl_PerVertex {\n" |
12912 | " vec4 gl_Position;\n" | ||||
12913 | "};\n" | ||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 12914 | "void main(){\n" |
12915 | " gl_Position = vec4(1);\n" | ||||
12916 | "}\n"; | ||||
12917 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12918 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 12919 | "\n" |
12920 | "layout(location=0) out vec4 x;\n" | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12921 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 12922 | "void main(){\n" |
12923 | " x = vec4(1);\n" | ||||
12924 | " y = vec4(1);\n" | ||||
12925 | "}\n"; | ||||
12926 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 12927 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
12928 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 12929 | |
12930 | VkPipelineObj pipe(m_device); | ||||
12931 | pipe.AddShader(&vs); | ||||
12932 | pipe.AddShader(&fs); | ||||
12933 | |||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 12934 | /* set up CB 0, not written */ |
12935 | pipe.AddColorAttachment(); | ||||
12936 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 12937 | /* FS writes CB 1, but we don't configure it */ |
12938 | |||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 12939 | VkDescriptorSetObj descriptorSet(m_device); |
12940 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12941 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 12942 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 12943 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 12944 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12945 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 12946 | } |
12947 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12948 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 12949 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12950 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12951 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 12952 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 12953 | |
12954 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12955 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 12956 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12957 | "out gl_PerVertex {\n" |
12958 | " vec4 gl_Position;\n" | ||||
12959 | "};\n" | ||||
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 12960 | "void main(){\n" |
12961 | " gl_Position = vec4(1);\n" | ||||
12962 | "}\n"; | ||||
12963 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12964 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 12965 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12966 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 12967 | "void main(){\n" |
12968 | " x = ivec4(1);\n" | ||||
12969 | "}\n"; | ||||
12970 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 12971 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
12972 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 12973 | |
12974 | VkPipelineObj pipe(m_device); | ||||
12975 | pipe.AddShader(&vs); | ||||
12976 | pipe.AddShader(&fs); | ||||
12977 | |||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 12978 | /* set up CB 0; type is UNORM by default */ |
12979 | pipe.AddColorAttachment(); | ||||
12980 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 12981 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 12982 | VkDescriptorSetObj descriptorSet(m_device); |
12983 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12984 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 12985 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 12986 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 12987 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12988 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 12989 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 12990 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12991 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 12992 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12993 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12994 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 12995 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 12996 | |
12997 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12998 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 12999 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 13000 | "out gl_PerVertex {\n" |
13001 | " vec4 gl_Position;\n" | ||||
13002 | "};\n" | ||||
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13003 | "void main(){\n" |
13004 | " gl_Position = vec4(1);\n" | ||||
13005 | "}\n"; | ||||
13006 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13007 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13008 | "\n" |
13009 | "layout(location=0) out vec4 x;\n" | ||||
13010 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" | ||||
13011 | "void main(){\n" | ||||
13012 | " x = vec4(bar.y);\n" | ||||
13013 | "}\n"; | ||||
13014 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 13015 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
13016 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13017 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13018 | VkPipelineObj pipe(m_device); |
13019 | pipe.AddShader(&vs); | ||||
13020 | pipe.AddShader(&fs); | ||||
13021 | |||||
13022 | /* set up CB 0; type is UNORM by default */ | ||||
13023 | pipe.AddColorAttachment(); | ||||
13024 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13025 | |||||
13026 | VkDescriptorSetObj descriptorSet(m_device); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13027 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13028 | |
13029 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13030 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13031 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13032 | } |
13033 | |||||
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 13034 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
13035 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13036 | "not declared in layout"); | ||||
13037 | |||||
13038 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13039 | |||||
13040 | char const *vsSource = | ||||
13041 | "#version 450\n" | ||||
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 13042 | "\n" |
13043 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" | ||||
13044 | "out gl_PerVertex {\n" | ||||
13045 | " vec4 gl_Position;\n" | ||||
13046 | "};\n" | ||||
13047 | "void main(){\n" | ||||
13048 | " gl_Position = vec4(consts.x);\n" | ||||
13049 | "}\n"; | ||||
13050 | char const *fsSource = | ||||
13051 | "#version 450\n" | ||||
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 13052 | "\n" |
13053 | "layout(location=0) out vec4 x;\n" | ||||
13054 | "void main(){\n" | ||||
13055 | " x = vec4(1);\n" | ||||
13056 | "}\n"; | ||||
13057 | |||||
13058 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
13059 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13060 | |||||
13061 | VkPipelineObj pipe(m_device); | ||||
13062 | pipe.AddShader(&vs); | ||||
13063 | pipe.AddShader(&fs); | ||||
13064 | |||||
13065 | /* set up CB 0; type is UNORM by default */ | ||||
13066 | pipe.AddColorAttachment(); | ||||
13067 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13068 | |||||
13069 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13070 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13071 | |||||
13072 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13073 | |||||
13074 | /* should have generated an error -- no push constant ranges provided! */ | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13075 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 13076 | } |
13077 | |||||
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 13078 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
13079 | m_errorMonitor->SetDesiredFailureMsg( | ||||
13080 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13081 | "Shader uses descriptor slot 0.0"); | ||||
13082 | |||||
13083 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13084 | |||||
13085 | char const *csSource = | ||||
13086 | "#version 450\n" | ||||
13087 | "\n" | ||||
13088 | "layout(local_size_x=1) in;\n" | ||||
13089 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" | ||||
13090 | "void main(){\n" | ||||
13091 | " x = vec4(1);\n" | ||||
13092 | "}\n"; | ||||
13093 | |||||
13094 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); | ||||
13095 | |||||
13096 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13097 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13098 | |||||
13099 | VkComputePipelineCreateInfo cpci = { | ||||
13100 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, | ||||
13101 | nullptr, 0, { | ||||
13102 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, | ||||
13103 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, | ||||
13104 | cs.handle(), "main", nullptr | ||||
13105 | }, | ||||
13106 | descriptorSet.GetPipelineLayout(), | ||||
13107 | VK_NULL_HANDLE, -1 | ||||
13108 | }; | ||||
13109 | |||||
13110 | VkPipeline pipe; | ||||
13111 | VkResult err = vkCreateComputePipelines( | ||||
13112 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); | ||||
13113 | |||||
13114 | m_errorMonitor->VerifyFound(); | ||||
13115 | |||||
13116 | if (err == VK_SUCCESS) { | ||||
13117 | vkDestroyPipeline(m_device->device(), pipe, nullptr); | ||||
13118 | } | ||||
13119 | } | ||||
13120 | |||||
13121 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { | ||||
13122 | m_errorMonitor->ExpectSuccess(); | ||||
13123 | |||||
13124 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13125 | |||||
13126 | char const *csSource = | ||||
13127 | "#version 450\n" | ||||
13128 | "\n" | ||||
13129 | "layout(local_size_x=1) in;\n" | ||||
13130 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" | ||||
13131 | "void main(){\n" | ||||
13132 | " // x is not used.\n" | ||||
13133 | "}\n"; | ||||
13134 | |||||
13135 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); | ||||
13136 | |||||
13137 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13138 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13139 | |||||
13140 | VkComputePipelineCreateInfo cpci = { | ||||
13141 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, | ||||
13142 | nullptr, 0, { | ||||
13143 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, | ||||
13144 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, | ||||
13145 | cs.handle(), "main", nullptr | ||||
13146 | }, | ||||
13147 | descriptorSet.GetPipelineLayout(), | ||||
13148 | VK_NULL_HANDLE, -1 | ||||
13149 | }; | ||||
13150 | |||||
13151 | VkPipeline pipe; | ||||
13152 | VkResult err = vkCreateComputePipelines( | ||||
13153 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); | ||||
13154 | |||||
13155 | m_errorMonitor->VerifyNotFound(); | ||||
13156 | |||||
13157 | if (err == VK_SUCCESS) { | ||||
13158 | vkDestroyPipeline(m_device->device(), pipe, nullptr); | ||||
13159 | } | ||||
13160 | } | ||||
13161 | |||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 13162 | #endif // SHADER_CHECKER_TESTS |
13163 | |||||
13164 | #if DEVICE_LIMITS_TESTS | ||||
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 13165 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13166 | m_errorMonitor->SetDesiredFailureMsg( |
13167 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13168 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 13169 | |
13170 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 13171 | |
13172 | // Create an image | ||||
13173 | VkImage image; | ||||
13174 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13175 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
13176 | const int32_t tex_width = 32; | ||||
13177 | const int32_t tex_height = 32; | ||||
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 13178 | |
13179 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13180 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
13181 | image_create_info.pNext = NULL; | ||||
13182 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
13183 | image_create_info.format = tex_format; | ||||
13184 | image_create_info.extent.width = tex_width; | ||||
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 13185 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13186 | image_create_info.extent.depth = 1; |
13187 | image_create_info.mipLevels = 1; | ||||
13188 | image_create_info.arrayLayers = 1; | ||||
13189 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
13190 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
13191 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
13192 | image_create_info.flags = 0; | ||||
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 13193 | |
13194 | // Introduce error by sending down a bogus width extent | ||||
13195 | image_create_info.extent.width = 65536; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13196 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 13197 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13198 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 13199 | } |
13200 | |||||
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 13201 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
13202 | m_errorMonitor->SetDesiredFailureMsg( | ||||
13203 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13204 | "CreateImage extents is 0 for at least one required dimension"); | ||||
13205 | |||||
13206 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13207 | |||||
13208 | // Create an image | ||||
13209 | VkImage image; | ||||
13210 | |||||
13211 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
13212 | const int32_t tex_width = 32; | ||||
13213 | const int32_t tex_height = 32; | ||||
13214 | |||||
13215 | VkImageCreateInfo image_create_info = {}; | ||||
13216 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
13217 | image_create_info.pNext = NULL; | ||||
13218 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
13219 | image_create_info.format = tex_format; | ||||
13220 | image_create_info.extent.width = tex_width; | ||||
13221 | image_create_info.extent.height = tex_height; | ||||
13222 | image_create_info.extent.depth = 1; | ||||
13223 | image_create_info.mipLevels = 1; | ||||
13224 | image_create_info.arrayLayers = 1; | ||||
13225 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
13226 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
13227 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
13228 | image_create_info.flags = 0; | ||||
13229 | |||||
13230 | // Introduce error by sending down a bogus width extent | ||||
13231 | image_create_info.extent.width = 0; | ||||
13232 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
13233 | |||||
13234 | m_errorMonitor->VerifyFound(); | ||||
13235 | } | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 13236 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13237 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13238 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13239 | TEST_F(VkLayerTest, InvalidImageView) { |
13240 | VkResult err; | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13241 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13242 | m_errorMonitor->SetDesiredFailureMsg( |
13243 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13244 | "vkCreateImageView called with baseMipLevel 10 "); |
13245 | |||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13246 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13247 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13248 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13249 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13250 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13251 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
13252 | const int32_t tex_width = 32; | ||||
13253 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13254 | |
13255 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13256 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
13257 | image_create_info.pNext = NULL; | ||||
13258 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
13259 | image_create_info.format = tex_format; | ||||
13260 | image_create_info.extent.width = tex_width; | ||||
13261 | image_create_info.extent.height = tex_height; | ||||
13262 | image_create_info.extent.depth = 1; | ||||
13263 | image_create_info.mipLevels = 1; | ||||
13264 | image_create_info.arrayLayers = 1; | ||||
13265 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
13266 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
13267 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
13268 | image_create_info.flags = 0; | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13269 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13270 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13271 | ASSERT_VK_SUCCESS(err); |
13272 | |||||
13273 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13274 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
13275 | image_view_create_info.image = image; | ||||
13276 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
13277 | image_view_create_info.format = tex_format; | ||||
13278 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
13279 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error | ||||
13280 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
13281 | image_view_create_info.subresourceRange.aspectMask = | ||||
13282 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13283 | |
13284 | VkImageView view; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13285 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
13286 | &view); | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13287 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13288 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 13289 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 13290 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13291 | |
Mark Young | d339ba3 | 2016-05-30 13:28:35 -0600 | [diff] [blame] | 13292 | TEST_F(VkLayerTest, CreateImageViewNoMemoryBoundToImage) { |
13293 | VkResult err; | ||||
13294 | |||||
13295 | m_errorMonitor->SetDesiredFailureMsg( | ||||
13296 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13297 | "vkCreateImageView called with invalid memory "); | ||||
13298 | |||||
13299 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13300 | |||||
13301 | // Create an image and try to create a view with no memory backing the image | ||||
13302 | VkImage image; | ||||
13303 | |||||
13304 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
13305 | const int32_t tex_width = 32; | ||||
13306 | const int32_t tex_height = 32; | ||||
13307 | |||||
13308 | VkImageCreateInfo image_create_info = {}; | ||||
13309 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
13310 | image_create_info.pNext = NULL; | ||||
13311 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
13312 | image_create_info.format = tex_format; | ||||
13313 | image_create_info.extent.width = tex_width; | ||||
13314 | image_create_info.extent.height = tex_height; | ||||
13315 | image_create_info.extent.depth = 1; | ||||
13316 | image_create_info.mipLevels = 1; | ||||
13317 | image_create_info.arrayLayers = 1; | ||||
13318 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
13319 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
13320 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
13321 | image_create_info.flags = 0; | ||||
13322 | |||||
13323 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
13324 | ASSERT_VK_SUCCESS(err); | ||||
13325 | |||||
13326 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
13327 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
13328 | image_view_create_info.image = image; | ||||
13329 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
13330 | image_view_create_info.format = tex_format; | ||||
13331 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
13332 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
13333 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
13334 | image_view_create_info.subresourceRange.aspectMask = | ||||
13335 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
13336 | |||||
13337 | VkImageView view; | ||||
13338 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, | ||||
13339 | &view); | ||||
13340 | |||||
13341 | m_errorMonitor->VerifyFound(); | ||||
13342 | vkDestroyImage(m_device->device(), image, NULL); | ||||
13343 | // If last error is success, it still created the view, so delete it. | ||||
13344 | if (err == VK_SUCCESS) { | ||||
13345 | vkDestroyImageView(m_device->device(), view, NULL); | ||||
13346 | } | ||||
13347 | |||||
13348 | } | ||||
13349 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13350 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 13351 | TEST_DESCRIPTION( |
13352 | "Create an image and try to create a view with an invalid aspectMask"); | ||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 13353 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13354 | "vkCreateImageView: Color image " |
13355 | "formats must have ONLY the " | ||||
13356 | "VK_IMAGE_ASPECT_COLOR_BIT set"); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13357 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 13358 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 13359 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13360 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 13361 | VkImageObj image(m_device); |
13362 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, | ||||
13363 | VK_IMAGE_TILING_LINEAR, 0); | ||||
13364 | ASSERT_TRUE(image.initialized()); | ||||
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 13365 | |
13366 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13367 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 13368 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13369 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
13370 | image_view_create_info.format = tex_format; | ||||
13371 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
13372 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
13373 | // Cause an error by setting an invalid image aspect | ||||
13374 | image_view_create_info.subresourceRange.aspectMask = | ||||
13375 | VK_IMAGE_ASPECT_METADATA_BIT; | ||||
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 13376 | |
13377 | VkImageView view; | ||||
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 13378 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 13379 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13380 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 13381 | } |
13382 | |||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 13383 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13384 | VkResult err; |
13385 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13386 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13387 | m_errorMonitor->SetDesiredFailureMsg( |
13388 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 13389 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13390 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13391 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13392 | |
13393 | // Create two images of different types and try to copy between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13394 | VkImage srcImage; |
13395 | VkImage dstImage; | ||||
13396 | VkDeviceMemory srcMem; | ||||
13397 | VkDeviceMemory destMem; | ||||
13398 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13399 | |
13400 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13401 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
13402 | image_create_info.pNext = NULL; | ||||
13403 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
13404 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
13405 | image_create_info.extent.width = 32; | ||||
13406 | image_create_info.extent.height = 32; | ||||
13407 | image_create_info.extent.depth = 1; | ||||
13408 | image_create_info.mipLevels = 1; | ||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 13409 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13410 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
13411 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
13412 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
13413 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13414 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13415 | err = |
13416 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13417 | ASSERT_VK_SUCCESS(err); |
13418 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13419 | err = |
13420 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13421 | ASSERT_VK_SUCCESS(err); |
13422 | |||||
13423 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13424 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13425 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
13426 | memAlloc.pNext = NULL; | ||||
13427 | memAlloc.allocationSize = 0; | ||||
13428 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13429 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 13430 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13431 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13432 | pass = |
13433 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 13434 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13435 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13436 | ASSERT_VK_SUCCESS(err); |
13437 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13438 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13439 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13440 | pass = |
13441 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13442 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13443 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13444 | ASSERT_VK_SUCCESS(err); |
13445 | |||||
13446 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
13447 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13448 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13449 | ASSERT_VK_SUCCESS(err); |
13450 | |||||
13451 | BeginCommandBuffer(); | ||||
13452 | VkImageCopy copyRegion; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 13453 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13454 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 13455 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 13456 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13457 | copyRegion.srcOffset.x = 0; |
13458 | copyRegion.srcOffset.y = 0; | ||||
13459 | copyRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 13460 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13461 | copyRegion.dstSubresource.mipLevel = 0; |
13462 | copyRegion.dstSubresource.baseArrayLayer = 0; | ||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 13463 | // Introduce failure by forcing the dst layerCount to differ from src |
13464 | copyRegion.dstSubresource.layerCount = 3; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13465 | copyRegion.dstOffset.x = 0; |
13466 | copyRegion.dstOffset.y = 0; | ||||
13467 | copyRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13468 | copyRegion.extent.width = 1; |
13469 | copyRegion.extent.height = 1; | ||||
13470 | copyRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13471 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
13472 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13473 | EndCommandBuffer(); |
13474 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13475 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13476 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13477 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13478 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 13479 | vkFreeMemory(m_device->device(), srcMem, NULL); |
13480 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13481 | } |
13482 | |||||
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 13483 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
13484 | |||||
13485 | TEST_DESCRIPTION("Creating images with unsuported formats "); | ||||
13486 | |||||
13487 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13488 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13489 | VkImageObj image(m_device); | ||||
13490 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
13491 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | ||||
13492 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
13493 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
13494 | ASSERT_TRUE(image.initialized()); | ||||
13495 | |||||
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 13496 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
13497 | VkImageCreateInfo image_create_info; | ||||
13498 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
13499 | image_create_info.pNext = NULL; | ||||
13500 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
13501 | image_create_info.format = VK_FORMAT_UNDEFINED; | ||||
13502 | image_create_info.extent.width = 32; | ||||
13503 | image_create_info.extent.height = 32; | ||||
13504 | image_create_info.extent.depth = 1; | ||||
13505 | image_create_info.mipLevels = 1; | ||||
13506 | image_create_info.arrayLayers = 1; | ||||
13507 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
13508 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
13509 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
13510 | image_create_info.flags = 0; | ||||
13511 | |||||
13512 | m_errorMonitor->SetDesiredFailureMsg( | ||||
13513 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13514 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); | ||||
13515 | |||||
13516 | VkImage localImage; | ||||
13517 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); | ||||
13518 | m_errorMonitor->VerifyFound(); | ||||
13519 | |||||
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 13520 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 13521 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 13522 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
13523 | VkFormat format = static_cast<VkFormat>(f); | ||||
13524 | VkFormatProperties fProps = m_device->format_properties(format); | ||||
13525 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && | ||||
13526 | fProps.optimalTilingFeatures == 0) { | ||||
13527 | unsupported = format; | ||||
13528 | break; | ||||
13529 | } | ||||
13530 | } | ||||
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 13531 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 13532 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 13533 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 13534 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 13535 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 13536 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 13537 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 13538 | m_errorMonitor->VerifyFound(); |
13539 | } | ||||
13540 | } | ||||
13541 | |||||
13542 | TEST_F(VkLayerTest, ImageLayerViewTests) { | ||||
13543 | VkResult ret; | ||||
13544 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); | ||||
13545 | |||||
13546 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13547 | |||||
13548 | VkImageObj image(m_device); | ||||
13549 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
13550 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | ||||
13551 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
13552 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
13553 | ASSERT_TRUE(image.initialized()); | ||||
13554 | |||||
13555 | VkImageView imgView; | ||||
13556 | VkImageViewCreateInfo imgViewInfo = {}; | ||||
13557 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
13558 | imgViewInfo.image = image.handle(); | ||||
13559 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
13560 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
13561 | imgViewInfo.subresourceRange.layerCount = 1; | ||||
13562 | imgViewInfo.subresourceRange.baseMipLevel = 0; | ||||
13563 | imgViewInfo.subresourceRange.levelCount = 1; | ||||
13564 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
13565 | |||||
13566 | m_errorMonitor->SetDesiredFailureMsg( | ||||
13567 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13568 | "vkCreateImageView called with baseMipLevel"); | ||||
13569 | // View can't have baseMipLevel >= image's mipLevels - Expect | ||||
13570 | // VIEW_CREATE_ERROR | ||||
13571 | imgViewInfo.subresourceRange.baseMipLevel = 1; | ||||
13572 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
13573 | m_errorMonitor->VerifyFound(); | ||||
13574 | imgViewInfo.subresourceRange.baseMipLevel = 0; | ||||
13575 | |||||
13576 | m_errorMonitor->SetDesiredFailureMsg( | ||||
13577 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13578 | "vkCreateImageView called with baseArrayLayer"); | ||||
13579 | // View can't have baseArrayLayer >= image's arraySize - Expect | ||||
13580 | // VIEW_CREATE_ERROR | ||||
13581 | imgViewInfo.subresourceRange.baseArrayLayer = 1; | ||||
13582 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
13583 | m_errorMonitor->VerifyFound(); | ||||
13584 | imgViewInfo.subresourceRange.baseArrayLayer = 0; | ||||
13585 | |||||
13586 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13587 | "vkCreateImageView called with 0 in " | ||||
13588 | "pCreateInfo->subresourceRange." | ||||
13589 | "levelCount"); | ||||
13590 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR | ||||
13591 | imgViewInfo.subresourceRange.levelCount = 0; | ||||
13592 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
13593 | m_errorMonitor->VerifyFound(); | ||||
13594 | imgViewInfo.subresourceRange.levelCount = 1; | ||||
13595 | |||||
13596 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13597 | "vkCreateImageView called with 0 in " | ||||
13598 | "pCreateInfo->subresourceRange." | ||||
13599 | "layerCount"); | ||||
13600 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR | ||||
13601 | imgViewInfo.subresourceRange.layerCount = 0; | ||||
13602 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
13603 | m_errorMonitor->VerifyFound(); | ||||
13604 | imgViewInfo.subresourceRange.layerCount = 1; | ||||
13605 | |||||
13606 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13607 | "but both must be color formats"); | ||||
13608 | // Can't use depth format for view into color image - Expect INVALID_FORMAT | ||||
13609 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
13610 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
13611 | m_errorMonitor->VerifyFound(); | ||||
13612 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
13613 | |||||
13614 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13615 | "Formats MUST be IDENTICAL unless " | ||||
13616 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " | ||||
13617 | "was set on image creation."); | ||||
13618 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect | ||||
13619 | // VIEW_CREATE_ERROR | ||||
13620 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; | ||||
13621 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
13622 | m_errorMonitor->VerifyFound(); | ||||
13623 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
13624 | |||||
13625 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13626 | "can support ImageViews with " | ||||
13627 | "differing formats but they must be " | ||||
13628 | "in the same compatibility class."); | ||||
13629 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect | ||||
13630 | // VIEW_CREATE_ERROR | ||||
13631 | VkImageCreateInfo mutImgInfo = image.create_info(); | ||||
13632 | VkImage mutImage; | ||||
13633 | mutImgInfo.format = VK_FORMAT_R8_UINT; | ||||
13634 | assert( | ||||
13635 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & | ||||
13636 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); | ||||
13637 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; | ||||
13638 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
13639 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); | ||||
13640 | ASSERT_VK_SUCCESS(ret); | ||||
13641 | imgViewInfo.image = mutImage; | ||||
13642 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
13643 | m_errorMonitor->VerifyFound(); | ||||
13644 | imgViewInfo.image = image.handle(); | ||||
13645 | vkDestroyImage(m_device->handle(), mutImage, NULL); | ||||
13646 | } | ||||
13647 | |||||
13648 | TEST_F(VkLayerTest, MiscImageLayerTests) { | ||||
13649 | |||||
13650 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); | ||||
13651 | |||||
13652 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13653 | |||||
13654 | VkImageObj image(m_device); | ||||
13655 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
13656 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | ||||
13657 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
13658 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
13659 | ASSERT_TRUE(image.initialized()); | ||||
13660 | |||||
13661 | m_errorMonitor->SetDesiredFailureMsg( | ||||
13662 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13663 | "number of layers in image subresource is zero"); | ||||
13664 | vk_testing::Buffer buffer; | ||||
13665 | VkMemoryPropertyFlags reqs = 0; | ||||
13666 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); | ||||
13667 | VkBufferImageCopy region = {}; | ||||
13668 | region.bufferRowLength = 128; | ||||
13669 | region.bufferImageHeight = 128; | ||||
13670 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
13671 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT | ||||
13672 | region.imageSubresource.layerCount = 0; | ||||
13673 | region.imageExtent.height = 4; | ||||
13674 | region.imageExtent.width = 4; | ||||
13675 | region.imageExtent.depth = 1; | ||||
13676 | m_commandBuffer->BeginCommandBuffer(); | ||||
13677 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), | ||||
13678 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
13679 | 1, ®ion); | ||||
13680 | m_errorMonitor->VerifyFound(); | ||||
13681 | region.imageSubresource.layerCount = 1; | ||||
13682 | |||||
13683 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13684 | "aspectMasks for each region must " | ||||
13685 | "specify only COLOR or DEPTH or " | ||||
13686 | "STENCIL"); | ||||
13687 | // Expect MISMATCHED_IMAGE_ASPECT | ||||
13688 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; | ||||
13689 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), | ||||
13690 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
13691 | 1, ®ion); | ||||
13692 | m_errorMonitor->VerifyFound(); | ||||
13693 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
13694 | |||||
13695 | m_errorMonitor->SetDesiredFailureMsg( | ||||
13696 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13697 | "If the format of srcImage is a depth, stencil, depth stencil or " | ||||
13698 | "integer-based format then filter must be VK_FILTER_NEAREST"); | ||||
13699 | // Expect INVALID_FILTER | ||||
13700 | VkImageObj intImage1(m_device); | ||||
13701 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, | ||||
13702 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, | ||||
13703 | 0); | ||||
13704 | VkImageObj intImage2(m_device); | ||||
13705 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, | ||||
13706 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, | ||||
13707 | 0); | ||||
13708 | VkImageBlit blitRegion = {}; | ||||
13709 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
13710 | blitRegion.srcSubresource.baseArrayLayer = 0; | ||||
13711 | blitRegion.srcSubresource.layerCount = 1; | ||||
13712 | blitRegion.srcSubresource.mipLevel = 0; | ||||
13713 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
13714 | blitRegion.dstSubresource.baseArrayLayer = 0; | ||||
13715 | blitRegion.dstSubresource.layerCount = 1; | ||||
13716 | blitRegion.dstSubresource.mipLevel = 0; | ||||
13717 | |||||
13718 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), | ||||
13719 | intImage1.layout(), intImage2.handle(), intImage2.layout(), | ||||
13720 | 16, &blitRegion, VK_FILTER_LINEAR); | ||||
13721 | m_errorMonitor->VerifyFound(); | ||||
13722 | |||||
13723 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13724 | "called with 0 in ppMemoryBarriers"); | ||||
13725 | VkImageMemoryBarrier img_barrier; | ||||
13726 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; | ||||
13727 | img_barrier.pNext = NULL; | ||||
13728 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
13729 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
13730 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
13731 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
13732 | img_barrier.image = image.handle(); | ||||
13733 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
13734 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
13735 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
13736 | img_barrier.subresourceRange.baseArrayLayer = 0; | ||||
13737 | img_barrier.subresourceRange.baseMipLevel = 0; | ||||
13738 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE | ||||
13739 | img_barrier.subresourceRange.layerCount = 0; | ||||
13740 | img_barrier.subresourceRange.levelCount = 1; | ||||
13741 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
13742 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
13743 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
13744 | nullptr, 1, &img_barrier); | ||||
13745 | m_errorMonitor->VerifyFound(); | ||||
13746 | img_barrier.subresourceRange.layerCount = 1; | ||||
13747 | } | ||||
13748 | |||||
13749 | TEST_F(VkLayerTest, ImageFormatLimits) { | ||||
13750 | |||||
13751 | TEST_DESCRIPTION("Exceed the limits of image format "); | ||||
13752 | |||||
13753 | m_errorMonitor->SetDesiredFailureMsg( | ||||
13754 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13755 | "CreateImage extents exceed allowable limits for format"); | ||||
13756 | VkImageCreateInfo image_create_info = {}; | ||||
13757 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
13758 | image_create_info.pNext = NULL; | ||||
13759 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
13760 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
13761 | image_create_info.extent.width = 32; | ||||
13762 | image_create_info.extent.height = 32; | ||||
13763 | image_create_info.extent.depth = 1; | ||||
13764 | image_create_info.mipLevels = 1; | ||||
13765 | image_create_info.arrayLayers = 1; | ||||
13766 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
13767 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
13768 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
13769 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; | ||||
13770 | image_create_info.flags = 0; | ||||
13771 | |||||
13772 | VkImage nullImg; | ||||
13773 | VkImageFormatProperties imgFmtProps; | ||||
13774 | vkGetPhysicalDeviceImageFormatProperties( | ||||
13775 | gpu(), image_create_info.format, image_create_info.imageType, | ||||
13776 | image_create_info.tiling, image_create_info.usage, | ||||
13777 | image_create_info.flags, &imgFmtProps); | ||||
13778 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; | ||||
13779 | // Expect INVALID_FORMAT_LIMITS_VIOLATION | ||||
13780 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
13781 | m_errorMonitor->VerifyFound(); | ||||
13782 | image_create_info.extent.depth = 1; | ||||
13783 | |||||
13784 | m_errorMonitor->SetDesiredFailureMsg( | ||||
13785 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13786 | "exceeds allowable maximum supported by format of"); | ||||
13787 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; | ||||
13788 | // Expect INVALID_FORMAT_LIMITS_VIOLATION | ||||
13789 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
13790 | m_errorMonitor->VerifyFound(); | ||||
13791 | image_create_info.mipLevels = 1; | ||||
13792 | |||||
13793 | m_errorMonitor->SetDesiredFailureMsg( | ||||
13794 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13795 | "exceeds allowable maximum supported by format of"); | ||||
13796 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; | ||||
13797 | // Expect INVALID_FORMAT_LIMITS_VIOLATION | ||||
13798 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
13799 | m_errorMonitor->VerifyFound(); | ||||
13800 | image_create_info.arrayLayers = 1; | ||||
13801 | |||||
13802 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13803 | "is not supported by format"); | ||||
13804 | int samples = imgFmtProps.sampleCounts >> 1; | ||||
13805 | image_create_info.samples = (VkSampleCountFlagBits)samples; | ||||
13806 | // Expect INVALID_FORMAT_LIMITS_VIOLATION | ||||
13807 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
13808 | m_errorMonitor->VerifyFound(); | ||||
13809 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
13810 | |||||
13811 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13812 | "pCreateInfo->initialLayout, must be " | ||||
13813 | "VK_IMAGE_LAYOUT_UNDEFINED or " | ||||
13814 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); | ||||
13815 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
13816 | // Expect INVALID_LAYOUT | ||||
13817 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
13818 | m_errorMonitor->VerifyFound(); | ||||
13819 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; | ||||
13820 | } | ||||
13821 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13822 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 13823 | VkResult err; |
13824 | bool pass; | ||||
13825 | |||||
13826 | // Create color images with different format sizes and try to copy between them | ||||
13827 | m_errorMonitor->SetDesiredFailureMsg( | ||||
13828 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13829 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); | ||||
13830 | |||||
13831 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13832 | |||||
13833 | // Create two images of different types and try to copy between them | ||||
13834 | VkImage srcImage; | ||||
13835 | VkImage dstImage; | ||||
13836 | VkDeviceMemory srcMem; | ||||
13837 | VkDeviceMemory destMem; | ||||
13838 | VkMemoryRequirements memReqs; | ||||
13839 | |||||
13840 | VkImageCreateInfo image_create_info = {}; | ||||
13841 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
13842 | image_create_info.pNext = NULL; | ||||
13843 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
13844 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
13845 | image_create_info.extent.width = 32; | ||||
13846 | image_create_info.extent.height = 32; | ||||
13847 | image_create_info.extent.depth = 1; | ||||
13848 | image_create_info.mipLevels = 1; | ||||
13849 | image_create_info.arrayLayers = 1; | ||||
13850 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
13851 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
13852 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
13853 | image_create_info.flags = 0; | ||||
13854 | |||||
13855 | err = | ||||
13856 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
13857 | ASSERT_VK_SUCCESS(err); | ||||
13858 | |||||
13859 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; | ||||
13860 | // Introduce failure by creating second image with a different-sized format. | ||||
13861 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; | ||||
13862 | |||||
13863 | err = | ||||
13864 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
13865 | ASSERT_VK_SUCCESS(err); | ||||
13866 | |||||
13867 | // Allocate memory | ||||
13868 | VkMemoryAllocateInfo memAlloc = {}; | ||||
13869 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
13870 | memAlloc.pNext = NULL; | ||||
13871 | memAlloc.allocationSize = 0; | ||||
13872 | memAlloc.memoryTypeIndex = 0; | ||||
13873 | |||||
13874 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); | ||||
13875 | memAlloc.allocationSize = memReqs.size; | ||||
13876 | pass = | ||||
13877 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
13878 | ASSERT_TRUE(pass); | ||||
13879 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); | ||||
13880 | ASSERT_VK_SUCCESS(err); | ||||
13881 | |||||
13882 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); | ||||
13883 | memAlloc.allocationSize = memReqs.size; | ||||
13884 | pass = | ||||
13885 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
13886 | ASSERT_TRUE(pass); | ||||
13887 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); | ||||
13888 | ASSERT_VK_SUCCESS(err); | ||||
13889 | |||||
13890 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
13891 | ASSERT_VK_SUCCESS(err); | ||||
13892 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); | ||||
13893 | ASSERT_VK_SUCCESS(err); | ||||
13894 | |||||
13895 | BeginCommandBuffer(); | ||||
13896 | VkImageCopy copyRegion; | ||||
13897 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
13898 | copyRegion.srcSubresource.mipLevel = 0; | ||||
13899 | copyRegion.srcSubresource.baseArrayLayer = 0; | ||||
13900 | copyRegion.srcSubresource.layerCount = 0; | ||||
13901 | copyRegion.srcOffset.x = 0; | ||||
13902 | copyRegion.srcOffset.y = 0; | ||||
13903 | copyRegion.srcOffset.z = 0; | ||||
13904 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
13905 | copyRegion.dstSubresource.mipLevel = 0; | ||||
13906 | copyRegion.dstSubresource.baseArrayLayer = 0; | ||||
13907 | copyRegion.dstSubresource.layerCount = 0; | ||||
13908 | copyRegion.dstOffset.x = 0; | ||||
13909 | copyRegion.dstOffset.y = 0; | ||||
13910 | copyRegion.dstOffset.z = 0; | ||||
13911 | copyRegion.extent.width = 1; | ||||
13912 | copyRegion.extent.height = 1; | ||||
13913 | copyRegion.extent.depth = 1; | ||||
13914 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, | ||||
13915 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
13916 | EndCommandBuffer(); | ||||
13917 | |||||
13918 | m_errorMonitor->VerifyFound(); | ||||
13919 | |||||
13920 | vkDestroyImage(m_device->device(), srcImage, NULL); | ||||
13921 | vkDestroyImage(m_device->device(), dstImage, NULL); | ||||
13922 | vkFreeMemory(m_device->device(), srcMem, NULL); | ||||
13923 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13924 | } |
13925 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13926 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
13927 | VkResult err; | ||||
13928 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13929 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 13930 | // Create a color image and a depth/stencil image and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13931 | m_errorMonitor->SetDesiredFailureMsg( |
13932 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 13933 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13934 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13935 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13936 | |
13937 | // Create two images of different types and try to copy between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13938 | VkImage srcImage; |
13939 | VkImage dstImage; | ||||
13940 | VkDeviceMemory srcMem; | ||||
13941 | VkDeviceMemory destMem; | ||||
13942 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13943 | |
13944 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13945 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
13946 | image_create_info.pNext = NULL; | ||||
13947 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
13948 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
13949 | image_create_info.extent.width = 32; | ||||
13950 | image_create_info.extent.height = 32; | ||||
13951 | image_create_info.extent.depth = 1; | ||||
13952 | image_create_info.mipLevels = 1; | ||||
13953 | image_create_info.arrayLayers = 1; | ||||
13954 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
13955 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
13956 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
13957 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13958 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13959 | err = |
13960 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13961 | ASSERT_VK_SUCCESS(err); |
13962 | |||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 13963 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
13964 | |||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 13965 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13966 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 13967 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
13968 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13969 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13970 | err = |
13971 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13972 | ASSERT_VK_SUCCESS(err); |
13973 | |||||
13974 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13975 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13976 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
13977 | memAlloc.pNext = NULL; | ||||
13978 | memAlloc.allocationSize = 0; | ||||
13979 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13980 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 13981 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13982 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13983 | pass = |
13984 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 13985 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13986 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13987 | ASSERT_VK_SUCCESS(err); |
13988 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13989 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13990 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13991 | pass = |
13992 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 13993 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13994 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 13995 | ASSERT_VK_SUCCESS(err); |
13996 | |||||
13997 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
13998 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13999 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14000 | ASSERT_VK_SUCCESS(err); |
14001 | |||||
14002 | BeginCommandBuffer(); | ||||
14003 | VkImageCopy copyRegion; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 14004 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14005 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 14006 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14007 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14008 | copyRegion.srcOffset.x = 0; |
14009 | copyRegion.srcOffset.y = 0; | ||||
14010 | copyRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 14011 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14012 | copyRegion.dstSubresource.mipLevel = 0; |
14013 | copyRegion.dstSubresource.baseArrayLayer = 0; | ||||
14014 | copyRegion.dstSubresource.layerCount = 0; | ||||
14015 | copyRegion.dstOffset.x = 0; | ||||
14016 | copyRegion.dstOffset.y = 0; | ||||
14017 | copyRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14018 | copyRegion.extent.width = 1; |
14019 | copyRegion.extent.height = 1; | ||||
14020 | copyRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14021 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
14022 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14023 | EndCommandBuffer(); |
14024 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 14025 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14026 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14027 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14028 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14029 | vkFreeMemory(m_device->device(), srcMem, NULL); |
14030 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14031 | } |
14032 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14033 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
14034 | VkResult err; | ||||
14035 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14036 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14037 | m_errorMonitor->SetDesiredFailureMsg( |
14038 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 14039 | "vkCmdResolveImage called with source sample count less than 2."); |
14040 | |||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14041 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14042 | |
14043 | // Create two images of sample count 1 and try to Resolve between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14044 | VkImage srcImage; |
14045 | VkImage dstImage; | ||||
14046 | VkDeviceMemory srcMem; | ||||
14047 | VkDeviceMemory destMem; | ||||
14048 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14049 | |
14050 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14051 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
14052 | image_create_info.pNext = NULL; | ||||
14053 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14054 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
14055 | image_create_info.extent.width = 32; | ||||
14056 | image_create_info.extent.height = 1; | ||||
14057 | image_create_info.extent.depth = 1; | ||||
14058 | image_create_info.mipLevels = 1; | ||||
14059 | image_create_info.arrayLayers = 1; | ||||
14060 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
14061 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
14062 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
14063 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14064 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14065 | err = |
14066 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14067 | ASSERT_VK_SUCCESS(err); |
14068 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14069 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14070 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14071 | err = |
14072 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14073 | ASSERT_VK_SUCCESS(err); |
14074 | |||||
14075 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14076 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14077 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
14078 | memAlloc.pNext = NULL; | ||||
14079 | memAlloc.allocationSize = 0; | ||||
14080 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14081 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 14082 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14083 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14084 | pass = |
14085 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 14086 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14087 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14088 | ASSERT_VK_SUCCESS(err); |
14089 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14090 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14091 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14092 | pass = |
14093 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 14094 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14095 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14096 | ASSERT_VK_SUCCESS(err); |
14097 | |||||
14098 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
14099 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14100 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14101 | ASSERT_VK_SUCCESS(err); |
14102 | |||||
14103 | BeginCommandBuffer(); | ||||
14104 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14105 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
14106 | // VK_IMAGE_LAYOUT_GENERAL = 1, | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14107 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 14108 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14109 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 14110 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14111 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14112 | resolveRegion.srcOffset.x = 0; |
14113 | resolveRegion.srcOffset.y = 0; | ||||
14114 | resolveRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 14115 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14116 | resolveRegion.dstSubresource.mipLevel = 0; |
14117 | resolveRegion.dstSubresource.baseArrayLayer = 0; | ||||
14118 | resolveRegion.dstSubresource.layerCount = 0; | ||||
14119 | resolveRegion.dstOffset.x = 0; | ||||
14120 | resolveRegion.dstOffset.y = 0; | ||||
14121 | resolveRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14122 | resolveRegion.extent.width = 1; |
14123 | resolveRegion.extent.height = 1; | ||||
14124 | resolveRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14125 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
14126 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14127 | EndCommandBuffer(); |
14128 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 14129 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14130 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14131 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14132 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14133 | vkFreeMemory(m_device->device(), srcMem, NULL); |
14134 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14135 | } |
14136 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14137 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
14138 | VkResult err; | ||||
14139 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14140 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14141 | m_errorMonitor->SetDesiredFailureMsg( |
14142 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 14143 | "vkCmdResolveImage called with dest sample count greater than 1."); |
14144 | |||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14145 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14146 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 14147 | // Create two images of sample count 4 and try to Resolve between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14148 | VkImage srcImage; |
14149 | VkImage dstImage; | ||||
14150 | VkDeviceMemory srcMem; | ||||
14151 | VkDeviceMemory destMem; | ||||
14152 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14153 | |
14154 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14155 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
14156 | image_create_info.pNext = NULL; | ||||
14157 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14158 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
14159 | image_create_info.extent.width = 32; | ||||
14160 | image_create_info.extent.height = 1; | ||||
14161 | image_create_info.extent.depth = 1; | ||||
14162 | image_create_info.mipLevels = 1; | ||||
14163 | image_create_info.arrayLayers = 1; | ||||
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 14164 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14165 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
14166 | // Note: Some implementations expect color attachment usage for any | ||||
14167 | // multisample surface | ||||
14168 | image_create_info.usage = | ||||
14169 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
14170 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14171 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14172 | err = |
14173 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14174 | ASSERT_VK_SUCCESS(err); |
14175 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14176 | // Note: Some implementations expect color attachment usage for any |
14177 | // multisample surface | ||||
14178 | image_create_info.usage = | ||||
14179 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14180 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14181 | err = |
14182 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14183 | ASSERT_VK_SUCCESS(err); |
14184 | |||||
14185 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14186 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14187 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
14188 | memAlloc.pNext = NULL; | ||||
14189 | memAlloc.allocationSize = 0; | ||||
14190 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14191 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 14192 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14193 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14194 | pass = |
14195 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 14196 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14197 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14198 | ASSERT_VK_SUCCESS(err); |
14199 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14200 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14201 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14202 | pass = |
14203 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 14204 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14205 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14206 | ASSERT_VK_SUCCESS(err); |
14207 | |||||
14208 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
14209 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14210 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14211 | ASSERT_VK_SUCCESS(err); |
14212 | |||||
14213 | BeginCommandBuffer(); | ||||
14214 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14215 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
14216 | // VK_IMAGE_LAYOUT_GENERAL = 1, | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14217 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 14218 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14219 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 14220 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14221 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14222 | resolveRegion.srcOffset.x = 0; |
14223 | resolveRegion.srcOffset.y = 0; | ||||
14224 | resolveRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 14225 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14226 | resolveRegion.dstSubresource.mipLevel = 0; |
14227 | resolveRegion.dstSubresource.baseArrayLayer = 0; | ||||
14228 | resolveRegion.dstSubresource.layerCount = 0; | ||||
14229 | resolveRegion.dstOffset.x = 0; | ||||
14230 | resolveRegion.dstOffset.y = 0; | ||||
14231 | resolveRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14232 | resolveRegion.extent.width = 1; |
14233 | resolveRegion.extent.height = 1; | ||||
14234 | resolveRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14235 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
14236 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14237 | EndCommandBuffer(); |
14238 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 14239 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14240 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14241 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14242 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14243 | vkFreeMemory(m_device->device(), srcMem, NULL); |
14244 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14245 | } |
14246 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14247 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
14248 | VkResult err; | ||||
14249 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14250 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14251 | m_errorMonitor->SetDesiredFailureMsg( |
14252 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 14253 | "vkCmdResolveImage called with unmatched source and dest formats."); |
14254 | |||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14255 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14256 | |
14257 | // Create two images of different types and try to copy between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14258 | VkImage srcImage; |
14259 | VkImage dstImage; | ||||
14260 | VkDeviceMemory srcMem; | ||||
14261 | VkDeviceMemory destMem; | ||||
14262 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14263 | |
14264 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14265 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
14266 | image_create_info.pNext = NULL; | ||||
14267 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14268 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
14269 | image_create_info.extent.width = 32; | ||||
14270 | image_create_info.extent.height = 1; | ||||
14271 | image_create_info.extent.depth = 1; | ||||
14272 | image_create_info.mipLevels = 1; | ||||
14273 | image_create_info.arrayLayers = 1; | ||||
14274 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; | ||||
14275 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
14276 | // Note: Some implementations expect color attachment usage for any | ||||
14277 | // multisample surface | ||||
14278 | image_create_info.usage = | ||||
14279 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
14280 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14281 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14282 | err = |
14283 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14284 | ASSERT_VK_SUCCESS(err); |
14285 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14286 | // Set format to something other than source image |
14287 | image_create_info.format = VK_FORMAT_R32_SFLOAT; | ||||
14288 | // Note: Some implementations expect color attachment usage for any | ||||
14289 | // multisample surface | ||||
14290 | image_create_info.usage = | ||||
14291 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
14292 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14293 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14294 | err = |
14295 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14296 | ASSERT_VK_SUCCESS(err); |
14297 | |||||
14298 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14299 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14300 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
14301 | memAlloc.pNext = NULL; | ||||
14302 | memAlloc.allocationSize = 0; | ||||
14303 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14304 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 14305 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14306 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14307 | pass = |
14308 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 14309 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14310 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14311 | ASSERT_VK_SUCCESS(err); |
14312 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14313 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14314 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14315 | pass = |
14316 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 14317 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14318 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14319 | ASSERT_VK_SUCCESS(err); |
14320 | |||||
14321 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
14322 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14323 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14324 | ASSERT_VK_SUCCESS(err); |
14325 | |||||
14326 | BeginCommandBuffer(); | ||||
14327 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14328 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
14329 | // VK_IMAGE_LAYOUT_GENERAL = 1, | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14330 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 14331 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14332 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 14333 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14334 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14335 | resolveRegion.srcOffset.x = 0; |
14336 | resolveRegion.srcOffset.y = 0; | ||||
14337 | resolveRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 14338 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14339 | resolveRegion.dstSubresource.mipLevel = 0; |
14340 | resolveRegion.dstSubresource.baseArrayLayer = 0; | ||||
14341 | resolveRegion.dstSubresource.layerCount = 0; | ||||
14342 | resolveRegion.dstOffset.x = 0; | ||||
14343 | resolveRegion.dstOffset.y = 0; | ||||
14344 | resolveRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14345 | resolveRegion.extent.width = 1; |
14346 | resolveRegion.extent.height = 1; | ||||
14347 | resolveRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14348 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
14349 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14350 | EndCommandBuffer(); |
14351 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 14352 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14353 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14354 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14355 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14356 | vkFreeMemory(m_device->device(), srcMem, NULL); |
14357 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14358 | } |
14359 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14360 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
14361 | VkResult err; | ||||
14362 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14363 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14364 | m_errorMonitor->SetDesiredFailureMsg( |
14365 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 14366 | "vkCmdResolveImage called with unmatched source and dest image types."); |
14367 | |||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14368 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14369 | |
14370 | // Create two images of different types and try to copy between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14371 | VkImage srcImage; |
14372 | VkImage dstImage; | ||||
14373 | VkDeviceMemory srcMem; | ||||
14374 | VkDeviceMemory destMem; | ||||
14375 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14376 | |
14377 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14378 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
14379 | image_create_info.pNext = NULL; | ||||
14380 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14381 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
14382 | image_create_info.extent.width = 32; | ||||
14383 | image_create_info.extent.height = 1; | ||||
14384 | image_create_info.extent.depth = 1; | ||||
14385 | image_create_info.mipLevels = 1; | ||||
14386 | image_create_info.arrayLayers = 1; | ||||
14387 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; | ||||
14388 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
14389 | // Note: Some implementations expect color attachment usage for any | ||||
14390 | // multisample surface | ||||
14391 | image_create_info.usage = | ||||
14392 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
14393 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14394 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14395 | err = |
14396 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14397 | ASSERT_VK_SUCCESS(err); |
14398 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14399 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
14400 | // Note: Some implementations expect color attachment usage for any | ||||
14401 | // multisample surface | ||||
14402 | image_create_info.usage = | ||||
14403 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
14404 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14405 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14406 | err = |
14407 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14408 | ASSERT_VK_SUCCESS(err); |
14409 | |||||
14410 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14411 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14412 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
14413 | memAlloc.pNext = NULL; | ||||
14414 | memAlloc.allocationSize = 0; | ||||
14415 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14416 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 14417 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14418 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14419 | pass = |
14420 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 14421 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14422 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14423 | ASSERT_VK_SUCCESS(err); |
14424 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14425 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14426 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14427 | pass = |
14428 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 14429 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14430 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14431 | ASSERT_VK_SUCCESS(err); |
14432 | |||||
14433 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
14434 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14435 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14436 | ASSERT_VK_SUCCESS(err); |
14437 | |||||
14438 | BeginCommandBuffer(); | ||||
14439 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14440 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
14441 | // VK_IMAGE_LAYOUT_GENERAL = 1, | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14442 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 14443 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14444 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 14445 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14446 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14447 | resolveRegion.srcOffset.x = 0; |
14448 | resolveRegion.srcOffset.y = 0; | ||||
14449 | resolveRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 14450 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14451 | resolveRegion.dstSubresource.mipLevel = 0; |
14452 | resolveRegion.dstSubresource.baseArrayLayer = 0; | ||||
14453 | resolveRegion.dstSubresource.layerCount = 0; | ||||
14454 | resolveRegion.dstOffset.x = 0; | ||||
14455 | resolveRegion.dstOffset.y = 0; | ||||
14456 | resolveRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14457 | resolveRegion.extent.width = 1; |
14458 | resolveRegion.extent.height = 1; | ||||
14459 | resolveRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14460 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
14461 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14462 | EndCommandBuffer(); |
14463 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 14464 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14465 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14466 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14467 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14468 | vkFreeMemory(m_device->device(), srcMem, NULL); |
14469 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14470 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14472 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14473 | // Create a single Image descriptor and cause it to first hit an error due |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14474 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
14475 | // set in aspect | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14476 | // The image format check comes 2nd in validation so we trigger it first, |
14477 | // then when we cause aspect fail next, bad format check will be preempted | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14478 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14479 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14480 | m_errorMonitor->SetDesiredFailureMsg( |
14481 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 14482 | "Combination depth/stencil image formats can have only the "); |
14483 | |||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14484 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 14485 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 14486 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14487 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
14488 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14489 | |
14490 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14491 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
14492 | ds_pool_ci.pNext = NULL; | ||||
14493 | ds_pool_ci.maxSets = 1; | ||||
14494 | ds_pool_ci.poolSizeCount = 1; | ||||
14495 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14496 | |
14497 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14498 | err = |
14499 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14500 | ASSERT_VK_SUCCESS(err); |
14501 | |||||
14502 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14503 | dsl_binding.binding = 0; |
14504 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
14505 | dsl_binding.descriptorCount = 1; | ||||
14506 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
14507 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14508 | |
14509 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14510 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
14511 | ds_layout_ci.pNext = NULL; | ||||
14512 | ds_layout_ci.bindingCount = 1; | ||||
14513 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14514 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14515 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
14516 | &ds_layout); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14517 | ASSERT_VK_SUCCESS(err); |
14518 | |||||
14519 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14520 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 14521 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 14522 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14523 | alloc_info.descriptorPool = ds_pool; |
14524 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14525 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
14526 | &descriptorSet); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14527 | ASSERT_VK_SUCCESS(err); |
14528 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14529 | VkImage image_bad; |
14530 | VkImage image_good; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14531 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 14532 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14533 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14534 | const int32_t tex_width = 32; |
14535 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14536 | |
14537 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14538 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
14539 | image_create_info.pNext = NULL; | ||||
14540 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14541 | image_create_info.format = tex_format_bad; | ||||
14542 | image_create_info.extent.width = tex_width; | ||||
14543 | image_create_info.extent.height = tex_height; | ||||
14544 | image_create_info.extent.depth = 1; | ||||
14545 | image_create_info.mipLevels = 1; | ||||
14546 | image_create_info.arrayLayers = 1; | ||||
14547 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
14548 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
14549 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | | ||||
14550 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; | ||||
14551 | image_create_info.flags = 0; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14552 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14553 | err = |
14554 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14555 | ASSERT_VK_SUCCESS(err); |
14556 | image_create_info.format = tex_format_good; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14557 | image_create_info.usage = |
14558 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
14559 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, | ||||
14560 | &image_good); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14561 | ASSERT_VK_SUCCESS(err); |
14562 | |||||
14563 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14564 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
14565 | image_view_create_info.image = image_bad; | ||||
14566 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
14567 | image_view_create_info.format = tex_format_bad; | ||||
14568 | image_view_create_info.subresourceRange.baseArrayLayer = 0; | ||||
14569 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
14570 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
14571 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
14572 | image_view_create_info.subresourceRange.aspectMask = | ||||
14573 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14574 | |
14575 | VkImageView view; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14576 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
14577 | &view); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 14578 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 14579 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14580 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14581 | vkDestroyImage(m_device->device(), image_bad, NULL); |
14582 | vkDestroyImage(m_device->device(), image_good, NULL); | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14583 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
14584 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 14585 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 14586 | |
14587 | TEST_F(VkLayerTest, ClearImageErrors) { | ||||
14588 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " | ||||
14589 | "ClearDepthStencilImage with a color image."); | ||||
14590 | |||||
14591 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14592 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
14593 | |||||
14594 | // Renderpass is started here so end it as Clear cmds can't be in renderpass | ||||
14595 | BeginCommandBuffer(); | ||||
14596 | m_commandBuffer->EndRenderPass(); | ||||
14597 | |||||
14598 | // Color image | ||||
14599 | VkClearColorValue clear_color; | ||||
14600 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); | ||||
14601 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
14602 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
14603 | const int32_t img_width = 32; | ||||
14604 | const int32_t img_height = 32; | ||||
14605 | VkImageCreateInfo image_create_info = {}; | ||||
14606 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
14607 | image_create_info.pNext = NULL; | ||||
14608 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14609 | image_create_info.format = color_format; | ||||
14610 | image_create_info.extent.width = img_width; | ||||
14611 | image_create_info.extent.height = img_height; | ||||
14612 | image_create_info.extent.depth = 1; | ||||
14613 | image_create_info.mipLevels = 1; | ||||
14614 | image_create_info.arrayLayers = 1; | ||||
14615 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
14616 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
14617 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
14618 | |||||
14619 | vk_testing::Image color_image; | ||||
14620 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, | ||||
14621 | reqs); | ||||
14622 | |||||
14623 | const VkImageSubresourceRange color_range = | ||||
14624 | vk_testing::Image::subresource_range(image_create_info, | ||||
14625 | VK_IMAGE_ASPECT_COLOR_BIT); | ||||
14626 | |||||
14627 | // Depth/Stencil image | ||||
14628 | VkClearDepthStencilValue clear_value = {0}; | ||||
14629 | reqs = 0; // don't need HOST_VISIBLE DS image | ||||
14630 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); | ||||
14631 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14632 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
14633 | ds_image_create_info.extent.width = 64; | ||||
14634 | ds_image_create_info.extent.height = 64; | ||||
14635 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
14636 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; | ||||
14637 | |||||
14638 | vk_testing::Image ds_image; | ||||
14639 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, | ||||
14640 | reqs); | ||||
14641 | |||||
14642 | const VkImageSubresourceRange ds_range = | ||||
14643 | vk_testing::Image::subresource_range(ds_image_create_info, | ||||
14644 | VK_IMAGE_ASPECT_DEPTH_BIT); | ||||
14645 | |||||
14646 | m_errorMonitor->SetDesiredFailureMsg( | ||||
14647 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14648 | "vkCmdClearColorImage called with depth/stencil image."); | ||||
14649 | |||||
14650 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), | ||||
14651 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, | ||||
14652 | &color_range); | ||||
14653 | |||||
14654 | m_errorMonitor->VerifyFound(); | ||||
14655 | |||||
Tony Barbour | 26434b9 | 2016-06-02 09:43:50 -0600 | [diff] [blame] | 14656 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
14657 | "vkCmdClearColorImage called with " | ||||
14658 | "image created without " | ||||
14659 | "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); | ||||
14660 | |||||
14661 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), | ||||
14662 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, | ||||
14663 | &color_range); | ||||
14664 | |||||
14665 | m_errorMonitor->VerifyFound(); | ||||
14666 | |||||
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 14667 | // Call CmdClearDepthStencilImage with color image |
14668 | m_errorMonitor->SetDesiredFailureMsg( | ||||
14669 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14670 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); | ||||
14671 | |||||
14672 | vkCmdClearDepthStencilImage( | ||||
14673 | m_commandBuffer->GetBufferHandle(), color_image.handle(), | ||||
14674 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, | ||||
14675 | &ds_range); | ||||
14676 | |||||
14677 | m_errorMonitor->VerifyFound(); | ||||
14678 | } | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 14679 | #endif // IMAGE_TESTS |
14680 | |||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 14681 | int main(int argc, char **argv) { |
14682 | int result; | ||||
14683 | |||||
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 14684 | #ifdef ANDROID |
14685 | int vulkanSupport = InitVulkan(); | ||||
14686 | if (vulkanSupport == 0) | ||||
14687 | return 1; | ||||
14688 | #endif | ||||
14689 | |||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 14690 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 14691 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 14692 | |
14693 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); | ||||
14694 | |||||
14695 | result = RUN_ALL_TESTS(); | ||||
14696 | |||||
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 14697 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 14698 | return result; |
14699 | } |