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 | } | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 255 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 256 | void QueueCommandBuffer(const VkFence &fence) { |
257 | m_commandBuffer->QueueCommandBuffer(fence); | ||||
258 | } | ||||
259 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, | ||||
260 | VkDeviceSize offset, uint32_t binding) { | ||||
261 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); | ||||
262 | } | ||||
263 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { | ||||
264 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); | ||||
265 | } | ||||
266 | |||||
267 | protected: | ||||
268 | ErrorMonitor *m_errorMonitor; | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 269 | bool m_enableWSI; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 270 | |
271 | virtual void SetUp() { | ||||
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 272 | std::vector<const char *> instance_layer_names; |
273 | std::vector<const char *> device_layer_names; | ||||
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 274 | std::vector<const char *> instance_extension_names; |
275 | std::vector<const char *> device_extension_names; | ||||
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 276 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 277 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 278 | /* |
279 | * Since CreateDbgMsgCallback is an instance level extension call | ||||
280 | * any extension / layer that utilizes that feature also needs | ||||
281 | * to be enabled at create instance time. | ||||
282 | */ | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 283 | // Use Threading layer first to protect others from |
284 | // ThreadCommandBufferCollision test | ||||
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
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_device_limits"); |
299 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); | ||||
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 300 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 301 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 302 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 303 | if (m_enableWSI) { |
304 | instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME); | ||||
305 | device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); | ||||
306 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM | ||||
307 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) | ||||
308 | instance_extension_names.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); | ||||
309 | #endif // VK_USE_PLATFORM_ANDROID_KHR | ||||
310 | #if defined(VK_USE_PLATFORM_MIR_KHR) | ||||
311 | instance_extension_names.push_back(VK_KHR_MIR_SURFACE_EXTENSION_NAME); | ||||
312 | #endif // VK_USE_PLATFORM_MIR_KHR | ||||
313 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) | ||||
314 | instance_extension_names.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); | ||||
315 | #endif // VK_USE_PLATFORM_WAYLAND_KHR | ||||
316 | #if defined(VK_USE_PLATFORM_WIN32_KHR) | ||||
317 | instance_extension_names.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); | ||||
318 | #endif // VK_USE_PLATFORM_WIN32_KHR | ||||
319 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM | ||||
320 | #if defined(VK_USE_PLATFORM_XCB_KHR) | ||||
321 | instance_extension_names.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); | ||||
322 | #elif defined(VK_USE_PLATFORM_XLIB_KHR) | ||||
323 | instance_extension_names.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); | ||||
324 | #endif // VK_USE_PLATFORM_XLIB_KHR | ||||
325 | } | ||||
326 | |||||
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 327 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 328 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 329 | this->app_info.pApplicationName = "layer_tests"; |
330 | this->app_info.applicationVersion = 1; | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 331 | this->app_info.pEngineName = "unittest"; |
332 | this->app_info.engineVersion = 1; | ||||
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 333 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 334 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 335 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 336 | InitFramework(instance_layer_names, device_layer_names, |
337 | instance_extension_names, device_extension_names, | ||||
338 | myDbgFunc, m_errorMonitor); | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 339 | } |
340 | |||||
341 | virtual void TearDown() { | ||||
342 | // Clean up resources before we reset | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 343 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 344 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 345 | } |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 346 | |
347 | VkLayerTest() { | ||||
348 | m_enableWSI = false; | ||||
349 | } | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 350 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 351 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 352 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 353 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 354 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 355 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 356 | |
357 | /* | ||||
358 | * For render test all drawing happens in a single render pass | ||||
359 | * on a single command buffer. | ||||
360 | */ | ||||
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 361 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 362 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 363 | } |
364 | |||||
365 | return result; | ||||
366 | } | ||||
367 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 368 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 369 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 370 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 371 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 372 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 373 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 374 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 375 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 376 | |
377 | return result; | ||||
378 | } | ||||
379 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 380 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
381 | const char *fragShaderText, | ||||
382 | BsoFailSelect failMask) { | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 383 | // Create identity matrix |
384 | int i; | ||||
385 | struct vktriangle_vs_uniform data; | ||||
386 | |||||
387 | glm::mat4 Projection = glm::mat4(1.0f); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 388 | glm::mat4 View = glm::mat4(1.0f); |
389 | glm::mat4 Model = glm::mat4(1.0f); | ||||
390 | glm::mat4 MVP = Projection * View * Model; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 391 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 392 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 393 | |
394 | memcpy(&data.mvp, &MVP[0][0], matrixSize); | ||||
395 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 396 | static const Vertex tri_data[] = { |
397 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, | ||||
398 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, | ||||
399 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 400 | }; |
401 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 402 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 403 | data.position[i][0] = tri_data[i].posX; |
404 | data.position[i][1] = tri_data[i].posY; | ||||
405 | data.position[i][2] = tri_data[i].posZ; | ||||
406 | data.position[i][3] = tri_data[i].posW; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 407 | data.color[i][0] = tri_data[i].r; |
408 | data.color[i][1] = tri_data[i].g; | ||||
409 | data.color[i][2] = tri_data[i].b; | ||||
410 | data.color[i][3] = tri_data[i].a; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 411 | } |
412 | |||||
413 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
414 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
415 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 416 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
417 | (const void *)&data); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 418 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 419 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
420 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
421 | this); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 422 | |
423 | VkPipelineObj pipelineobj(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 424 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 425 | pipelineobj.AddShader(&vs); |
426 | pipelineobj.AddShader(&ps); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 427 | if (failMask & BsoFailLineWidth) { |
428 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 429 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
430 | ia_state.sType = | ||||
431 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
432 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; | ||||
433 | pipelineobj.SetInputAssembly(&ia_state); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 434 | } |
435 | if (failMask & BsoFailDepthBias) { | ||||
436 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 437 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
438 | rs_state.sType = | ||||
439 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
440 | rs_state.depthBiasEnable = VK_TRUE; | ||||
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 441 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 442 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 443 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 444 | // Viewport and scissors must stay in synch or other errors will occur than |
445 | // the ones we want | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 446 | if (failMask & BsoFailViewport) { |
447 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 448 | m_viewports.clear(); |
449 | m_scissors.clear(); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 450 | } |
451 | if (failMask & BsoFailScissor) { | ||||
452 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 453 | m_scissors.clear(); |
454 | m_viewports.clear(); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 455 | } |
456 | if (failMask & BsoFailBlend) { | ||||
457 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 458 | VkPipelineColorBlendAttachmentState att_state = {}; |
459 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; | ||||
460 | att_state.blendEnable = VK_TRUE; | ||||
461 | pipelineobj.AddColorAttachment(0, &att_state); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 462 | } |
463 | if (failMask & BsoFailDepthBounds) { | ||||
464 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); | ||||
465 | } | ||||
466 | if (failMask & BsoFailStencilReadMask) { | ||||
467 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); | ||||
468 | } | ||||
469 | if (failMask & BsoFailStencilWriteMask) { | ||||
470 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); | ||||
471 | } | ||||
472 | if (failMask & BsoFailStencilReference) { | ||||
473 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); | ||||
474 | } | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 475 | |
476 | VkDescriptorSetObj descriptorSet(m_device); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 477 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
478 | constantBuffer); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 479 | |
480 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 481 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 482 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 483 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 484 | |
485 | // render triangle | ||||
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 486 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 487 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 488 | if (failMask & BsoFailCmdClearAttachments) { |
489 | VkClearAttachment color_attachment = {}; | ||||
490 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
491 | color_attachment.colorAttachment = 1; // Someone who knew what they were doing would use 0 for the index; | ||||
492 | VkClearRect clear_rect = {{{0, 0}, {static_cast<uint32_t>(m_width), static_cast<uint32_t>(m_height)}}, 0, 0}; | ||||
493 | |||||
494 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, | ||||
495 | &color_attachment, 1, &clear_rect); | ||||
496 | } | ||||
497 | |||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 498 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 499 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 500 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 501 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 502 | } |
503 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 504 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
505 | VkPipelineObj &pipelineobj, | ||||
506 | VkDescriptorSetObj &descriptorSet, | ||||
507 | BsoFailSelect failMask) { | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 508 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 509 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
510 | m_stencil_clear_color, m_depthStencil); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 511 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 512 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
513 | m_stencil_clear_color, NULL); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 514 | } |
515 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 516 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 517 | // Make sure depthWriteEnable is set so that Depth fail test will work |
518 | // correctly | ||||
519 | // Make sure stencilTestEnable is set so that Stencil fail test will work | ||||
520 | // correctly | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 521 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 522 | stencil.failOp = VK_STENCIL_OP_KEEP; |
523 | stencil.passOp = VK_STENCIL_OP_KEEP; | ||||
524 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; | ||||
525 | stencil.compareOp = VK_COMPARE_OP_NEVER; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 526 | |
527 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; | ||||
528 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 529 | ds_ci.pNext = NULL; |
530 | ds_ci.depthTestEnable = VK_FALSE; | ||||
531 | ds_ci.depthWriteEnable = VK_TRUE; | ||||
532 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; | ||||
533 | ds_ci.depthBoundsTestEnable = VK_FALSE; | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 534 | if (failMask & BsoFailDepthBounds) { |
535 | ds_ci.depthBoundsTestEnable = VK_TRUE; | ||||
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 536 | ds_ci.maxDepthBounds = 0.0f; |
537 | ds_ci.minDepthBounds = 0.0f; | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 538 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 539 | ds_ci.stencilTestEnable = VK_TRUE; |
540 | ds_ci.front = stencil; | ||||
541 | ds_ci.back = stencil; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 542 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 543 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 544 | pipelineobj.SetViewport(m_viewports); |
545 | pipelineobj.SetScissor(m_scissors); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 546 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 547 | VkResult err = pipelineobj.CreateVKPipeline( |
548 | descriptorSet.GetPipelineLayout(), renderPass()); | ||||
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 549 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 550 | commandBuffer->BindPipeline(pipelineobj); |
551 | commandBuffer->BindDescriptorSet(descriptorSet); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 552 | } |
553 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 554 | class VkWsiEnabledLayerTest : public VkLayerTest { |
555 | public: | ||||
556 | protected: | ||||
557 | VkWsiEnabledLayerTest() { | ||||
558 | m_enableWSI = true; | ||||
559 | } | ||||
560 | }; | ||||
561 | |||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 562 | // ******************************************************************************************************************** |
563 | // ******************************************************************************************************************** | ||||
564 | // ******************************************************************************************************************** | ||||
565 | // ******************************************************************************************************************** | ||||
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 566 | #if PARAMETER_VALIDATION_TESTS |
567 | TEST_F(VkLayerTest, RequiredParameter) { | ||||
568 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " | ||||
569 | "pointer, array, and array count parameters"); | ||||
570 | |||||
571 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
572 | |||||
573 | m_errorMonitor->SetDesiredFailureMsg( | ||||
574 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
575 | "required parameter pFeatures specified as NULL"); | ||||
576 | // Specify NULL for a pointer to a handle | ||||
577 | // Expected to trigger an error with | ||||
578 | // parameter_validation::validate_required_pointer | ||||
579 | vkGetPhysicalDeviceFeatures(gpu(), NULL); | ||||
580 | m_errorMonitor->VerifyFound(); | ||||
581 | |||||
582 | m_errorMonitor->SetDesiredFailureMsg( | ||||
583 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 584 | "required parameter pQueueFamilyPropertyCount specified as NULL"); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 585 | // Specify NULL for pointer to array count |
586 | // Expected to trigger an error with parameter_validation::validate_array | ||||
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 587 | vkGetPhysicalDeviceQueueFamilyProperties(gpu(), NULL, NULL); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 588 | m_errorMonitor->VerifyFound(); |
589 | |||||
590 | m_errorMonitor->SetDesiredFailureMsg( | ||||
591 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
592 | "parameter viewportCount must be greater than 0"); | ||||
593 | // Specify 0 for a required array count | ||||
594 | // Expected to trigger an error with parameter_validation::validate_array | ||||
595 | VkViewport view_port = {}; | ||||
596 | m_commandBuffer->SetViewport(0, 0, &view_port); | ||||
597 | m_errorMonitor->VerifyFound(); | ||||
598 | |||||
599 | m_errorMonitor->SetDesiredFailureMsg( | ||||
600 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
601 | "required parameter pViewports specified as NULL"); | ||||
602 | // Specify NULL for a required array | ||||
603 | // Expected to trigger an error with parameter_validation::validate_array | ||||
604 | m_commandBuffer->SetViewport(0, 1, NULL); | ||||
605 | m_errorMonitor->VerifyFound(); | ||||
606 | |||||
607 | m_errorMonitor->SetDesiredFailureMsg( | ||||
608 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
609 | "required parameter memory specified as VK_NULL_HANDLE"); | ||||
610 | // Specify VK_NULL_HANDLE for a required handle | ||||
611 | // Expected to trigger an error with | ||||
612 | // parameter_validation::validate_required_handle | ||||
613 | vkUnmapMemory(device(), VK_NULL_HANDLE); | ||||
614 | m_errorMonitor->VerifyFound(); | ||||
615 | |||||
616 | m_errorMonitor->SetDesiredFailureMsg( | ||||
617 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
618 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); | ||||
619 | // Specify VK_NULL_HANDLE for a required handle array entry | ||||
620 | // Expected to trigger an error with | ||||
621 | // parameter_validation::validate_required_handle_array | ||||
622 | VkFence fence = VK_NULL_HANDLE; | ||||
623 | vkResetFences(device(), 1, &fence); | ||||
624 | m_errorMonitor->VerifyFound(); | ||||
625 | |||||
626 | m_errorMonitor->SetDesiredFailureMsg( | ||||
627 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
628 | "required parameter pAllocateInfo specified as NULL"); | ||||
629 | // Specify NULL for a required struct pointer | ||||
630 | // Expected to trigger an error with | ||||
631 | // parameter_validation::validate_struct_type | ||||
632 | VkDeviceMemory memory = VK_NULL_HANDLE; | ||||
633 | vkAllocateMemory(device(), NULL, NULL, &memory); | ||||
634 | m_errorMonitor->VerifyFound(); | ||||
635 | |||||
636 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
637 | "value of faceMask must not be 0"); | ||||
638 | // Specify 0 for a required VkFlags parameter | ||||
639 | // Expected to trigger an error with parameter_validation::validate_flags | ||||
640 | m_commandBuffer->SetStencilReference(0, 0); | ||||
641 | m_errorMonitor->VerifyFound(); | ||||
642 | |||||
643 | m_errorMonitor->SetDesiredFailureMsg( | ||||
644 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
645 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); | ||||
646 | // Specify 0 for a required VkFlags array entry | ||||
647 | // Expected to trigger an error with | ||||
648 | // parameter_validation::validate_flags_array | ||||
649 | VkSemaphore semaphore = VK_NULL_HANDLE; | ||||
650 | VkPipelineStageFlags stageFlags = 0; | ||||
651 | VkSubmitInfo submitInfo = {}; | ||||
652 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
653 | submitInfo.waitSemaphoreCount = 1; | ||||
654 | submitInfo.pWaitSemaphores = &semaphore; | ||||
655 | submitInfo.pWaitDstStageMask = &stageFlags; | ||||
656 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); | ||||
657 | m_errorMonitor->VerifyFound(); | ||||
658 | } | ||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 659 | |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 660 | TEST_F(VkLayerTest, ReservedParameter) { |
661 | TEST_DESCRIPTION("Specify a non-zero value for a reserved parameter"); | ||||
662 | |||||
663 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
664 | |||||
665 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
666 | " must be 0"); | ||||
667 | // Specify 0 for a reserved VkFlags parameter | ||||
668 | // Expected to trigger an error with | ||||
669 | // parameter_validation::validate_reserved_flags | ||||
670 | VkEvent event_handle = VK_NULL_HANDLE; | ||||
671 | VkEventCreateInfo event_info = {}; | ||||
672 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
673 | event_info.flags = 1; | ||||
674 | vkCreateEvent(device(), &event_info, NULL, &event_handle); | ||||
675 | m_errorMonitor->VerifyFound(); | ||||
676 | } | ||||
677 | |||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 678 | TEST_F(VkLayerTest, InvalidStructSType) { |
679 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " | ||||
680 | "structure's sType field"); | ||||
681 | |||||
682 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
683 | |||||
684 | m_errorMonitor->SetDesiredFailureMsg( | ||||
685 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
686 | "parameter pAllocateInfo->sType must be"); | ||||
687 | // Zero struct memory, effectively setting sType to | ||||
688 | // VK_STRUCTURE_TYPE_APPLICATION_INFO | ||||
689 | // Expected to trigger an error with | ||||
690 | // parameter_validation::validate_struct_type | ||||
691 | VkMemoryAllocateInfo alloc_info = {}; | ||||
692 | VkDeviceMemory memory = VK_NULL_HANDLE; | ||||
693 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); | ||||
694 | m_errorMonitor->VerifyFound(); | ||||
695 | |||||
696 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
697 | "parameter pSubmits[0].sType must be"); | ||||
698 | // Zero struct memory, effectively setting sType to | ||||
699 | // VK_STRUCTURE_TYPE_APPLICATION_INFO | ||||
700 | // Expected to trigger an error with | ||||
701 | // parameter_validation::validate_struct_type_array | ||||
702 | VkSubmitInfo submit_info = {}; | ||||
703 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
704 | m_errorMonitor->VerifyFound(); | ||||
705 | } | ||||
706 | |||||
707 | TEST_F(VkLayerTest, InvalidStructPNext) { | ||||
708 | TEST_DESCRIPTION( | ||||
709 | "Specify an invalid value for a Vulkan structure's pNext field"); | ||||
710 | |||||
711 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
712 | |||||
713 | m_errorMonitor->SetDesiredFailureMsg( | ||||
714 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
715 | "value of pAllocateInfo->pNext must be NULL"); | ||||
716 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be | ||||
717 | // NULL | ||||
718 | // Expected to trigger an error with | ||||
719 | // parameter_validation::validate_struct_pnext | ||||
720 | VkDeviceMemory memory = VK_NULL_HANDLE; | ||||
721 | // Zero-initialization will provide the correct sType | ||||
722 | VkApplicationInfo app_info = {}; | ||||
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 723 | VkMemoryAllocateInfo memory_alloc_info = {}; |
724 | memory_alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
725 | memory_alloc_info.pNext = &app_info; | ||||
726 | vkAllocateMemory(device(), &memory_alloc_info, NULL, &memory); | ||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 727 | m_errorMonitor->VerifyFound(); |
728 | |||||
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 729 | m_errorMonitor->SetDesiredFailureMsg( |
730 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
731 | " chain includes a structure with unexpected VkStructureType "); | ||||
732 | // Set VkGraphicsPipelineCreateInfo::VkPipelineRasterizationStateCreateInfo::pNext to an invalid structure, when pNext is allowed to be a non-NULL value | ||||
733 | // Expected to trigger an error with | ||||
734 | // parameter_validation::validate_struct_pnext | ||||
735 | VkDescriptorPoolSize ds_type_count = {}; | ||||
736 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
737 | ds_type_count.descriptorCount = 1; | ||||
738 | |||||
739 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
740 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
741 | ds_pool_ci.pNext = NULL; | ||||
742 | ds_pool_ci.maxSets = 1; | ||||
743 | ds_pool_ci.poolSizeCount = 1; | ||||
744 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
745 | |||||
746 | VkDescriptorPool ds_pool; | ||||
747 | VkResult err = | ||||
748 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
749 | ASSERT_VK_SUCCESS(err); | ||||
750 | |||||
751 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
752 | dsl_binding.binding = 0; | ||||
753 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
754 | dsl_binding.descriptorCount = 1; | ||||
755 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
756 | dsl_binding.pImmutableSamplers = NULL; | ||||
757 | |||||
758 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
759 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
760 | ds_layout_ci.pNext = NULL; | ||||
761 | ds_layout_ci.bindingCount = 1; | ||||
762 | ds_layout_ci.pBindings = &dsl_binding; | ||||
763 | |||||
764 | VkDescriptorSetLayout ds_layout; | ||||
765 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
766 | &ds_layout); | ||||
767 | ASSERT_VK_SUCCESS(err); | ||||
768 | |||||
769 | VkDescriptorSet descriptorSet; | ||||
770 | VkDescriptorSetAllocateInfo ds_alloc_info = {}; | ||||
771 | ds_alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
772 | ds_alloc_info.descriptorSetCount = 1; | ||||
773 | ds_alloc_info.descriptorPool = ds_pool; | ||||
774 | ds_alloc_info.pSetLayouts = &ds_layout; | ||||
775 | err = vkAllocateDescriptorSets(m_device->device(), &ds_alloc_info, | ||||
776 | &descriptorSet); | ||||
777 | ASSERT_VK_SUCCESS(err); | ||||
778 | |||||
779 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
780 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
781 | pipeline_layout_ci.setLayoutCount = 1; | ||||
782 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
783 | |||||
784 | VkPipelineLayout pipeline_layout; | ||||
785 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
786 | &pipeline_layout); | ||||
787 | ASSERT_VK_SUCCESS(err); | ||||
788 | |||||
789 | VkViewport vp = {}; // Just need dummy vp to point to | ||||
790 | VkRect2D sc = {}; // dummy scissor to point to | ||||
791 | |||||
792 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
793 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; | ||||
794 | vp_state_ci.scissorCount = 1; | ||||
795 | vp_state_ci.pScissors = ≻ | ||||
796 | vp_state_ci.viewportCount = 1; | ||||
797 | vp_state_ci.pViewports = &vp; | ||||
798 | |||||
799 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; | ||||
800 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
801 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; | ||||
802 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; | ||||
803 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; | ||||
804 | rs_state_ci.depthClampEnable = VK_FALSE; | ||||
805 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; | ||||
806 | rs_state_ci.depthBiasEnable = VK_FALSE; | ||||
807 | |||||
808 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
809 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; | ||||
810 | gp_ci.pViewportState = &vp_state_ci; | ||||
811 | gp_ci.pRasterizationState = &rs_state_ci; | ||||
812 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
813 | gp_ci.layout = pipeline_layout; | ||||
814 | gp_ci.renderPass = renderPass(); | ||||
815 | |||||
816 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
817 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; | ||||
818 | pc_ci.initialDataSize = 0; | ||||
819 | pc_ci.pInitialData = 0; | ||||
820 | |||||
821 | VkPipeline pipeline; | ||||
822 | VkPipelineCache pipelineCache; | ||||
823 | |||||
824 | err = | ||||
825 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
826 | ASSERT_VK_SUCCESS(err); | ||||
827 | |||||
828 | // Set VkPipelineRasterizationStateCreateInfo::pNext to an invalid value | ||||
829 | VkApplicationInfo invalid_pnext_struct = {}; | ||||
830 | rs_state_ci.pNext = &invalid_pnext_struct; | ||||
831 | |||||
832 | vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
833 | &gp_ci, NULL, &pipeline); | ||||
834 | m_errorMonitor->VerifyFound(); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 835 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
836 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
837 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
838 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
839 | |||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 840 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame] | 841 | |
842 | TEST_F(VkLayerTest, UnrecognizedValue) { | ||||
843 | TEST_DESCRIPTION( | ||||
844 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); | ||||
845 | |||||
846 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
847 | |||||
848 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
849 | "does not fall within the begin..end " | ||||
850 | "range of the core VkFormat " | ||||
851 | "enumeration tokens"); | ||||
852 | // Specify an invalid VkFormat value | ||||
853 | // Expected to trigger an error with | ||||
854 | // parameter_validation::validate_ranged_enum | ||||
855 | VkFormatProperties format_properties; | ||||
856 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), | ||||
857 | &format_properties); | ||||
858 | m_errorMonitor->VerifyFound(); | ||||
859 | |||||
860 | m_errorMonitor->SetDesiredFailureMsg( | ||||
861 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
862 | "contains flag bits that are not recognized members of"); | ||||
863 | // Specify an invalid VkFlags bitmask value | ||||
864 | // Expected to trigger an error with parameter_validation::validate_flags | ||||
865 | VkImageFormatProperties image_format_properties; | ||||
866 | vkGetPhysicalDeviceImageFormatProperties( | ||||
867 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, | ||||
868 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, | ||||
869 | &image_format_properties); | ||||
870 | m_errorMonitor->VerifyFound(); | ||||
871 | |||||
872 | m_errorMonitor->SetDesiredFailureMsg( | ||||
873 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
874 | "contains flag bits that are not recognized members of"); | ||||
875 | // Specify an invalid VkFlags array entry | ||||
876 | // Expected to trigger an error with | ||||
877 | // parameter_validation::validate_flags_array | ||||
878 | VkSemaphore semaphore = VK_NULL_HANDLE; | ||||
879 | VkPipelineStageFlags stage_flags = | ||||
880 | static_cast<VkPipelineStageFlags>(1 << 25); | ||||
881 | VkSubmitInfo submit_info = {}; | ||||
882 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
883 | submit_info.waitSemaphoreCount = 1; | ||||
884 | submit_info.pWaitSemaphores = &semaphore; | ||||
885 | submit_info.pWaitDstStageMask = &stage_flags; | ||||
886 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
887 | m_errorMonitor->VerifyFound(); | ||||
888 | |||||
889 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, | ||||
890 | "is neither VK_TRUE nor VK_FALSE"); | ||||
891 | // Specify an invalid VkBool32 value | ||||
892 | // Expected to trigger a warning with | ||||
893 | // parameter_validation::validate_bool32 | ||||
894 | VkSampler sampler = VK_NULL_HANDLE; | ||||
895 | VkSamplerCreateInfo sampler_info = {}; | ||||
896 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; | ||||
897 | sampler_info.pNext = NULL; | ||||
898 | sampler_info.magFilter = VK_FILTER_NEAREST; | ||||
899 | sampler_info.minFilter = VK_FILTER_NEAREST; | ||||
900 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
901 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
902 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
903 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
904 | sampler_info.mipLodBias = 1.0; | ||||
905 | sampler_info.maxAnisotropy = 1; | ||||
906 | sampler_info.compareEnable = VK_FALSE; | ||||
907 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; | ||||
908 | sampler_info.minLod = 1.0; | ||||
909 | sampler_info.maxLod = 1.0; | ||||
910 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
911 | sampler_info.unnormalizedCoordinates = VK_FALSE; | ||||
912 | // Not VK_TRUE or VK_FALSE | ||||
913 | sampler_info.anisotropyEnable = 3; | ||||
914 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); | ||||
915 | m_errorMonitor->VerifyFound(); | ||||
916 | } | ||||
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 917 | |
918 | TEST_F(VkLayerTest, FailedReturnValue) { | ||||
919 | TEST_DESCRIPTION("Check for a message describing a VkResult failure code"); | ||||
920 | |||||
921 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
922 | |||||
Dustin Graves | 13c1e2b | 2016-05-16 15:31:02 -0600 | [diff] [blame] | 923 | // Find an unsupported image format |
924 | VkFormat unsupported = VK_FORMAT_UNDEFINED; | ||||
925 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { | ||||
926 | VkFormat format = static_cast<VkFormat>(f); | ||||
927 | VkFormatProperties fProps = m_device->format_properties(format); | ||||
928 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && | ||||
929 | fProps.optimalTilingFeatures == 0) { | ||||
930 | unsupported = format; | ||||
931 | break; | ||||
932 | } | ||||
933 | } | ||||
934 | |||||
935 | if (unsupported != VK_FORMAT_UNDEFINED) { | ||||
936 | m_errorMonitor->SetDesiredFailureMsg( | ||||
937 | VK_DEBUG_REPORT_WARNING_BIT_EXT, | ||||
938 | "the requested format is not supported on this device"); | ||||
939 | // Specify an unsupported VkFormat value to generate a | ||||
940 | // VK_ERROR_FORMAT_NOT_SUPPORTED return code | ||||
941 | // Expected to trigger a warning from | ||||
942 | // parameter_validation::validate_result | ||||
943 | VkImageFormatProperties image_format_properties; | ||||
944 | VkResult err = vkGetPhysicalDeviceImageFormatProperties( | ||||
945 | gpu(), unsupported, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, | ||||
946 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &image_format_properties); | ||||
947 | ASSERT_TRUE(err == VK_ERROR_FORMAT_NOT_SUPPORTED); | ||||
948 | m_errorMonitor->VerifyFound(); | ||||
949 | } | ||||
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 950 | } |
Mark Lobodzinski | e090fef | 2016-06-09 17:04:56 -0600 | [diff] [blame] | 951 | |
952 | TEST_F(VkLayerTest, UpdateBufferAlignment) { | ||||
953 | TEST_DESCRIPTION("Check alignment parameters for vkCmdUpdateBuffer"); | ||||
954 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; | ||||
955 | |||||
956 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
957 | |||||
958 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
959 | vk_testing::Buffer buffer; | ||||
960 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); | ||||
961 | |||||
962 | BeginCommandBuffer(); | ||||
963 | // Introduce failure by using dstOffset that is not multiple of 4 | ||||
964 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
965 | " is not a multiple of 4"); | ||||
966 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); | ||||
967 | m_errorMonitor->VerifyFound(); | ||||
968 | |||||
969 | // Introduce failure by using dataSize that is not multiple of 4 | ||||
970 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
971 | " is not a multiple of 4"); | ||||
972 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); | ||||
973 | m_errorMonitor->VerifyFound(); | ||||
974 | |||||
975 | // Introduce failure by using dataSize that is < 0 | ||||
976 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
977 | "must be greater than zero and less than or equal to 65536"); | ||||
978 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, -44, updateData); | ||||
979 | m_errorMonitor->VerifyFound(); | ||||
980 | |||||
981 | // Introduce failure by using dataSize that is > 65536 | ||||
982 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
983 | "must be greater than zero and less than or equal to 65536"); | ||||
984 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 80000, updateData); | ||||
985 | m_errorMonitor->VerifyFound(); | ||||
986 | |||||
987 | EndCommandBuffer(); | ||||
988 | } | ||||
989 | |||||
990 | TEST_F(VkLayerTest, FillBufferAlignment) { | ||||
991 | TEST_DESCRIPTION("Check alignment parameters for vkCmdFillBuffer"); | ||||
992 | |||||
993 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
994 | |||||
995 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
996 | vk_testing::Buffer buffer; | ||||
997 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); | ||||
998 | |||||
999 | BeginCommandBuffer(); | ||||
1000 | |||||
1001 | // Introduce failure by using dstOffset that is not multiple of 4 | ||||
1002 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1003 | " is not a multiple of 4"); | ||||
1004 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); | ||||
1005 | m_errorMonitor->VerifyFound(); | ||||
1006 | |||||
1007 | // Introduce failure by using size that is not multiple of 4 | ||||
1008 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1009 | " is not a multiple of 4"); | ||||
1010 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); | ||||
1011 | m_errorMonitor->VerifyFound(); | ||||
1012 | |||||
1013 | // Introduce failure by using size that is zero | ||||
1014 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1015 | "must be greater than zero"); | ||||
1016 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 0, 0x11111111); | ||||
1017 | m_errorMonitor->VerifyFound(); | ||||
1018 | |||||
1019 | EndCommandBuffer(); | ||||
1020 | } | ||||
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 1021 | #endif // PARAMETER_VALIDATION_TESTS |
1022 | |||||
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1023 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1024 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1025 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1026 | { |
1027 | vk_testing::Fence testFence; | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1028 | VkFenceCreateInfo fenceInfo = {}; |
1029 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
1030 | fenceInfo.pNext = NULL; | ||||
1031 | fenceInfo.flags = 0; | ||||
1032 | |||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1033 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1034 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1035 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 1036 | |
1037 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
1038 | vk_testing::Buffer buffer; | ||||
1039 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1040 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1041 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1042 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1043 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1044 | |
1045 | testFence.init(*m_device, fenceInfo); | ||||
1046 | |||||
1047 | // Bypass framework since it does the waits automatically | ||||
1048 | VkResult err = VK_SUCCESS; | ||||
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1049 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1050 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
1051 | submit_info.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1052 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1053 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1054 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1055 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1056 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1057 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1058 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1059 | |
1060 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1061 | ASSERT_VK_SUCCESS( err ); |
1062 | |||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1063 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1064 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1065 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1066 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1067 | } |
1068 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1069 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1070 | { |
1071 | vk_testing::Fence testFence; | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1072 | VkFenceCreateInfo fenceInfo = {}; |
1073 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
1074 | fenceInfo.pNext = NULL; | ||||
1075 | fenceInfo.flags = 0; | ||||
1076 | |||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1077 | 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] | 1078 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1079 | ASSERT_NO_FATAL_FAILURE(InitState()); |
1080 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
1081 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
1082 | |||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1083 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1084 | 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] | 1085 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1086 | |
1087 | testFence.init(*m_device, fenceInfo); | ||||
1088 | |||||
1089 | // Bypass framework since it does the waits automatically | ||||
1090 | VkResult err = VK_SUCCESS; | ||||
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1091 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1092 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
1093 | submit_info.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1094 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1095 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1096 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1097 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1098 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1099 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1100 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1101 | |
1102 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1103 | ASSERT_VK_SUCCESS( err ); |
1104 | |||||
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1105 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1106 | VkCommandBufferBeginInfo info = {}; |
1107 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; | ||||
1108 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1109 | info.renderPass = VK_NULL_HANDLE; |
1110 | info.subpass = 0; | ||||
1111 | info.framebuffer = VK_NULL_HANDLE; | ||||
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 1112 | info.occlusionQueryEnable = VK_FALSE; |
1113 | info.queryFlags = 0; | ||||
1114 | info.pipelineStatistics = 0; | ||||
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1115 | |
1116 | // Introduce failure by calling BCB again before checking fence | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1117 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1118 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1119 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1120 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1121 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1122 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1123 | // This is a positive test. No failures are expected. |
1124 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { | ||||
1125 | VkResult err; | ||||
1126 | bool pass; | ||||
1127 | |||||
1128 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " | ||||
1129 | "the buffer, create an image, and bind the same memory to " | ||||
1130 | "it"); | ||||
1131 | |||||
1132 | m_errorMonitor->ExpectSuccess(); | ||||
1133 | |||||
1134 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1135 | |||||
1136 | VkBuffer buffer; | ||||
1137 | VkImage image; | ||||
1138 | VkDeviceMemory mem; | ||||
1139 | VkMemoryRequirements mem_reqs; | ||||
1140 | |||||
1141 | VkBufferCreateInfo buf_info = {}; | ||||
1142 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
1143 | buf_info.pNext = NULL; | ||||
1144 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
1145 | buf_info.size = 256; | ||||
1146 | buf_info.queueFamilyIndexCount = 0; | ||||
1147 | buf_info.pQueueFamilyIndices = NULL; | ||||
1148 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1149 | buf_info.flags = 0; | ||||
1150 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); | ||||
1151 | ASSERT_VK_SUCCESS(err); | ||||
1152 | |||||
1153 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); | ||||
1154 | |||||
1155 | VkMemoryAllocateInfo alloc_info = {}; | ||||
1156 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1157 | alloc_info.pNext = NULL; | ||||
1158 | alloc_info.memoryTypeIndex = 0; | ||||
1159 | |||||
1160 | // Ensure memory is big enough for both bindings | ||||
1161 | alloc_info.allocationSize = 0x10000; | ||||
1162 | |||||
1163 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, | ||||
1164 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
1165 | if (!pass) { | ||||
1166 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1167 | return; | ||||
1168 | } | ||||
1169 | |||||
1170 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); | ||||
1171 | ASSERT_VK_SUCCESS(err); | ||||
1172 | |||||
1173 | uint8_t *pData; | ||||
1174 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, | ||||
1175 | (void **)&pData); | ||||
1176 | ASSERT_VK_SUCCESS(err); | ||||
1177 | |||||
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 1178 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1179 | |
1180 | vkUnmapMemory(m_device->device(), mem); | ||||
1181 | |||||
1182 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
1183 | ASSERT_VK_SUCCESS(err); | ||||
1184 | |||||
1185 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this | ||||
1186 | // memory. In fact, it was never used by the GPU. | ||||
1187 | // Just be be sure, wait for idle. | ||||
1188 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1189 | vkDeviceWaitIdle(m_device->device()); | ||||
1190 | |||||
1191 | VkImageCreateInfo image_create_info = {}; | ||||
1192 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
1193 | image_create_info.pNext = NULL; | ||||
1194 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
1195 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
1196 | image_create_info.extent.width = 64; | ||||
1197 | image_create_info.extent.height = 64; | ||||
1198 | image_create_info.extent.depth = 1; | ||||
1199 | image_create_info.mipLevels = 1; | ||||
1200 | image_create_info.arrayLayers = 1; | ||||
1201 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
1202 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
1203 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | ||||
1204 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
1205 | image_create_info.queueFamilyIndexCount = 0; | ||||
1206 | image_create_info.pQueueFamilyIndices = NULL; | ||||
1207 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1208 | image_create_info.flags = 0; | ||||
1209 | |||||
1210 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
1211 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1212 | mem_alloc.pNext = NULL; | ||||
1213 | mem_alloc.allocationSize = 0; | ||||
1214 | mem_alloc.memoryTypeIndex = 0; | ||||
1215 | |||||
1216 | /* Create a mappable image. It will be the texture if linear images are ok | ||||
1217 | * to be textures or it will be the staging image if they are not. | ||||
1218 | */ | ||||
1219 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
1220 | ASSERT_VK_SUCCESS(err); | ||||
1221 | |||||
1222 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
1223 | |||||
1224 | mem_alloc.allocationSize = mem_reqs.size; | ||||
1225 | |||||
1226 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, | ||||
1227 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
1228 | if (!pass) { | ||||
1229 | vkDestroyImage(m_device->device(), image, NULL); | ||||
1230 | return; | ||||
1231 | } | ||||
1232 | |||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1233 | // VALIDATION FAILURE: |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1234 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
1235 | ASSERT_VK_SUCCESS(err); | ||||
1236 | |||||
1237 | m_errorMonitor->VerifyNotFound(); | ||||
1238 | |||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 1239 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1240 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
1241 | vkDestroyImage(m_device->device(), image, NULL); | ||||
1242 | } | ||||
1243 | |||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1244 | TEST_F(VkLayerTest, InvalidMemoryAliasing) { |
1245 | TEST_DESCRIPTION("Create a buffer and image, allocate memory, and bind the " | ||||
1246 | "buffer and image to memory such that they will alias."); | ||||
1247 | VkResult err; | ||||
1248 | bool pass; | ||||
1249 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1250 | |||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1251 | VkBuffer buffer, buffer2; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1252 | VkImage image; |
1253 | VkDeviceMemory mem; // buffer will be bound first | ||||
1254 | VkDeviceMemory mem_img; // image bound first | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1255 | VkMemoryRequirements buff_mem_reqs, img_mem_reqs; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1256 | |
1257 | VkBufferCreateInfo buf_info = {}; | ||||
1258 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
1259 | buf_info.pNext = NULL; | ||||
1260 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
1261 | buf_info.size = 256; | ||||
1262 | buf_info.queueFamilyIndexCount = 0; | ||||
1263 | buf_info.pQueueFamilyIndices = NULL; | ||||
1264 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1265 | buf_info.flags = 0; | ||||
1266 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); | ||||
1267 | ASSERT_VK_SUCCESS(err); | ||||
1268 | |||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1269 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &buff_mem_reqs); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1270 | |
1271 | VkImageCreateInfo image_create_info = {}; | ||||
1272 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
1273 | image_create_info.pNext = NULL; | ||||
1274 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
1275 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
1276 | image_create_info.extent.width = 64; | ||||
1277 | image_create_info.extent.height = 64; | ||||
1278 | image_create_info.extent.depth = 1; | ||||
1279 | image_create_info.mipLevels = 1; | ||||
1280 | image_create_info.arrayLayers = 1; | ||||
1281 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
1282 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
1283 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | ||||
1284 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
1285 | image_create_info.queueFamilyIndexCount = 0; | ||||
1286 | image_create_info.pQueueFamilyIndices = NULL; | ||||
1287 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1288 | image_create_info.flags = 0; | ||||
1289 | |||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1290 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
1291 | ASSERT_VK_SUCCESS(err); | ||||
1292 | |||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1293 | vkGetImageMemoryRequirements(m_device->device(), image, &img_mem_reqs); |
1294 | |||||
1295 | VkMemoryAllocateInfo alloc_info = {}; | ||||
1296 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1297 | alloc_info.pNext = NULL; | ||||
1298 | alloc_info.memoryTypeIndex = 0; | ||||
1299 | // Ensure memory is big enough for both bindings | ||||
1300 | alloc_info.allocationSize = buff_mem_reqs.size + img_mem_reqs.size; | ||||
1301 | pass = m_device->phy().set_memory_type( | ||||
1302 | buff_mem_reqs.memoryTypeBits | img_mem_reqs.memoryTypeBits, &alloc_info, | ||||
1303 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1304 | if (!pass) { |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1305 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1306 | vkDestroyImage(m_device->device(), image, NULL); |
1307 | return; | ||||
1308 | } | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1309 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
1310 | ASSERT_VK_SUCCESS(err); | ||||
1311 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
1312 | ASSERT_VK_SUCCESS(err); | ||||
1313 | |||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1314 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
1315 | " is aliased with buffer 0x"); | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1316 | // VALIDATION FAILURE due to image mapping overlapping buffer mapping |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1317 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
1318 | m_errorMonitor->VerifyFound(); | ||||
1319 | |||||
1320 | // Now correctly bind image to second mem allocation before incorrectly | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1321 | // aliasing buffer2 |
1322 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer2); | ||||
1323 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1324 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem_img); |
1325 | ASSERT_VK_SUCCESS(err); | ||||
1326 | err = vkBindImageMemory(m_device->device(), image, mem_img, 0); | ||||
1327 | ASSERT_VK_SUCCESS(err); | ||||
1328 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1329 | " is aliased with image 0x"); | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1330 | err = vkBindBufferMemory(m_device->device(), buffer2, mem_img, 0); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1331 | m_errorMonitor->VerifyFound(); |
1332 | |||||
1333 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1334 | vkDestroyBuffer(m_device->device(), buffer2, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1335 | vkDestroyImage(m_device->device(), image, NULL); |
1336 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
1337 | vkFreeMemory(m_device->device(), mem_img, NULL); | ||||
1338 | } | ||||
1339 | |||||
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 1340 | TEST_F(VkLayerTest, InvalidMemoryMapping) { |
1341 | TEST_DESCRIPTION("Attempt to map memory in a number of incorrect ways"); | ||||
1342 | VkResult err; | ||||
1343 | bool pass; | ||||
1344 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1345 | |||||
1346 | VkBuffer buffer; | ||||
1347 | VkDeviceMemory mem; | ||||
1348 | VkMemoryRequirements mem_reqs; | ||||
1349 | |||||
1350 | VkBufferCreateInfo buf_info = {}; | ||||
1351 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
1352 | buf_info.pNext = NULL; | ||||
1353 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
1354 | buf_info.size = 256; | ||||
1355 | buf_info.queueFamilyIndexCount = 0; | ||||
1356 | buf_info.pQueueFamilyIndices = NULL; | ||||
1357 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1358 | buf_info.flags = 0; | ||||
1359 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); | ||||
1360 | ASSERT_VK_SUCCESS(err); | ||||
1361 | |||||
1362 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); | ||||
1363 | VkMemoryAllocateInfo alloc_info = {}; | ||||
1364 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1365 | alloc_info.pNext = NULL; | ||||
1366 | alloc_info.memoryTypeIndex = 0; | ||||
1367 | |||||
1368 | // Ensure memory is big enough for both bindings | ||||
1369 | static const VkDeviceSize allocation_size = 0x10000; | ||||
1370 | alloc_info.allocationSize = allocation_size; | ||||
1371 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, | ||||
1372 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
1373 | if (!pass) { | ||||
1374 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1375 | return; | ||||
1376 | } | ||||
1377 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); | ||||
1378 | ASSERT_VK_SUCCESS(err); | ||||
1379 | |||||
1380 | uint8_t *pData; | ||||
1381 | // Attempt to map memory size 0 is invalid | ||||
1382 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1383 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1384 | "VkMapMemory: Attempting to map memory range of size zero"); | ||||
1385 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, (void **)&pData); | ||||
1386 | m_errorMonitor->VerifyFound(); | ||||
1387 | // Map memory twice | ||||
1388 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, | ||||
1389 | (void **)&pData); | ||||
1390 | ASSERT_VK_SUCCESS(err); | ||||
1391 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1392 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1393 | "VkMapMemory: Attempting to map memory on an already-mapped object "); | ||||
1394 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, | ||||
1395 | (void **)&pData); | ||||
1396 | m_errorMonitor->VerifyFound(); | ||||
1397 | |||||
1398 | // Unmap the memory to avoid re-map error | ||||
1399 | vkUnmapMemory(m_device->device(), mem); | ||||
1400 | // overstep allocation with VK_WHOLE_SIZE | ||||
1401 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1402 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1403 | " with size of VK_WHOLE_SIZE oversteps total array size 0x"); | ||||
1404 | err = vkMapMemory(m_device->device(), mem, allocation_size + 1, | ||||
1405 | VK_WHOLE_SIZE, 0, (void **)&pData); | ||||
1406 | m_errorMonitor->VerifyFound(); | ||||
1407 | // overstep allocation w/o VK_WHOLE_SIZE | ||||
1408 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1409 | " oversteps total array size 0x"); | ||||
1410 | err = vkMapMemory(m_device->device(), mem, 1, allocation_size, 0, | ||||
1411 | (void **)&pData); | ||||
1412 | m_errorMonitor->VerifyFound(); | ||||
1413 | // Now error due to unmapping memory that's not mapped | ||||
1414 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1415 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1416 | "Unmapping Memory without memory being mapped: "); | ||||
1417 | vkUnmapMemory(m_device->device(), mem); | ||||
1418 | m_errorMonitor->VerifyFound(); | ||||
1419 | // Now map memory and cause errors due to flushing invalid ranges | ||||
1420 | err = vkMapMemory(m_device->device(), mem, 16, VK_WHOLE_SIZE, 0, | ||||
1421 | (void **)&pData); | ||||
1422 | ASSERT_VK_SUCCESS(err); | ||||
1423 | VkMappedMemoryRange mmr = {}; | ||||
1424 | mmr.memory = mem; | ||||
1425 | mmr.offset = 15; // Error b/c offset less than offset of mapped mem | ||||
1426 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1427 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1428 | ") is less than Memory Object's offset ("); | ||||
1429 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); | ||||
1430 | m_errorMonitor->VerifyFound(); | ||||
1431 | // Now flush range that oversteps mapped range | ||||
1432 | vkUnmapMemory(m_device->device(), mem); | ||||
1433 | err = vkMapMemory(m_device->device(), mem, 0, 256, 0, (void **)&pData); | ||||
1434 | ASSERT_VK_SUCCESS(err); | ||||
1435 | mmr.offset = 16; | ||||
1436 | mmr.size = 256; // flushing bounds (272) exceed mapped bounds (256) | ||||
1437 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1438 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1439 | ") exceeds the Memory Object's upper-bound ("); | ||||
1440 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); | ||||
1441 | m_errorMonitor->VerifyFound(); | ||||
1442 | |||||
1443 | pass = | ||||
1444 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, | ||||
1445 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, | ||||
1446 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); | ||||
1447 | if (!pass) { | ||||
1448 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
1449 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1450 | return; | ||||
1451 | } | ||||
1452 | // TODO : If we can get HOST_VISIBLE w/o HOST_COHERENT we can test cases of | ||||
1453 | // MEMTRACK_INVALID_MAP in validateAndCopyNoncoherentMemoryToDriver() | ||||
1454 | |||||
1455 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1456 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
1457 | } | ||||
1458 | |||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1459 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
1460 | VkResult err; | ||||
1461 | bool pass; | ||||
1462 | |||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1463 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
1464 | // following declaration (which is temporarily being moved below): | ||||
1465 | // VkSurfaceKHR surface = VK_NULL_HANDLE; | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1466 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
1467 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; | ||||
1468 | uint32_t swapchain_image_count = 0; | ||||
1469 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; | ||||
1470 | uint32_t image_index = 0; | ||||
1471 | // VkPresentInfoKHR present_info = {}; | ||||
1472 | |||||
1473 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1474 | |||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1475 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
1476 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) | ||||
1477 | // Use the functions from the VK_KHR_android_surface extension without | ||||
1478 | // enabling that extension: | ||||
1479 | |||||
1480 | // Create a surface: | ||||
1481 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1482 | m_errorMonitor->SetDesiredFailureMsg( |
1483 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1484 | "extension was not enabled for this"); | ||||
1485 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, | ||||
1486 | &surface); | ||||
1487 | pass = (err != VK_SUCCESS); | ||||
1488 | ASSERT_TRUE(pass); | ||||
1489 | m_errorMonitor->VerifyFound(); | ||||
1490 | #endif // VK_USE_PLATFORM_ANDROID_KHR | ||||
1491 | |||||
1492 | |||||
1493 | #if defined(VK_USE_PLATFORM_MIR_KHR) | ||||
1494 | // Use the functions from the VK_KHR_mir_surface extension without enabling | ||||
1495 | // that extension: | ||||
1496 | |||||
1497 | // Create a surface: | ||||
1498 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1499 | m_errorMonitor->SetDesiredFailureMsg( |
1500 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1501 | "extension was not enabled for this"); | ||||
1502 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); | ||||
1503 | pass = (err != VK_SUCCESS); | ||||
1504 | ASSERT_TRUE(pass); | ||||
1505 | m_errorMonitor->VerifyFound(); | ||||
1506 | |||||
1507 | // Tell whether an mir_connection supports presentation: | ||||
1508 | MirConnection *mir_connection = NULL; | ||||
1509 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1510 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1511 | "extension was not enabled for this"); | ||||
1512 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, | ||||
1513 | visual_id); | ||||
1514 | m_errorMonitor->VerifyFound(); | ||||
1515 | #endif // VK_USE_PLATFORM_MIR_KHR | ||||
1516 | |||||
1517 | |||||
1518 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) | ||||
1519 | // Use the functions from the VK_KHR_wayland_surface extension without | ||||
1520 | // enabling that extension: | ||||
1521 | |||||
1522 | // Create a surface: | ||||
1523 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1524 | m_errorMonitor->SetDesiredFailureMsg( |
1525 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1526 | "extension was not enabled for this"); | ||||
1527 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, | ||||
1528 | &surface); | ||||
1529 | pass = (err != VK_SUCCESS); | ||||
1530 | ASSERT_TRUE(pass); | ||||
1531 | m_errorMonitor->VerifyFound(); | ||||
1532 | |||||
1533 | // Tell whether an wayland_display supports presentation: | ||||
1534 | struct wl_display wayland_display = {}; | ||||
1535 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1536 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1537 | "extension was not enabled for this"); | ||||
1538 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, | ||||
1539 | &wayland_display); | ||||
1540 | m_errorMonitor->VerifyFound(); | ||||
1541 | #endif // VK_USE_PLATFORM_WAYLAND_KHR | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1542 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1543 | |
1544 | |||||
1545 | #if defined(VK_USE_PLATFORM_WIN32_KHR) | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1546 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
1547 | // TO NON-LINUX PLATFORMS: | ||||
1548 | VkSurfaceKHR surface = VK_NULL_HANDLE; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1549 | // Use the functions from the VK_KHR_win32_surface extension without |
1550 | // enabling that extension: | ||||
1551 | |||||
1552 | // Create a surface: | ||||
1553 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1554 | m_errorMonitor->SetDesiredFailureMsg( |
1555 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1556 | "extension was not enabled for this"); | ||||
1557 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, | ||||
1558 | &surface); | ||||
1559 | pass = (err != VK_SUCCESS); | ||||
1560 | ASSERT_TRUE(pass); | ||||
1561 | m_errorMonitor->VerifyFound(); | ||||
1562 | |||||
1563 | // Tell whether win32 supports presentation: | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1564 | m_errorMonitor->SetDesiredFailureMsg( |
1565 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1566 | "extension was not enabled for this"); | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1567 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1568 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1569 | // Set this (for now, until all platforms are supported and tested): |
1570 | #define NEED_TO_TEST_THIS_ON_PLATFORM | ||||
1571 | #endif // VK_USE_PLATFORM_WIN32_KHR | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1572 | |
1573 | |||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1574 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1575 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
1576 | // TO NON-LINUX PLATFORMS: | ||||
1577 | VkSurfaceKHR surface = VK_NULL_HANDLE; | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1578 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
1579 | // that extension: | ||||
1580 | |||||
1581 | // Create a surface: | ||||
1582 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1583 | m_errorMonitor->SetDesiredFailureMsg( |
1584 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1585 | "extension was not enabled for this"); | ||||
1586 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); | ||||
1587 | pass = (err != VK_SUCCESS); | ||||
1588 | ASSERT_TRUE(pass); | ||||
1589 | m_errorMonitor->VerifyFound(); | ||||
1590 | |||||
1591 | // Tell whether an xcb_visualid_t supports presentation: | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1592 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1593 | xcb_visualid_t visual_id = 0; |
1594 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1595 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1596 | "extension was not enabled for this"); | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1597 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1598 | visual_id); |
1599 | m_errorMonitor->VerifyFound(); | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1600 | // Set this (for now, until all platforms are supported and tested): |
1601 | #define NEED_TO_TEST_THIS_ON_PLATFORM | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1602 | #endif // VK_USE_PLATFORM_XCB_KHR |
1603 | |||||
1604 | |||||
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1605 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
1606 | // Use the functions from the VK_KHR_xlib_surface extension without enabling | ||||
1607 | // that extension: | ||||
1608 | |||||
1609 | // Create a surface: | ||||
1610 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; | ||||
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1611 | m_errorMonitor->SetDesiredFailureMsg( |
1612 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1613 | "extension was not enabled for this"); | ||||
1614 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); | ||||
1615 | pass = (err != VK_SUCCESS); | ||||
1616 | ASSERT_TRUE(pass); | ||||
1617 | m_errorMonitor->VerifyFound(); | ||||
1618 | |||||
1619 | // Tell whether an Xlib VisualID supports presentation: | ||||
1620 | Display *dpy = NULL; | ||||
1621 | VisualID visual = 0; | ||||
1622 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1623 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1624 | "extension was not enabled for this"); | ||||
1625 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); | ||||
1626 | m_errorMonitor->VerifyFound(); | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1627 | // Set this (for now, until all platforms are supported and tested): |
1628 | #define NEED_TO_TEST_THIS_ON_PLATFORM | ||||
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1629 | #endif // VK_USE_PLATFORM_XLIB_KHR |
1630 | |||||
1631 | |||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1632 | // Use the functions from the VK_KHR_surface extension without enabling |
1633 | // that extension: | ||||
1634 | |||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1635 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1636 | // Destroy a surface: |
1637 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1638 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1639 | "extension was not enabled for this"); | ||||
1640 | vkDestroySurfaceKHR(instance(), surface, NULL); | ||||
1641 | m_errorMonitor->VerifyFound(); | ||||
1642 | |||||
1643 | // Check if surface supports presentation: | ||||
1644 | VkBool32 supported = false; | ||||
1645 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1646 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1647 | "extension was not enabled for this"); | ||||
1648 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); | ||||
1649 | pass = (err != VK_SUCCESS); | ||||
1650 | ASSERT_TRUE(pass); | ||||
1651 | m_errorMonitor->VerifyFound(); | ||||
1652 | |||||
1653 | // Check surface capabilities: | ||||
1654 | VkSurfaceCapabilitiesKHR capabilities = {}; | ||||
1655 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1656 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1657 | "extension was not enabled for this"); | ||||
1658 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, | ||||
1659 | &capabilities); | ||||
1660 | pass = (err != VK_SUCCESS); | ||||
1661 | ASSERT_TRUE(pass); | ||||
1662 | m_errorMonitor->VerifyFound(); | ||||
1663 | |||||
1664 | // Check surface formats: | ||||
1665 | uint32_t format_count = 0; | ||||
1666 | VkSurfaceFormatKHR *formats = NULL; | ||||
1667 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1668 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1669 | "extension was not enabled for this"); | ||||
1670 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, | ||||
1671 | &format_count, formats); | ||||
1672 | pass = (err != VK_SUCCESS); | ||||
1673 | ASSERT_TRUE(pass); | ||||
1674 | m_errorMonitor->VerifyFound(); | ||||
1675 | |||||
1676 | // Check surface present modes: | ||||
1677 | uint32_t present_mode_count = 0; | ||||
1678 | VkSurfaceFormatKHR *present_modes = NULL; | ||||
1679 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1680 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1681 | "extension was not enabled for this"); | ||||
1682 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, | ||||
1683 | &present_mode_count, present_modes); | ||||
1684 | pass = (err != VK_SUCCESS); | ||||
1685 | ASSERT_TRUE(pass); | ||||
1686 | m_errorMonitor->VerifyFound(); | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1687 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1688 | |
1689 | |||||
1690 | // Use the functions from the VK_KHR_swapchain extension without enabling | ||||
1691 | // that extension: | ||||
1692 | |||||
1693 | // Create a swapchain: | ||||
1694 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1695 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1696 | "extension was not enabled for this"); | ||||
1697 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; | ||||
1698 | swapchain_create_info.pNext = NULL; | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1699 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
1700 | NULL, &swapchain); | ||||
1701 | pass = (err != VK_SUCCESS); | ||||
1702 | ASSERT_TRUE(pass); | ||||
1703 | m_errorMonitor->VerifyFound(); | ||||
1704 | |||||
1705 | // Get the images from the swapchain: | ||||
1706 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1707 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1708 | "extension was not enabled for this"); | ||||
1709 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, | ||||
1710 | &swapchain_image_count, NULL); | ||||
1711 | pass = (err != VK_SUCCESS); | ||||
1712 | ASSERT_TRUE(pass); | ||||
1713 | m_errorMonitor->VerifyFound(); | ||||
1714 | |||||
1715 | // Try to acquire an image: | ||||
1716 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1717 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1718 | "extension was not enabled for this"); | ||||
1719 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, | ||||
1720 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); | ||||
1721 | pass = (err != VK_SUCCESS); | ||||
1722 | ASSERT_TRUE(pass); | ||||
1723 | m_errorMonitor->VerifyFound(); | ||||
1724 | |||||
1725 | // Try to present an image: | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1726 | // |
1727 | // NOTE: Currently can't test this because a real swapchain is needed (as | ||||
1728 | // opposed to the fake one we created) in order for the layer to lookup the | ||||
1729 | // VkDevice used to enable the extension: | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1730 | |
1731 | // Destroy the swapchain: | ||||
1732 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1733 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1734 | "extension was not enabled for this"); | ||||
1735 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); | ||||
1736 | m_errorMonitor->VerifyFound(); | ||||
1737 | } | ||||
1738 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1739 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1740 | |
Dustin Graves | 6c6d898 | 2016-05-17 10:09:21 -0600 | [diff] [blame] | 1741 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1742 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1743 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1744 | VkResult err; |
1745 | bool pass; | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1746 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
1747 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1748 | // uint32_t swapchain_image_count = 0; |
1749 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; | ||||
1750 | // uint32_t image_index = 0; | ||||
1751 | // VkPresentInfoKHR present_info = {}; | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1752 | |
1753 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1754 | |||||
1755 | // Use the create function from one of the VK_KHR_*_surface extension in | ||||
1756 | // order to create a surface, testing all known errors in the process, | ||||
1757 | // before successfully creating a surface: | ||||
1758 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1759 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
1760 | "called with NULL pointer"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1761 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
1762 | pass = (err != VK_SUCCESS); | ||||
1763 | ASSERT_TRUE(pass); | ||||
1764 | m_errorMonitor->VerifyFound(); | ||||
1765 | |||||
1766 | // Next, try to create a surface with the wrong | ||||
1767 | // VkXcbSurfaceCreateInfoKHR::sType: | ||||
1768 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; | ||||
1769 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1770 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
1771 | "called with the wrong value for"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1772 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
1773 | pass = (err != VK_SUCCESS); | ||||
1774 | ASSERT_TRUE(pass); | ||||
1775 | m_errorMonitor->VerifyFound(); | ||||
1776 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1777 | // Create a native window, and then correctly create a surface: |
1778 | xcb_connection_t *connection; | ||||
1779 | xcb_screen_t *screen; | ||||
1780 | xcb_window_t xcb_window; | ||||
1781 | xcb_intern_atom_reply_t *atom_wm_delete_window; | ||||
1782 | |||||
1783 | const xcb_setup_t *setup; | ||||
1784 | xcb_screen_iterator_t iter; | ||||
1785 | int scr; | ||||
1786 | uint32_t value_mask, value_list[32]; | ||||
1787 | int width = 1; | ||||
1788 | int height = 1; | ||||
1789 | |||||
1790 | connection = xcb_connect(NULL, &scr); | ||||
1791 | ASSERT_TRUE(connection != NULL); | ||||
1792 | setup = xcb_get_setup(connection); | ||||
1793 | iter = xcb_setup_roots_iterator(setup); | ||||
1794 | while (scr-- > 0) | ||||
1795 | xcb_screen_next(&iter); | ||||
1796 | screen = iter.data; | ||||
1797 | |||||
1798 | xcb_window = xcb_generate_id(connection); | ||||
1799 | |||||
1800 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; | ||||
1801 | value_list[0] = screen->black_pixel; | ||||
1802 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | | ||||
1803 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; | ||||
1804 | |||||
1805 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, | ||||
1806 | screen->root, 0, 0, width, height, 0, | ||||
1807 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, | ||||
1808 | value_mask, value_list); | ||||
1809 | |||||
1810 | /* Magic code that will send notification when window is destroyed */ | ||||
1811 | xcb_intern_atom_cookie_t cookie = | ||||
1812 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); | ||||
1813 | xcb_intern_atom_reply_t *reply = | ||||
1814 | xcb_intern_atom_reply(connection, cookie, 0); | ||||
1815 | |||||
1816 | xcb_intern_atom_cookie_t cookie2 = | ||||
1817 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1818 | atom_wm_delete_window = xcb_intern_atom_reply(connection, cookie2, 0); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1819 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
1820 | (*reply).atom, 4, 32, 1, | ||||
1821 | &(*atom_wm_delete_window).atom); | ||||
1822 | free(reply); | ||||
1823 | |||||
1824 | xcb_map_window(connection, xcb_window); | ||||
1825 | |||||
1826 | // Force the x/y coordinates to 100,100 results are identical in consecutive | ||||
1827 | // runs | ||||
1828 | const uint32_t coords[] = {100, 100}; | ||||
1829 | xcb_configure_window(connection, xcb_window, | ||||
1830 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); | ||||
1831 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1832 | // Finally, try to correctly create a surface: |
1833 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; | ||||
1834 | xcb_create_info.pNext = NULL; | ||||
1835 | xcb_create_info.flags = 0; | ||||
1836 | xcb_create_info.connection = connection; | ||||
1837 | xcb_create_info.window = xcb_window; | ||||
1838 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); | ||||
1839 | pass = (err == VK_SUCCESS); | ||||
1840 | ASSERT_TRUE(pass); | ||||
1841 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1842 | // Check if surface supports presentation: |
1843 | |||||
1844 | // 1st, do so without having queried the queue families: | ||||
1845 | VkBool32 supported = false; | ||||
1846 | // TODO: Get the following error to come out: | ||||
1847 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1848 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1849 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " | ||||
1850 | "function"); | ||||
1851 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); | ||||
1852 | pass = (err != VK_SUCCESS); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1853 | // ASSERT_TRUE(pass); |
1854 | // m_errorMonitor->VerifyFound(); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1855 | |
1856 | // Next, query a queue family index that's too large: | ||||
1857 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1858 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1859 | "called with a queueFamilyIndex that is too large"); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1860 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, |
1861 | &supported); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1862 | pass = (err != VK_SUCCESS); |
1863 | ASSERT_TRUE(pass); | ||||
1864 | m_errorMonitor->VerifyFound(); | ||||
1865 | |||||
1866 | // Finally, do so correctly: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1867 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
1868 | // SUPPORTED | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1869 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
1870 | pass = (err == VK_SUCCESS); | ||||
1871 | ASSERT_TRUE(pass); | ||||
1872 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1873 | // Before proceeding, try to create a swapchain without having called |
1874 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): | ||||
1875 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; | ||||
1876 | swapchain_create_info.pNext = NULL; | ||||
1877 | swapchain_create_info.flags = 0; | ||||
1878 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1879 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1880 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1881 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
1882 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1883 | pass = (err != VK_SUCCESS); |
1884 | ASSERT_TRUE(pass); | ||||
1885 | m_errorMonitor->VerifyFound(); | ||||
1886 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1887 | // Get the surface capabilities: |
1888 | VkSurfaceCapabilitiesKHR surface_capabilities; | ||||
1889 | |||||
1890 | // Do so correctly (only error logged by this entrypoint is if the | ||||
1891 | // extension isn't enabled): | ||||
1892 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, | ||||
1893 | &surface_capabilities); | ||||
1894 | pass = (err == VK_SUCCESS); | ||||
1895 | ASSERT_TRUE(pass); | ||||
1896 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1897 | // Get the surface formats: |
1898 | uint32_t surface_format_count; | ||||
1899 | |||||
1900 | // First, try without a pointer to surface_format_count: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1901 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
1902 | "called with NULL pointer"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1903 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
1904 | pass = (err == VK_SUCCESS); | ||||
1905 | ASSERT_TRUE(pass); | ||||
1906 | m_errorMonitor->VerifyFound(); | ||||
1907 | |||||
1908 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't | ||||
1909 | // correctly done a 1st try (to get the count): | ||||
1910 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1911 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1912 | "but no prior positive value has been seen for"); | ||||
1913 | surface_format_count = 0; | ||||
1914 | vkGetPhysicalDeviceSurfaceFormatsKHR( | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1915 | gpu(), surface, &surface_format_count, |
1916 | (VkSurfaceFormatKHR *)&surface_format_count); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1917 | pass = (err == VK_SUCCESS); |
1918 | ASSERT_TRUE(pass); | ||||
1919 | m_errorMonitor->VerifyFound(); | ||||
1920 | |||||
1921 | // 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] | 1922 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
1923 | NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1924 | pass = (err == VK_SUCCESS); |
1925 | ASSERT_TRUE(pass); | ||||
1926 | |||||
1927 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1928 | VkSurfaceFormatKHR *surface_formats = (VkSurfaceFormatKHR *)malloc( |
1929 | surface_format_count * sizeof(VkSurfaceFormatKHR)); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1930 | |
1931 | // Next, do a 2nd try with surface_format_count being set too high: | ||||
1932 | surface_format_count += 5; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1933 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
1934 | "that is greater than the value"); | ||||
1935 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1936 | surface_formats); |
1937 | pass = (err == VK_SUCCESS); | ||||
1938 | ASSERT_TRUE(pass); | ||||
1939 | m_errorMonitor->VerifyFound(); | ||||
1940 | |||||
1941 | // Finally, do a correct 1st and 2nd try: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1942 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
1943 | NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1944 | pass = (err == VK_SUCCESS); |
1945 | ASSERT_TRUE(pass); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1946 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1947 | surface_formats); |
1948 | pass = (err == VK_SUCCESS); | ||||
1949 | ASSERT_TRUE(pass); | ||||
1950 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1951 | // Get the surface present modes: |
1952 | uint32_t surface_present_mode_count; | ||||
1953 | |||||
1954 | // First, try without a pointer to surface_format_count: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1955 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
1956 | "called with NULL pointer"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1957 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
1958 | pass = (err == VK_SUCCESS); | ||||
1959 | ASSERT_TRUE(pass); | ||||
1960 | m_errorMonitor->VerifyFound(); | ||||
1961 | |||||
1962 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't | ||||
1963 | // correctly done a 1st try (to get the count): | ||||
1964 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1965 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1966 | "but no prior positive value has been seen for"); | ||||
1967 | surface_present_mode_count = 0; | ||||
1968 | vkGetPhysicalDeviceSurfacePresentModesKHR( | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1969 | gpu(), surface, &surface_present_mode_count, |
1970 | (VkPresentModeKHR *)&surface_present_mode_count); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1971 | pass = (err == VK_SUCCESS); |
1972 | ASSERT_TRUE(pass); | ||||
1973 | m_errorMonitor->VerifyFound(); | ||||
1974 | |||||
1975 | // 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] | 1976 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
1977 | gpu(), surface, &surface_present_mode_count, NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1978 | pass = (err == VK_SUCCESS); |
1979 | ASSERT_TRUE(pass); | ||||
1980 | |||||
1981 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1982 | VkPresentModeKHR *surface_present_modes = (VkPresentModeKHR *)malloc( |
1983 | surface_present_mode_count * sizeof(VkPresentModeKHR)); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1984 | |
1985 | // Next, do a 2nd try with surface_format_count being set too high: | ||||
1986 | surface_present_mode_count += 5; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1987 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
1988 | "that is greater than the value"); | ||||
1989 | vkGetPhysicalDeviceSurfacePresentModesKHR( | ||||
1990 | gpu(), surface, &surface_present_mode_count, surface_present_modes); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1991 | pass = (err == VK_SUCCESS); |
1992 | ASSERT_TRUE(pass); | ||||
1993 | m_errorMonitor->VerifyFound(); | ||||
1994 | |||||
1995 | // Finally, do a correct 1st and 2nd try: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1996 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
1997 | gpu(), surface, &surface_present_mode_count, NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1998 | pass = (err == VK_SUCCESS); |
1999 | ASSERT_TRUE(pass); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2000 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
2001 | gpu(), surface, &surface_present_mode_count, surface_present_modes); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2002 | pass = (err == VK_SUCCESS); |
2003 | ASSERT_TRUE(pass); | ||||
2004 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2005 | // Create a swapchain: |
2006 | |||||
2007 | // First, try without a pointer to swapchain_create_info: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2008 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2009 | "called with NULL pointer"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2010 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
2011 | pass = (err != VK_SUCCESS); | ||||
2012 | ASSERT_TRUE(pass); | ||||
2013 | m_errorMonitor->VerifyFound(); | ||||
2014 | |||||
2015 | // Next, call with a non-NULL swapchain_create_info, that has the wrong | ||||
2016 | // sType: | ||||
2017 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2018 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2019 | "called with the wrong value for"); | ||||
2020 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, | ||||
2021 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2022 | pass = (err != VK_SUCCESS); |
2023 | ASSERT_TRUE(pass); | ||||
2024 | m_errorMonitor->VerifyFound(); | ||||
2025 | |||||
2026 | // Next, call with a NULL swapchain pointer: | ||||
2027 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; | ||||
2028 | swapchain_create_info.pNext = NULL; | ||||
2029 | swapchain_create_info.flags = 0; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2030 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2031 | "called with NULL pointer"); | ||||
2032 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, | ||||
2033 | NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2034 | pass = (err != VK_SUCCESS); |
2035 | ASSERT_TRUE(pass); | ||||
2036 | m_errorMonitor->VerifyFound(); | ||||
2037 | |||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2038 | // TODO: Enhance swapchain layer so that |
2039 | // swapchain_create_info.queueFamilyIndexCount is checked against something? | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2040 | |
2041 | // Next, call with a queue family index that's too large: | ||||
2042 | uint32_t queueFamilyIndex[2] = {100000, 0}; | ||||
2043 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; | ||||
2044 | swapchain_create_info.queueFamilyIndexCount = 2; | ||||
2045 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; | ||||
2046 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2047 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2048 | "called with a queueFamilyIndex that is too large"); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2049 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
2050 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2051 | pass = (err != VK_SUCCESS); |
2052 | ASSERT_TRUE(pass); | ||||
2053 | m_errorMonitor->VerifyFound(); | ||||
2054 | |||||
2055 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: | ||||
2056 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; | ||||
2057 | swapchain_create_info.queueFamilyIndexCount = 1; | ||||
2058 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2059 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2060 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " | ||||
2061 | "pCreateInfo->pQueueFamilyIndices)."); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2062 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
2063 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2064 | pass = (err != VK_SUCCESS); |
2065 | ASSERT_TRUE(pass); | ||||
2066 | m_errorMonitor->VerifyFound(); | ||||
2067 | |||||
2068 | // Next, call with an invalid imageSharingMode: | ||||
2069 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; | ||||
2070 | swapchain_create_info.queueFamilyIndexCount = 1; | ||||
2071 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2072 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2073 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2074 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
2075 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2076 | pass = (err != VK_SUCCESS); |
2077 | ASSERT_TRUE(pass); | ||||
2078 | m_errorMonitor->VerifyFound(); | ||||
2079 | // Fix for the future: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2080 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
2081 | // SUPPORTED | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2082 | swapchain_create_info.queueFamilyIndexCount = 0; |
2083 | queueFamilyIndex[0] = 0; | ||||
2084 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
2085 | |||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2086 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2087 | // Get the images from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2088 | // Acquire an image from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2089 | // Present an image to a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2090 | // Destroy the swapchain: |
2091 | |||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2092 | // TODOs: |
2093 | // | ||||
2094 | // - Try destroying the device without first destroying the swapchain | ||||
2095 | // | ||||
2096 | // - Try destroying the device without first destroying the surface | ||||
2097 | // | ||||
2098 | // - Try destroying the surface without first destroying the swapchain | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2099 | |
2100 | // Destroy the surface: | ||||
2101 | vkDestroySurfaceKHR(instance(), surface, NULL); | ||||
2102 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2103 | // Tear down the window: |
2104 | xcb_destroy_window(connection, xcb_window); | ||||
2105 | xcb_disconnect(connection); | ||||
2106 | |||||
2107 | #else // VK_USE_PLATFORM_XCB_KHR | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2108 | return; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2109 | #endif // VK_USE_PLATFORM_XCB_KHR |
2110 | } | ||||
2111 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2112 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
2113 | VkResult err; | ||||
2114 | bool pass; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2115 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2116 | m_errorMonitor->SetDesiredFailureMsg( |
2117 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2118 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
2119 | |||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2120 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2121 | |
2122 | // 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] | 2123 | VkImage image; |
2124 | VkDeviceMemory mem; | ||||
2125 | VkMemoryRequirements mem_reqs; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2126 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2127 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
2128 | const int32_t tex_width = 32; | ||||
2129 | const int32_t tex_height = 32; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2130 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2131 | VkImageCreateInfo image_create_info = {}; |
2132 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2133 | image_create_info.pNext = NULL; |
2134 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
2135 | image_create_info.format = tex_format; | ||||
2136 | image_create_info.extent.width = tex_width; | ||||
2137 | image_create_info.extent.height = tex_height; | ||||
2138 | image_create_info.extent.depth = 1; | ||||
2139 | image_create_info.mipLevels = 1; | ||||
2140 | image_create_info.arrayLayers = 1; | ||||
2141 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
2142 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
2143 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
2144 | image_create_info.flags = 0; | ||||
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2145 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2146 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2147 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2148 | mem_alloc.pNext = NULL; |
2149 | mem_alloc.allocationSize = 0; | ||||
2150 | // Introduce failure, do NOT set memProps to | ||||
2151 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | ||||
2152 | mem_alloc.memoryTypeIndex = 1; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2153 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2154 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2155 | ASSERT_VK_SUCCESS(err); |
2156 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2157 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2158 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2159 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2161 | pass = |
2162 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, | ||||
2163 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
2164 | if (!pass) { // If we can't find any unmappable memory this test doesn't | ||||
2165 | // make sense | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2166 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2167 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2168 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2169 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2170 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2171 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2172 | ASSERT_VK_SUCCESS(err); |
2173 | |||||
2174 | // Try to bind free memory that has been freed | ||||
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2175 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2176 | ASSERT_VK_SUCCESS(err); |
2177 | |||||
2178 | // Map memory as if to initialize the image | ||||
2179 | void *mappedAddress = NULL; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2180 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
2181 | &mappedAddress); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2182 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2183 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2184 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2185 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 2186 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2187 | } |
2188 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2189 | TEST_F(VkLayerTest, RebindMemory) { |
2190 | VkResult err; | ||||
2191 | bool pass; | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2192 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2193 | m_errorMonitor->SetDesiredFailureMsg( |
2194 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2195 | "which has already been bound to mem object"); |
2196 | |||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2197 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2198 | |
2199 | // 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] | 2200 | VkImage image; |
2201 | VkDeviceMemory mem1; | ||||
2202 | VkDeviceMemory mem2; | ||||
2203 | VkMemoryRequirements mem_reqs; | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2204 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2205 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
2206 | const int32_t tex_width = 32; | ||||
2207 | const int32_t tex_height = 32; | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2208 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2209 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2210 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
2211 | image_create_info.pNext = NULL; | ||||
2212 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
2213 | image_create_info.format = tex_format; | ||||
2214 | image_create_info.extent.width = tex_width; | ||||
2215 | image_create_info.extent.height = tex_height; | ||||
2216 | image_create_info.extent.depth = 1; | ||||
2217 | image_create_info.mipLevels = 1; | ||||
2218 | image_create_info.arrayLayers = 1; | ||||
2219 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
2220 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
2221 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
2222 | image_create_info.flags = 0; | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2223 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2224 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2225 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
2226 | mem_alloc.pNext = NULL; | ||||
2227 | mem_alloc.allocationSize = 0; | ||||
2228 | mem_alloc.memoryTypeIndex = 0; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2229 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2230 | // Introduce failure, do NOT set memProps to |
2231 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2232 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2233 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2234 | ASSERT_VK_SUCCESS(err); |
2235 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2236 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2237 | |
2238 | mem_alloc.allocationSize = mem_reqs.size; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2239 | pass = |
2240 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2241 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2242 | |
2243 | // allocate 2 memory objects | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2244 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2245 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2246 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2247 | ASSERT_VK_SUCCESS(err); |
2248 | |||||
2249 | // Bind first memory object to Image object | ||||
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2250 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2251 | ASSERT_VK_SUCCESS(err); |
2252 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2253 | // Introduce validation failure, try to bind a different memory object to |
2254 | // the same image object | ||||
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2255 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2256 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2257 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2258 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2259 | vkDestroyImage(m_device->device(), image, NULL); |
2260 | vkFreeMemory(m_device->device(), mem1, NULL); | ||||
2261 | vkFreeMemory(m_device->device(), mem2, NULL); | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2262 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2263 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2264 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2265 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2266 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2267 | m_errorMonitor->SetDesiredFailureMsg( |
2268 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " | ||||
2269 | "must be reset before being submitted"); | ||||
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2270 | |
2271 | VkFenceCreateInfo fenceInfo = {}; | ||||
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2272 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
2273 | fenceInfo.pNext = NULL; | ||||
2274 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2275 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2276 | ASSERT_NO_FATAL_FAILURE(InitState()); |
2277 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
2278 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
2279 | |||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2280 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2281 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
2282 | m_stencil_clear_color, NULL); | ||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2283 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2284 | |
2285 | testFence.init(*m_device, fenceInfo); | ||||
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2286 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2287 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2288 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
2289 | submit_info.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2290 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2291 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2292 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2293 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2294 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2295 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2296 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2297 | |
2298 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2299 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2300 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2301 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2302 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2303 | // This is a positive test. We used to expect error in this case but spec now |
2304 | // allows it | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2305 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2306 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2307 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2308 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2309 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
2310 | fenceInfo.pNext = NULL; | ||||
2311 | |||||
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2312 | ASSERT_NO_FATAL_FAILURE(InitState()); |
2313 | testFence.init(*m_device, fenceInfo); | ||||
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2314 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2315 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
2316 | ASSERT_VK_SUCCESS(result); | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2317 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2318 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2319 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2320 | |
Chris Forbes | 18127d1 | 2016-06-08 16:52:28 +1200 | [diff] [blame] | 2321 | TEST_F(VkLayerTest, CommandBufferSimultaneousUseSync) |
2322 | { | ||||
2323 | m_errorMonitor->ExpectSuccess(); | ||||
2324 | |||||
2325 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
2326 | VkResult err; | ||||
2327 | |||||
2328 | // Record (empty!) command buffer that can be submitted multiple times | ||||
2329 | // simultaneously. | ||||
2330 | VkCommandBufferBeginInfo cbbi = { | ||||
2331 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, | ||||
2332 | VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, nullptr | ||||
2333 | }; | ||||
2334 | m_commandBuffer->BeginCommandBuffer(&cbbi); | ||||
2335 | m_commandBuffer->EndCommandBuffer(); | ||||
2336 | |||||
2337 | VkFenceCreateInfo fci = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, 0 }; | ||||
2338 | VkFence fence; | ||||
2339 | err = vkCreateFence(m_device->device(), &fci, nullptr, &fence); | ||||
2340 | ASSERT_VK_SUCCESS(err); | ||||
2341 | |||||
2342 | VkSemaphoreCreateInfo sci = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, nullptr, 0 }; | ||||
2343 | VkSemaphore s1, s2; | ||||
2344 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s1); | ||||
2345 | ASSERT_VK_SUCCESS(err); | ||||
2346 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s2); | ||||
2347 | ASSERT_VK_SUCCESS(err); | ||||
2348 | |||||
2349 | // Submit CB once signaling s1, with fence so we can roll forward to its retirement. | ||||
2350 | VkSubmitInfo si = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, 0, nullptr, nullptr, | ||||
2351 | 1, &m_commandBuffer->handle(), 1, &s1 }; | ||||
2352 | err = vkQueueSubmit(m_device->m_queue, 1, &si, fence); | ||||
2353 | ASSERT_VK_SUCCESS(err); | ||||
2354 | |||||
2355 | // Submit CB again, signaling s2. | ||||
2356 | si.pSignalSemaphores = &s2; | ||||
2357 | err = vkQueueSubmit(m_device->m_queue, 1, &si, VK_NULL_HANDLE); | ||||
2358 | ASSERT_VK_SUCCESS(err); | ||||
2359 | |||||
2360 | // Wait for fence. | ||||
2361 | err = vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
2362 | ASSERT_VK_SUCCESS(err); | ||||
2363 | |||||
2364 | // CB is still in flight from second submission, but semaphore s1 is no | ||||
2365 | // longer in flight. delete it. | ||||
2366 | vkDestroySemaphore(m_device->device(), s1, nullptr); | ||||
2367 | |||||
2368 | m_errorMonitor->VerifyNotFound(); | ||||
2369 | |||||
2370 | // Force device idle and clean up remaining objects | ||||
2371 | vkDeviceWaitIdle(m_device->device()); | ||||
2372 | vkDestroySemaphore(m_device->device(), s2, nullptr); | ||||
2373 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
2374 | } | ||||
2375 | |||||
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2376 | TEST_F(VkLayerTest, InvalidUsageBits) |
2377 | { | ||||
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2378 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2379 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2380 | "Initialize buffer with wrong usage then perform copy expecting errors " |
2381 | "from both the image and the buffer (2 calls)"); | ||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2382 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2383 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2384 | |
2385 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2386 | VkImageObj image(m_device); |
2387 | // Initialize image with USAGE_INPUT_ATTACHMENT | ||||
Tobin Ehlis | 8b313c0 | 2016-05-25 15:01:52 -0600 | [diff] [blame] | 2388 | image.init(128, 128, VK_FORMAT_D24_UNORM_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2389 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
2390 | ASSERT_TRUE(image.initialized()); | ||||
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2391 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2392 | VkImageView dsv; |
2393 | VkImageViewCreateInfo dsvci = {}; | ||||
2394 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
2395 | dsvci.image = image.handle(); | ||||
2396 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
2397 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; | ||||
2398 | dsvci.subresourceRange.layerCount = 1; | ||||
2399 | dsvci.subresourceRange.baseMipLevel = 0; | ||||
2400 | dsvci.subresourceRange.levelCount = 1; | ||||
2401 | dsvci.subresourceRange.aspectMask = | ||||
2402 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; | ||||
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2403 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2404 | // Create a view with depth / stencil aspect for image with different usage |
2405 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2406 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2407 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2408 | |
2409 | // Initialize buffer with TRANSFER_DST usage | ||||
2410 | vk_testing::Buffer buffer; | ||||
2411 | VkMemoryPropertyFlags reqs = 0; | ||||
2412 | buffer.init_as_dst(*m_device, 128 * 128, reqs); | ||||
2413 | VkBufferImageCopy region = {}; | ||||
2414 | region.bufferRowLength = 128; | ||||
2415 | region.bufferImageHeight = 128; | ||||
2416 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
2417 | region.imageSubresource.layerCount = 1; | ||||
2418 | region.imageExtent.height = 16; | ||||
2419 | region.imageExtent.width = 16; | ||||
2420 | region.imageExtent.depth = 1; | ||||
2421 | |||||
2422 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2423 | "Invalid usage flag for buffer "); | ||||
2424 | // Buffer usage not set to TRANSFER_SRC and image usage not set to | ||||
2425 | // TRANSFER_DST | ||||
2426 | BeginCommandBuffer(); | ||||
2427 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), | ||||
2428 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
2429 | 1, ®ion); | ||||
2430 | m_errorMonitor->VerifyFound(); | ||||
2431 | |||||
2432 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2433 | "Invalid usage flag for image "); | ||||
2434 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), | ||||
2435 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
2436 | 1, ®ion); | ||||
2437 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2438 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2439 | #endif // MEM_TRACKER_TESTS |
2440 | |||||
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 2441 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2442 | |
2443 | TEST_F(VkLayerTest, LeakAnObject) { | ||||
2444 | VkResult err; | ||||
2445 | |||||
2446 | TEST_DESCRIPTION( | ||||
2447 | "Create a fence and destroy its device without first destroying the fence."); | ||||
2448 | |||||
2449 | // Note that we have to create a new device since destroying the | ||||
2450 | // framework's device causes Teardown() to fail and just calling Teardown | ||||
2451 | // will destroy the errorMonitor. | ||||
2452 | |||||
2453 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2454 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2455 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); | ||||
2456 | |||||
2457 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
2458 | |||||
2459 | const std::vector<VkQueueFamilyProperties> queue_props = | ||||
2460 | m_device->queue_props; | ||||
2461 | std::vector<VkDeviceQueueCreateInfo> queue_info; | ||||
2462 | queue_info.reserve(queue_props.size()); | ||||
2463 | std::vector<std::vector<float>> queue_priorities; | ||||
2464 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { | ||||
2465 | VkDeviceQueueCreateInfo qi = {}; | ||||
2466 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; | ||||
2467 | qi.pNext = NULL; | ||||
2468 | qi.queueFamilyIndex = i; | ||||
2469 | qi.queueCount = queue_props[i].queueCount; | ||||
2470 | queue_priorities.emplace_back(qi.queueCount, 0.0f); | ||||
2471 | qi.pQueuePriorities = queue_priorities[i].data(); | ||||
2472 | queue_info.push_back(qi); | ||||
2473 | } | ||||
2474 | |||||
2475 | std::vector<const char *> device_layer_names; | ||||
2476 | std::vector<const char *> device_extension_names; | ||||
2477 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); | ||||
2478 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); | ||||
2479 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); | ||||
2480 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); | ||||
2481 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); | ||||
2482 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); | ||||
2483 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); | ||||
2484 | |||||
2485 | // The sacrificial device object | ||||
2486 | VkDevice testDevice; | ||||
2487 | VkDeviceCreateInfo device_create_info = {}; | ||||
2488 | auto features = m_device->phy().features(); | ||||
2489 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; | ||||
2490 | device_create_info.pNext = NULL; | ||||
2491 | device_create_info.queueCreateInfoCount = queue_info.size(); | ||||
2492 | device_create_info.pQueueCreateInfos = queue_info.data(); | ||||
2493 | device_create_info.enabledLayerCount = device_layer_names.size(); | ||||
2494 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); | ||||
2495 | device_create_info.pEnabledFeatures = &features; | ||||
2496 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); | ||||
2497 | ASSERT_VK_SUCCESS(err); | ||||
2498 | |||||
2499 | VkFence fence; | ||||
2500 | VkFenceCreateInfo fence_create_info = {}; | ||||
2501 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
2502 | fence_create_info.pNext = NULL; | ||||
2503 | fence_create_info.flags = 0; | ||||
2504 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); | ||||
2505 | ASSERT_VK_SUCCESS(err); | ||||
2506 | |||||
2507 | // Induce failure by not calling vkDestroyFence | ||||
2508 | vkDestroyDevice(testDevice, NULL); | ||||
2509 | m_errorMonitor->VerifyFound(); | ||||
2510 | } | ||||
2511 | |||||
2512 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { | ||||
2513 | |||||
2514 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " | ||||
2515 | "attempt to delete them from another."); | ||||
2516 | |||||
2517 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2518 | "FreeCommandBuffers is attempting to free Command Buffer"); | ||||
2519 | |||||
2520 | VkCommandPool command_pool_one; | ||||
2521 | VkCommandPool command_pool_two; | ||||
2522 | |||||
2523 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
2524 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
2525 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
2526 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
2527 | |||||
2528 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
2529 | &command_pool_one); | ||||
2530 | |||||
2531 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
2532 | &command_pool_two); | ||||
2533 | |||||
2534 | VkCommandBuffer command_buffer[9]; | ||||
2535 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
2536 | command_buffer_allocate_info.sType = | ||||
2537 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
2538 | command_buffer_allocate_info.commandPool = command_pool_one; | ||||
2539 | command_buffer_allocate_info.commandBufferCount = 9; | ||||
2540 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
2541 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
2542 | command_buffer); | ||||
2543 | |||||
2544 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, | ||||
2545 | &command_buffer[3]); | ||||
2546 | |||||
2547 | m_errorMonitor->VerifyFound(); | ||||
2548 | |||||
2549 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); | ||||
2550 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); | ||||
2551 | } | ||||
2552 | |||||
2553 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { | ||||
2554 | VkResult err; | ||||
2555 | |||||
2556 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " | ||||
2557 | "attempt to delete them from another."); | ||||
2558 | |||||
2559 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2560 | "FreeDescriptorSets is attempting to free descriptorSet"); | ||||
2561 | |||||
2562 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
2563 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
2564 | |||||
2565 | VkDescriptorPoolSize ds_type_count = {}; | ||||
2566 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
2567 | ds_type_count.descriptorCount = 1; | ||||
2568 | |||||
2569 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
2570 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
2571 | ds_pool_ci.pNext = NULL; | ||||
2572 | ds_pool_ci.flags = 0; | ||||
2573 | ds_pool_ci.maxSets = 1; | ||||
2574 | ds_pool_ci.poolSizeCount = 1; | ||||
2575 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
2576 | |||||
2577 | VkDescriptorPool ds_pool_one; | ||||
2578 | err = | ||||
2579 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); | ||||
2580 | ASSERT_VK_SUCCESS(err); | ||||
2581 | |||||
2582 | // Create a second descriptor pool | ||||
2583 | VkDescriptorPool ds_pool_two; | ||||
2584 | err = | ||||
2585 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); | ||||
2586 | ASSERT_VK_SUCCESS(err); | ||||
2587 | |||||
2588 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
2589 | dsl_binding.binding = 0; | ||||
2590 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
2591 | dsl_binding.descriptorCount = 1; | ||||
2592 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
2593 | dsl_binding.pImmutableSamplers = NULL; | ||||
2594 | |||||
2595 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
2596 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
2597 | ds_layout_ci.pNext = NULL; | ||||
2598 | ds_layout_ci.bindingCount = 1; | ||||
2599 | ds_layout_ci.pBindings = &dsl_binding; | ||||
2600 | |||||
2601 | VkDescriptorSetLayout ds_layout; | ||||
2602 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
2603 | &ds_layout); | ||||
2604 | ASSERT_VK_SUCCESS(err); | ||||
2605 | |||||
2606 | VkDescriptorSet descriptorSet; | ||||
2607 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
2608 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
2609 | alloc_info.descriptorSetCount = 1; | ||||
2610 | alloc_info.descriptorPool = ds_pool_one; | ||||
2611 | alloc_info.pSetLayouts = &ds_layout; | ||||
2612 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
2613 | &descriptorSet); | ||||
2614 | ASSERT_VK_SUCCESS(err); | ||||
2615 | |||||
2616 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); | ||||
2617 | |||||
2618 | m_errorMonitor->VerifyFound(); | ||||
2619 | |||||
2620 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
2621 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); | ||||
2622 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); | ||||
2623 | } | ||||
2624 | |||||
2625 | TEST_F(VkLayerTest, CreateUnknownObject) { | ||||
2626 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2627 | "Invalid VkImage Object "); | ||||
2628 | |||||
2629 | TEST_DESCRIPTION( | ||||
2630 | "Pass an invalid image object handle into a Vulkan API call."); | ||||
2631 | |||||
2632 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
2633 | |||||
2634 | // Pass bogus handle into GetImageMemoryRequirements | ||||
2635 | VkMemoryRequirements mem_reqs; | ||||
2636 | uint64_t fakeImageHandle = 0xCADECADE; | ||||
2637 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); | ||||
2638 | |||||
2639 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); | ||||
2640 | |||||
2641 | m_errorMonitor->VerifyFound(); | ||||
2642 | } | ||||
2643 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2644 | TEST_F(VkLayerTest, PipelineNotBound) { |
2645 | VkResult err; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2646 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2647 | TEST_DESCRIPTION( |
2648 | "Pass in an invalid pipeline object handle into a Vulkan API call."); | ||||
2649 | |||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2650 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2651 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2652 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2653 | ASSERT_NO_FATAL_FAILURE(InitState()); |
2654 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2655 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2656 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2657 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
2658 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2659 | |
2660 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2661 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
2662 | ds_pool_ci.pNext = NULL; | ||||
2663 | ds_pool_ci.maxSets = 1; | ||||
2664 | ds_pool_ci.poolSizeCount = 1; | ||||
2665 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2666 | |
2667 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2668 | err = |
2669 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2670 | ASSERT_VK_SUCCESS(err); |
2671 | |||||
2672 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2673 | dsl_binding.binding = 0; |
2674 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
2675 | dsl_binding.descriptorCount = 1; | ||||
2676 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
2677 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2678 | |
2679 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2680 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
2681 | ds_layout_ci.pNext = NULL; | ||||
2682 | ds_layout_ci.bindingCount = 1; | ||||
2683 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2684 | |
2685 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2686 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
2687 | &ds_layout); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2688 | ASSERT_VK_SUCCESS(err); |
2689 | |||||
2690 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2691 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2692 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2693 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2694 | alloc_info.descriptorPool = ds_pool; |
2695 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2696 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
2697 | &descriptorSet); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2698 | ASSERT_VK_SUCCESS(err); |
2699 | |||||
2700 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2701 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
2702 | pipeline_layout_ci.pNext = NULL; | ||||
2703 | pipeline_layout_ci.setLayoutCount = 1; | ||||
2704 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2705 | |
2706 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2707 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
2708 | &pipeline_layout); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2709 | ASSERT_VK_SUCCESS(err); |
2710 | |||||
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 2711 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2712 | |
2713 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2714 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
2715 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2716 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2717 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2718 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2719 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
2720 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
2721 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2722 | } |
2723 | |||||
Mark Lobodzinski | bc18576 | 2016-06-15 16:28:53 -0600 | [diff] [blame] | 2724 | TEST_F(VkLayerTest, BindImageInvalidMemoryType) { |
2725 | VkResult err; | ||||
2726 | |||||
2727 | TEST_DESCRIPTION("Test validation check for an invalid memory type index " | ||||
2728 | "during bind[Buffer|Image]Memory time"); | ||||
2729 | |||||
2730 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2731 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2732 | "for this object type are not compatible with the memory"); | ||||
2733 | |||||
2734 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
2735 | |||||
2736 | // Create an image, allocate memory, set a bad typeIndex and then try to | ||||
2737 | // bind it | ||||
2738 | VkImage image; | ||||
2739 | VkDeviceMemory mem; | ||||
2740 | VkMemoryRequirements mem_reqs; | ||||
2741 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
2742 | const int32_t tex_width = 32; | ||||
2743 | const int32_t tex_height = 32; | ||||
2744 | |||||
2745 | VkImageCreateInfo image_create_info = {}; | ||||
2746 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
2747 | image_create_info.pNext = NULL; | ||||
2748 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
2749 | image_create_info.format = tex_format; | ||||
2750 | image_create_info.extent.width = tex_width; | ||||
2751 | image_create_info.extent.height = tex_height; | ||||
2752 | image_create_info.extent.depth = 1; | ||||
2753 | image_create_info.mipLevels = 1; | ||||
2754 | image_create_info.arrayLayers = 1; | ||||
2755 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
2756 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
2757 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
2758 | image_create_info.flags = 0; | ||||
2759 | |||||
2760 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
2761 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
2762 | mem_alloc.pNext = NULL; | ||||
2763 | mem_alloc.allocationSize = 0; | ||||
2764 | mem_alloc.memoryTypeIndex = 0; | ||||
2765 | |||||
2766 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
2767 | ASSERT_VK_SUCCESS(err); | ||||
2768 | |||||
2769 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
2770 | mem_alloc.allocationSize = mem_reqs.size; | ||||
2771 | // Introduce Failure, select likely invalid TypeIndex | ||||
2772 | mem_alloc.memoryTypeIndex = 31; | ||||
2773 | |||||
2774 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); | ||||
2775 | ASSERT_VK_SUCCESS(err); | ||||
2776 | |||||
2777 | err = vkBindImageMemory(m_device->device(), image, mem, 0); | ||||
2778 | (void)err; | ||||
2779 | |||||
2780 | m_errorMonitor->VerifyFound(); | ||||
2781 | |||||
2782 | vkDestroyImage(m_device->device(), image, NULL); | ||||
2783 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
2784 | } | ||||
2785 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2786 | TEST_F(VkLayerTest, BindInvalidMemory) { |
2787 | VkResult err; | ||||
2788 | bool pass; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2789 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2790 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2791 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2792 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2793 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2794 | |
2795 | // 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] | 2796 | VkImage image; |
2797 | VkDeviceMemory mem; | ||||
2798 | VkMemoryRequirements mem_reqs; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2799 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2800 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
2801 | const int32_t tex_width = 32; | ||||
2802 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2803 | |
2804 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2805 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
2806 | image_create_info.pNext = NULL; | ||||
2807 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
2808 | image_create_info.format = tex_format; | ||||
2809 | image_create_info.extent.width = tex_width; | ||||
2810 | image_create_info.extent.height = tex_height; | ||||
2811 | image_create_info.extent.depth = 1; | ||||
2812 | image_create_info.mipLevels = 1; | ||||
2813 | image_create_info.arrayLayers = 1; | ||||
2814 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
2815 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
2816 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
2817 | image_create_info.flags = 0; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2818 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2819 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2820 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
2821 | mem_alloc.pNext = NULL; | ||||
2822 | mem_alloc.allocationSize = 0; | ||||
2823 | mem_alloc.memoryTypeIndex = 0; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2824 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2825 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2826 | ASSERT_VK_SUCCESS(err); |
2827 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2828 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2829 | |
2830 | mem_alloc.allocationSize = mem_reqs.size; | ||||
2831 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2832 | pass = |
2833 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2834 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2835 | |
2836 | // allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2837 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2838 | ASSERT_VK_SUCCESS(err); |
2839 | |||||
2840 | // Introduce validation failure, free memory before binding | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2841 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2842 | |
2843 | // Try to bind free memory that has been freed | ||||
2844 | err = vkBindImageMemory(m_device->device(), image, mem, 0); | ||||
2845 | // This may very well return an error. | ||||
2846 | (void)err; | ||||
2847 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2848 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2849 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2850 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2851 | } |
2852 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2853 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
2854 | VkResult err; | ||||
2855 | bool pass; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2856 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2857 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2858 | "Invalid VkImage Object "); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2859 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2860 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2861 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2862 | // Create an image object, allocate memory, destroy the object and then try |
2863 | // to bind it | ||||
2864 | VkImage image; | ||||
2865 | VkDeviceMemory mem; | ||||
2866 | VkMemoryRequirements mem_reqs; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2867 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2868 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
2869 | const int32_t tex_width = 32; | ||||
2870 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2871 | |
2872 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2873 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
2874 | image_create_info.pNext = NULL; | ||||
2875 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
2876 | image_create_info.format = tex_format; | ||||
2877 | image_create_info.extent.width = tex_width; | ||||
2878 | image_create_info.extent.height = tex_height; | ||||
2879 | image_create_info.extent.depth = 1; | ||||
2880 | image_create_info.mipLevels = 1; | ||||
2881 | image_create_info.arrayLayers = 1; | ||||
2882 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
2883 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
2884 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
2885 | image_create_info.flags = 0; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2886 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2887 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2888 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
2889 | mem_alloc.pNext = NULL; | ||||
2890 | mem_alloc.allocationSize = 0; | ||||
2891 | mem_alloc.memoryTypeIndex = 0; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2892 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2893 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2894 | ASSERT_VK_SUCCESS(err); |
2895 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2896 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2897 | |
2898 | mem_alloc.allocationSize = mem_reqs.size; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2899 | pass = |
2900 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2901 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2902 | |
2903 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2904 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2905 | ASSERT_VK_SUCCESS(err); |
2906 | |||||
2907 | // Introduce validation failure, destroy Image object before binding | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2908 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2909 | ASSERT_VK_SUCCESS(err); |
2910 | |||||
2911 | // Now Try to bind memory to this destroyed object | ||||
2912 | err = vkBindImageMemory(m_device->device(), image, mem, 0); | ||||
2913 | // This may very well return an error. | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2914 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2915 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2916 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2917 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2918 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2919 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 2920 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2921 | #endif // OBJ_TRACKER_TESTS |
2922 | |||||
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 2923 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2924 | |
2925 | // This is a positive test. No errors should be generated. | ||||
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2926 | TEST_F(VkLayerTest, WaitEventThenSet) { |
2927 | TEST_DESCRIPTION( | ||||
2928 | "Wait on a event then set it after the wait has been submitted."); | ||||
2929 | |||||
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2930 | m_errorMonitor->ExpectSuccess(); |
2931 | |||||
2932 | VkEvent event; | ||||
2933 | VkEventCreateInfo event_create_info{}; | ||||
2934 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
2935 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); | ||||
2936 | |||||
2937 | VkCommandPool command_pool; | ||||
2938 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
2939 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
2940 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
2941 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
2942 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
2943 | &command_pool); | ||||
2944 | |||||
2945 | VkCommandBuffer command_buffer; | ||||
2946 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
2947 | command_buffer_allocate_info.sType = | ||||
2948 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
2949 | command_buffer_allocate_info.commandPool = command_pool; | ||||
2950 | command_buffer_allocate_info.commandBufferCount = 1; | ||||
2951 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
2952 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
2953 | &command_buffer); | ||||
2954 | |||||
2955 | VkQueue queue = VK_NULL_HANDLE; | ||||
2956 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 2957 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2958 | |
2959 | { | ||||
2960 | VkCommandBufferBeginInfo begin_info{}; | ||||
2961 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
2962 | vkBeginCommandBuffer(command_buffer, &begin_info); | ||||
2963 | |||||
2964 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, | ||||
2965 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, | ||||
2966 | nullptr, 0, nullptr); | ||||
2967 | vkCmdResetEvent(command_buffer, event, | ||||
2968 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); | ||||
2969 | vkEndCommandBuffer(command_buffer); | ||||
2970 | } | ||||
2971 | { | ||||
2972 | VkSubmitInfo submit_info{}; | ||||
2973 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
2974 | submit_info.commandBufferCount = 1; | ||||
2975 | submit_info.pCommandBuffers = &command_buffer; | ||||
2976 | submit_info.signalSemaphoreCount = 0; | ||||
2977 | submit_info.pSignalSemaphores = nullptr; | ||||
2978 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
2979 | } | ||||
2980 | { vkSetEvent(m_device->device(), event); } | ||||
2981 | |||||
2982 | vkQueueWaitIdle(queue); | ||||
2983 | |||||
2984 | vkDestroyEvent(m_device->device(), event, nullptr); | ||||
2985 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); | ||||
2986 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
2987 | |||||
2988 | m_errorMonitor->VerifyNotFound(); | ||||
2989 | } | ||||
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 2990 | // This is a positive test. No errors should be generated. |
2991 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { | ||||
2992 | TEST_DESCRIPTION( | ||||
2993 | "Issue a query and copy from it on a second command buffer."); | ||||
2994 | |||||
2995 | if ((m_device->queue_props.empty()) || | ||||
2996 | (m_device->queue_props[0].queueCount < 2)) | ||||
2997 | return; | ||||
2998 | |||||
2999 | m_errorMonitor->ExpectSuccess(); | ||||
3000 | |||||
3001 | VkQueryPool query_pool; | ||||
3002 | VkQueryPoolCreateInfo query_pool_create_info{}; | ||||
3003 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; | ||||
3004 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; | ||||
3005 | query_pool_create_info.queryCount = 1; | ||||
3006 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, | ||||
3007 | &query_pool); | ||||
3008 | |||||
3009 | VkCommandPool command_pool; | ||||
3010 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
3011 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3012 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3013 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3014 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3015 | &command_pool); | ||||
3016 | |||||
3017 | VkCommandBuffer command_buffer[2]; | ||||
3018 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
3019 | command_buffer_allocate_info.sType = | ||||
3020 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3021 | command_buffer_allocate_info.commandPool = command_pool; | ||||
3022 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
3023 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3024 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
3025 | command_buffer); | ||||
3026 | |||||
3027 | VkQueue queue = VK_NULL_HANDLE; | ||||
3028 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
3029 | 1, &queue); | ||||
3030 | |||||
3031 | uint32_t qfi = 0; | ||||
3032 | VkBufferCreateInfo buff_create_info = {}; | ||||
3033 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
3034 | buff_create_info.size = 1024; | ||||
3035 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; | ||||
3036 | buff_create_info.queueFamilyIndexCount = 1; | ||||
3037 | buff_create_info.pQueueFamilyIndices = &qfi; | ||||
3038 | |||||
3039 | VkResult err; | ||||
3040 | VkBuffer buffer; | ||||
3041 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); | ||||
3042 | ASSERT_VK_SUCCESS(err); | ||||
3043 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
3044 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
3045 | mem_alloc.pNext = NULL; | ||||
3046 | mem_alloc.allocationSize = 1024; | ||||
3047 | mem_alloc.memoryTypeIndex = 0; | ||||
3048 | |||||
3049 | VkMemoryRequirements memReqs; | ||||
3050 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); | ||||
3051 | bool pass = | ||||
3052 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); | ||||
3053 | if (!pass) { | ||||
3054 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
3055 | return; | ||||
3056 | } | ||||
3057 | |||||
3058 | VkDeviceMemory mem; | ||||
3059 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); | ||||
3060 | ASSERT_VK_SUCCESS(err); | ||||
3061 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
3062 | ASSERT_VK_SUCCESS(err); | ||||
3063 | |||||
3064 | { | ||||
3065 | VkCommandBufferBeginInfo begin_info{}; | ||||
3066 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3067 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
3068 | |||||
3069 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); | ||||
3070 | vkCmdWriteTimestamp(command_buffer[0], | ||||
3071 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); | ||||
3072 | |||||
3073 | vkEndCommandBuffer(command_buffer[0]); | ||||
3074 | |||||
3075 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
3076 | |||||
3077 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, | ||||
3078 | 0, 0, 0); | ||||
3079 | |||||
3080 | vkEndCommandBuffer(command_buffer[1]); | ||||
3081 | } | ||||
3082 | { | ||||
3083 | VkSubmitInfo submit_info{}; | ||||
3084 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3085 | submit_info.commandBufferCount = 2; | ||||
3086 | submit_info.pCommandBuffers = command_buffer; | ||||
3087 | submit_info.signalSemaphoreCount = 0; | ||||
3088 | submit_info.pSignalSemaphores = nullptr; | ||||
3089 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
3090 | } | ||||
3091 | |||||
3092 | vkQueueWaitIdle(queue); | ||||
3093 | |||||
3094 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); | ||||
3095 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); | ||||
3096 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3097 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
3098 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 3099 | |
3100 | m_errorMonitor->VerifyNotFound(); | ||||
3101 | } | ||||
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3102 | |
3103 | TEST_F(VkLayerTest, ResetEventThenSet) { | ||||
3104 | TEST_DESCRIPTION( | ||||
3105 | "Reset an event then set it after the reset has been submitted."); | ||||
3106 | |||||
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3107 | m_errorMonitor->ExpectSuccess(); |
3108 | |||||
3109 | VkEvent event; | ||||
3110 | VkEventCreateInfo event_create_info{}; | ||||
3111 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
3112 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); | ||||
3113 | |||||
3114 | VkCommandPool command_pool; | ||||
3115 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
3116 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3117 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3118 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3119 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3120 | &command_pool); | ||||
3121 | |||||
3122 | VkCommandBuffer command_buffer; | ||||
3123 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
3124 | command_buffer_allocate_info.sType = | ||||
3125 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3126 | command_buffer_allocate_info.commandPool = command_pool; | ||||
3127 | command_buffer_allocate_info.commandBufferCount = 1; | ||||
3128 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3129 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
3130 | &command_buffer); | ||||
3131 | |||||
3132 | VkQueue queue = VK_NULL_HANDLE; | ||||
3133 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 3134 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 3135 | |
3136 | { | ||||
3137 | VkCommandBufferBeginInfo begin_info{}; | ||||
3138 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3139 | vkBeginCommandBuffer(command_buffer, &begin_info); | ||||
3140 | |||||
3141 | vkCmdResetEvent(command_buffer, event, | ||||
3142 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); | ||||
3143 | vkCmdWaitEvents(command_buffer, 1, &event, | ||||
3144 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
3145 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, | ||||
3146 | nullptr, 0, nullptr); | ||||
3147 | vkEndCommandBuffer(command_buffer); | ||||
3148 | } | ||||
3149 | { | ||||
3150 | VkSubmitInfo submit_info{}; | ||||
3151 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3152 | submit_info.commandBufferCount = 1; | ||||
3153 | submit_info.pCommandBuffers = &command_buffer; | ||||
3154 | submit_info.signalSemaphoreCount = 0; | ||||
3155 | submit_info.pSignalSemaphores = nullptr; | ||||
3156 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
3157 | } | ||||
3158 | { | ||||
3159 | m_errorMonitor->SetDesiredFailureMsg( | ||||
3160 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " | ||||
3161 | "0x1 that is already in use by a " | ||||
3162 | "command buffer."); | ||||
3163 | vkSetEvent(m_device->device(), event); | ||||
3164 | m_errorMonitor->VerifyFound(); | ||||
3165 | } | ||||
3166 | |||||
3167 | vkQueueWaitIdle(queue); | ||||
3168 | |||||
3169 | vkDestroyEvent(m_device->device(), event, nullptr); | ||||
3170 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); | ||||
3171 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
3172 | } | ||||
3173 | |||||
3174 | // This is a positive test. No errors should be generated. | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3175 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
3176 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " | ||||
3177 | "run through a Submit & WaitForFences cycle 3 times. This " | ||||
3178 | "previously revealed a bug so running this positive test " | ||||
3179 | "to prevent a regression."); | ||||
3180 | m_errorMonitor->ExpectSuccess(); | ||||
3181 | |||||
3182 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3183 | VkQueue queue = VK_NULL_HANDLE; | ||||
3184 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
3185 | 0, &queue); | ||||
3186 | |||||
3187 | static const uint32_t NUM_OBJECTS = 2; | ||||
3188 | static const uint32_t NUM_FRAMES = 3; | ||||
3189 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; | ||||
3190 | VkFence fences[NUM_OBJECTS] = {}; | ||||
3191 | |||||
3192 | VkCommandPool cmd_pool; | ||||
3193 | VkCommandPoolCreateInfo cmd_pool_ci = {}; | ||||
3194 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3195 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3196 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3197 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, | ||||
3198 | nullptr, &cmd_pool); | ||||
3199 | ASSERT_VK_SUCCESS(err); | ||||
3200 | |||||
3201 | VkCommandBufferAllocateInfo cmd_buf_info = {}; | ||||
3202 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3203 | cmd_buf_info.commandPool = cmd_pool; | ||||
3204 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3205 | cmd_buf_info.commandBufferCount = 1; | ||||
3206 | |||||
3207 | VkFenceCreateInfo fence_ci = {}; | ||||
3208 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
3209 | fence_ci.pNext = nullptr; | ||||
3210 | fence_ci.flags = 0; | ||||
3211 | |||||
3212 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { | ||||
3213 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, | ||||
3214 | &cmd_buffers[i]); | ||||
3215 | ASSERT_VK_SUCCESS(err); | ||||
3216 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); | ||||
3217 | ASSERT_VK_SUCCESS(err); | ||||
3218 | } | ||||
3219 | |||||
3220 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { | ||||
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3221 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
3222 | // Create empty cmd buffer | ||||
3223 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; | ||||
3224 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3225 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3226 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
3227 | ASSERT_VK_SUCCESS(err); | ||||
3228 | err = vkEndCommandBuffer(cmd_buffers[obj]); | ||||
3229 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3230 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3231 | VkSubmitInfo submit_info = {}; |
3232 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3233 | submit_info.commandBufferCount = 1; | ||||
3234 | submit_info.pCommandBuffers = &cmd_buffers[obj]; | ||||
3235 | // Submit cmd buffer and wait for fence | ||||
3236 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); | ||||
3237 | ASSERT_VK_SUCCESS(err); | ||||
3238 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, | ||||
3239 | UINT64_MAX); | ||||
3240 | ASSERT_VK_SUCCESS(err); | ||||
3241 | err = vkResetFences(m_device->device(), 1, &fences[obj]); | ||||
3242 | ASSERT_VK_SUCCESS(err); | ||||
3243 | } | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3244 | } |
3245 | m_errorMonitor->VerifyNotFound(); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 3246 | vkDestroyCommandPool(m_device->device(), cmd_pool, NULL); |
3247 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { | ||||
3248 | vkDestroyFence(m_device->device(), fences[i], nullptr); | ||||
3249 | } | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3250 | } |
3251 | // This is a positive test. No errors should be generated. | ||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3252 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
3253 | |||||
3254 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
3255 | "submitted on separate queues followed by a QueueWaitIdle."); | ||||
3256 | |||||
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3257 | if ((m_device->queue_props.empty()) || |
3258 | (m_device->queue_props[0].queueCount < 2)) | ||||
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3259 | return; |
3260 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3261 | m_errorMonitor->ExpectSuccess(); |
3262 | |||||
3263 | VkSemaphore semaphore; | ||||
3264 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
3265 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
3266 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
3267 | &semaphore); | ||||
3268 | |||||
3269 | VkCommandPool command_pool; | ||||
3270 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
3271 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3272 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3273 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3274 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3275 | &command_pool); | ||||
3276 | |||||
3277 | VkCommandBuffer command_buffer[2]; | ||||
3278 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
3279 | command_buffer_allocate_info.sType = | ||||
3280 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3281 | command_buffer_allocate_info.commandPool = command_pool; | ||||
3282 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
3283 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3284 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
3285 | command_buffer); | ||||
3286 | |||||
3287 | VkQueue queue = VK_NULL_HANDLE; | ||||
3288 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
3289 | 1, &queue); | ||||
3290 | |||||
3291 | { | ||||
3292 | VkCommandBufferBeginInfo begin_info{}; | ||||
3293 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3294 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
3295 | |||||
3296 | vkCmdPipelineBarrier(command_buffer[0], | ||||
3297 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
3298 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
3299 | 0, nullptr, 0, nullptr); | ||||
3300 | |||||
3301 | VkViewport viewport{}; | ||||
3302 | viewport.maxDepth = 1.0f; | ||||
3303 | viewport.minDepth = 0.0f; | ||||
3304 | viewport.width = 512; | ||||
3305 | viewport.height = 512; | ||||
3306 | viewport.x = 0; | ||||
3307 | viewport.y = 0; | ||||
3308 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
3309 | vkEndCommandBuffer(command_buffer[0]); | ||||
3310 | } | ||||
3311 | { | ||||
3312 | VkCommandBufferBeginInfo begin_info{}; | ||||
3313 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3314 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
3315 | |||||
3316 | VkViewport viewport{}; | ||||
3317 | viewport.maxDepth = 1.0f; | ||||
3318 | viewport.minDepth = 0.0f; | ||||
3319 | viewport.width = 512; | ||||
3320 | viewport.height = 512; | ||||
3321 | viewport.x = 0; | ||||
3322 | viewport.y = 0; | ||||
3323 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
3324 | vkEndCommandBuffer(command_buffer[1]); | ||||
3325 | } | ||||
3326 | { | ||||
3327 | VkSubmitInfo submit_info{}; | ||||
3328 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3329 | submit_info.commandBufferCount = 1; | ||||
3330 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
3331 | submit_info.signalSemaphoreCount = 1; | ||||
3332 | submit_info.pSignalSemaphores = &semaphore; | ||||
3333 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
3334 | } | ||||
3335 | { | ||||
3336 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
3337 | VkSubmitInfo submit_info{}; | ||||
3338 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3339 | submit_info.commandBufferCount = 1; | ||||
3340 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
3341 | submit_info.waitSemaphoreCount = 1; | ||||
3342 | submit_info.pWaitSemaphores = &semaphore; | ||||
3343 | submit_info.pWaitDstStageMask = flags; | ||||
3344 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
3345 | } | ||||
3346 | |||||
3347 | vkQueueWaitIdle(m_device->m_queue); | ||||
3348 | |||||
3349 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
3350 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
3351 | &command_buffer[0]); | ||||
3352 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
3353 | |||||
3354 | m_errorMonitor->VerifyNotFound(); | ||||
3355 | } | ||||
3356 | |||||
3357 | // This is a positive test. No errors should be generated. | ||||
3358 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { | ||||
3359 | |||||
3360 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
3361 | "submitted on separate queues, the second having a fence" | ||||
3362 | "followed by a QueueWaitIdle."); | ||||
3363 | |||||
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3364 | if ((m_device->queue_props.empty()) || |
3365 | (m_device->queue_props[0].queueCount < 2)) | ||||
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3366 | return; |
3367 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3368 | m_errorMonitor->ExpectSuccess(); |
3369 | |||||
3370 | VkFence fence; | ||||
3371 | VkFenceCreateInfo fence_create_info{}; | ||||
3372 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
3373 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
3374 | |||||
3375 | VkSemaphore semaphore; | ||||
3376 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
3377 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
3378 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
3379 | &semaphore); | ||||
3380 | |||||
3381 | VkCommandPool command_pool; | ||||
3382 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
3383 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3384 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3385 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3386 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3387 | &command_pool); | ||||
3388 | |||||
3389 | VkCommandBuffer command_buffer[2]; | ||||
3390 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
3391 | command_buffer_allocate_info.sType = | ||||
3392 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3393 | command_buffer_allocate_info.commandPool = command_pool; | ||||
3394 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
3395 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3396 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
3397 | command_buffer); | ||||
3398 | |||||
3399 | VkQueue queue = VK_NULL_HANDLE; | ||||
3400 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
3401 | 1, &queue); | ||||
3402 | |||||
3403 | { | ||||
3404 | VkCommandBufferBeginInfo begin_info{}; | ||||
3405 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3406 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
3407 | |||||
3408 | vkCmdPipelineBarrier(command_buffer[0], | ||||
3409 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
3410 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
3411 | 0, nullptr, 0, nullptr); | ||||
3412 | |||||
3413 | VkViewport viewport{}; | ||||
3414 | viewport.maxDepth = 1.0f; | ||||
3415 | viewport.minDepth = 0.0f; | ||||
3416 | viewport.width = 512; | ||||
3417 | viewport.height = 512; | ||||
3418 | viewport.x = 0; | ||||
3419 | viewport.y = 0; | ||||
3420 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
3421 | vkEndCommandBuffer(command_buffer[0]); | ||||
3422 | } | ||||
3423 | { | ||||
3424 | VkCommandBufferBeginInfo begin_info{}; | ||||
3425 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3426 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
3427 | |||||
3428 | VkViewport viewport{}; | ||||
3429 | viewport.maxDepth = 1.0f; | ||||
3430 | viewport.minDepth = 0.0f; | ||||
3431 | viewport.width = 512; | ||||
3432 | viewport.height = 512; | ||||
3433 | viewport.x = 0; | ||||
3434 | viewport.y = 0; | ||||
3435 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
3436 | vkEndCommandBuffer(command_buffer[1]); | ||||
3437 | } | ||||
3438 | { | ||||
3439 | VkSubmitInfo submit_info{}; | ||||
3440 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3441 | submit_info.commandBufferCount = 1; | ||||
3442 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
3443 | submit_info.signalSemaphoreCount = 1; | ||||
3444 | submit_info.pSignalSemaphores = &semaphore; | ||||
3445 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
3446 | } | ||||
3447 | { | ||||
3448 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
3449 | VkSubmitInfo submit_info{}; | ||||
3450 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3451 | submit_info.commandBufferCount = 1; | ||||
3452 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
3453 | submit_info.waitSemaphoreCount = 1; | ||||
3454 | submit_info.pWaitSemaphores = &semaphore; | ||||
3455 | submit_info.pWaitDstStageMask = flags; | ||||
3456 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
3457 | } | ||||
3458 | |||||
3459 | vkQueueWaitIdle(m_device->m_queue); | ||||
3460 | |||||
3461 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
3462 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
3463 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
3464 | &command_buffer[0]); | ||||
3465 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
3466 | |||||
3467 | m_errorMonitor->VerifyNotFound(); | ||||
3468 | } | ||||
3469 | |||||
3470 | // This is a positive test. No errors should be generated. | ||||
3471 | TEST_F(VkLayerTest, | ||||
3472 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { | ||||
3473 | |||||
3474 | TEST_DESCRIPTION( | ||||
3475 | "Two command buffers, each in a separate QueueSubmit call " | ||||
3476 | "submitted on separate queues, the second having a fence" | ||||
3477 | "followed by two consecutive WaitForFences calls on the same fence."); | ||||
3478 | |||||
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3479 | if ((m_device->queue_props.empty()) || |
3480 | (m_device->queue_props[0].queueCount < 2)) | ||||
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3481 | return; |
3482 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3483 | m_errorMonitor->ExpectSuccess(); |
3484 | |||||
3485 | VkFence fence; | ||||
3486 | VkFenceCreateInfo fence_create_info{}; | ||||
3487 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
3488 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
3489 | |||||
3490 | VkSemaphore semaphore; | ||||
3491 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
3492 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
3493 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
3494 | &semaphore); | ||||
3495 | |||||
3496 | VkCommandPool command_pool; | ||||
3497 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
3498 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3499 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3500 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3501 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3502 | &command_pool); | ||||
3503 | |||||
3504 | VkCommandBuffer command_buffer[2]; | ||||
3505 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
3506 | command_buffer_allocate_info.sType = | ||||
3507 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3508 | command_buffer_allocate_info.commandPool = command_pool; | ||||
3509 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
3510 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3511 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
3512 | command_buffer); | ||||
3513 | |||||
3514 | VkQueue queue = VK_NULL_HANDLE; | ||||
3515 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
3516 | 1, &queue); | ||||
3517 | |||||
3518 | { | ||||
3519 | VkCommandBufferBeginInfo begin_info{}; | ||||
3520 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3521 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
3522 | |||||
3523 | vkCmdPipelineBarrier(command_buffer[0], | ||||
3524 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
3525 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
3526 | 0, nullptr, 0, nullptr); | ||||
3527 | |||||
3528 | VkViewport viewport{}; | ||||
3529 | viewport.maxDepth = 1.0f; | ||||
3530 | viewport.minDepth = 0.0f; | ||||
3531 | viewport.width = 512; | ||||
3532 | viewport.height = 512; | ||||
3533 | viewport.x = 0; | ||||
3534 | viewport.y = 0; | ||||
3535 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
3536 | vkEndCommandBuffer(command_buffer[0]); | ||||
3537 | } | ||||
3538 | { | ||||
3539 | VkCommandBufferBeginInfo begin_info{}; | ||||
3540 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3541 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
3542 | |||||
3543 | VkViewport viewport{}; | ||||
3544 | viewport.maxDepth = 1.0f; | ||||
3545 | viewport.minDepth = 0.0f; | ||||
3546 | viewport.width = 512; | ||||
3547 | viewport.height = 512; | ||||
3548 | viewport.x = 0; | ||||
3549 | viewport.y = 0; | ||||
3550 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
3551 | vkEndCommandBuffer(command_buffer[1]); | ||||
3552 | } | ||||
3553 | { | ||||
3554 | VkSubmitInfo submit_info{}; | ||||
3555 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3556 | submit_info.commandBufferCount = 1; | ||||
3557 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
3558 | submit_info.signalSemaphoreCount = 1; | ||||
3559 | submit_info.pSignalSemaphores = &semaphore; | ||||
3560 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
3561 | } | ||||
3562 | { | ||||
3563 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
3564 | VkSubmitInfo submit_info{}; | ||||
3565 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3566 | submit_info.commandBufferCount = 1; | ||||
3567 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
3568 | submit_info.waitSemaphoreCount = 1; | ||||
3569 | submit_info.pWaitSemaphores = &semaphore; | ||||
3570 | submit_info.pWaitDstStageMask = flags; | ||||
3571 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
3572 | } | ||||
3573 | |||||
3574 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
3575 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
3576 | |||||
3577 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
3578 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
3579 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
3580 | &command_buffer[0]); | ||||
3581 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
3582 | |||||
3583 | m_errorMonitor->VerifyNotFound(); | ||||
3584 | } | ||||
3585 | |||||
3586 | // This is a positive test. No errors should be generated. | ||||
3587 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { | ||||
3588 | |||||
3589 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
3590 | "submitted on separate queues, the second having a fence, " | ||||
3591 | "followed by a WaitForFences call."); | ||||
3592 | |||||
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3593 | if ((m_device->queue_props.empty()) || |
3594 | (m_device->queue_props[0].queueCount < 2)) | ||||
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3595 | return; |
3596 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3597 | m_errorMonitor->ExpectSuccess(); |
3598 | |||||
3599 | VkFence fence; | ||||
3600 | VkFenceCreateInfo fence_create_info{}; | ||||
3601 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
3602 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
3603 | |||||
3604 | VkSemaphore semaphore; | ||||
3605 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
3606 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
3607 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
3608 | &semaphore); | ||||
3609 | |||||
3610 | VkCommandPool command_pool; | ||||
3611 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
3612 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3613 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3614 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3615 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3616 | &command_pool); | ||||
3617 | |||||
3618 | VkCommandBuffer command_buffer[2]; | ||||
3619 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
3620 | command_buffer_allocate_info.sType = | ||||
3621 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3622 | command_buffer_allocate_info.commandPool = command_pool; | ||||
3623 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
3624 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3625 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
3626 | command_buffer); | ||||
3627 | |||||
3628 | VkQueue queue = VK_NULL_HANDLE; | ||||
3629 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
3630 | 1, &queue); | ||||
3631 | |||||
3632 | |||||
3633 | { | ||||
3634 | VkCommandBufferBeginInfo begin_info{}; | ||||
3635 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3636 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
3637 | |||||
3638 | vkCmdPipelineBarrier(command_buffer[0], | ||||
3639 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
3640 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
3641 | 0, nullptr, 0, nullptr); | ||||
3642 | |||||
3643 | VkViewport viewport{}; | ||||
3644 | viewport.maxDepth = 1.0f; | ||||
3645 | viewport.minDepth = 0.0f; | ||||
3646 | viewport.width = 512; | ||||
3647 | viewport.height = 512; | ||||
3648 | viewport.x = 0; | ||||
3649 | viewport.y = 0; | ||||
3650 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
3651 | vkEndCommandBuffer(command_buffer[0]); | ||||
3652 | } | ||||
3653 | { | ||||
3654 | VkCommandBufferBeginInfo begin_info{}; | ||||
3655 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3656 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
3657 | |||||
3658 | VkViewport viewport{}; | ||||
3659 | viewport.maxDepth = 1.0f; | ||||
3660 | viewport.minDepth = 0.0f; | ||||
3661 | viewport.width = 512; | ||||
3662 | viewport.height = 512; | ||||
3663 | viewport.x = 0; | ||||
3664 | viewport.y = 0; | ||||
3665 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
3666 | vkEndCommandBuffer(command_buffer[1]); | ||||
3667 | } | ||||
3668 | { | ||||
3669 | VkSubmitInfo submit_info{}; | ||||
3670 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3671 | submit_info.commandBufferCount = 1; | ||||
3672 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
3673 | submit_info.signalSemaphoreCount = 1; | ||||
3674 | submit_info.pSignalSemaphores = &semaphore; | ||||
3675 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
3676 | } | ||||
3677 | { | ||||
3678 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
3679 | VkSubmitInfo submit_info{}; | ||||
3680 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3681 | submit_info.commandBufferCount = 1; | ||||
3682 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
3683 | submit_info.waitSemaphoreCount = 1; | ||||
3684 | submit_info.pWaitSemaphores = &semaphore; | ||||
3685 | submit_info.pWaitDstStageMask = flags; | ||||
3686 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
3687 | } | ||||
3688 | |||||
3689 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
3690 | |||||
3691 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
3692 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
3693 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
3694 | &command_buffer[0]); | ||||
3695 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
3696 | |||||
3697 | m_errorMonitor->VerifyNotFound(); | ||||
3698 | } | ||||
3699 | |||||
3700 | // This is a positive test. No errors should be generated. | ||||
3701 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { | ||||
3702 | |||||
3703 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
3704 | "on the same queue, sharing a signal/wait semaphore, the " | ||||
3705 | "second having a fence, " | ||||
3706 | "followed by a WaitForFences call."); | ||||
3707 | |||||
3708 | m_errorMonitor->ExpectSuccess(); | ||||
3709 | |||||
3710 | VkFence fence; | ||||
3711 | VkFenceCreateInfo fence_create_info{}; | ||||
3712 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
3713 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
3714 | |||||
3715 | VkSemaphore semaphore; | ||||
3716 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
3717 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
3718 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
3719 | &semaphore); | ||||
3720 | |||||
3721 | VkCommandPool command_pool; | ||||
3722 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
3723 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3724 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3725 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3726 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3727 | &command_pool); | ||||
3728 | |||||
3729 | VkCommandBuffer command_buffer[2]; | ||||
3730 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
3731 | command_buffer_allocate_info.sType = | ||||
3732 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3733 | command_buffer_allocate_info.commandPool = command_pool; | ||||
3734 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
3735 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3736 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
3737 | command_buffer); | ||||
3738 | |||||
3739 | { | ||||
3740 | VkCommandBufferBeginInfo begin_info{}; | ||||
3741 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3742 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
3743 | |||||
3744 | vkCmdPipelineBarrier(command_buffer[0], | ||||
3745 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
3746 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
3747 | 0, nullptr, 0, nullptr); | ||||
3748 | |||||
3749 | VkViewport viewport{}; | ||||
3750 | viewport.maxDepth = 1.0f; | ||||
3751 | viewport.minDepth = 0.0f; | ||||
3752 | viewport.width = 512; | ||||
3753 | viewport.height = 512; | ||||
3754 | viewport.x = 0; | ||||
3755 | viewport.y = 0; | ||||
3756 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
3757 | vkEndCommandBuffer(command_buffer[0]); | ||||
3758 | } | ||||
3759 | { | ||||
3760 | VkCommandBufferBeginInfo begin_info{}; | ||||
3761 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3762 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
3763 | |||||
3764 | VkViewport viewport{}; | ||||
3765 | viewport.maxDepth = 1.0f; | ||||
3766 | viewport.minDepth = 0.0f; | ||||
3767 | viewport.width = 512; | ||||
3768 | viewport.height = 512; | ||||
3769 | viewport.x = 0; | ||||
3770 | viewport.y = 0; | ||||
3771 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
3772 | vkEndCommandBuffer(command_buffer[1]); | ||||
3773 | } | ||||
3774 | { | ||||
3775 | VkSubmitInfo submit_info{}; | ||||
3776 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3777 | submit_info.commandBufferCount = 1; | ||||
3778 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
3779 | submit_info.signalSemaphoreCount = 1; | ||||
3780 | submit_info.pSignalSemaphores = &semaphore; | ||||
3781 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
3782 | } | ||||
3783 | { | ||||
3784 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
3785 | VkSubmitInfo submit_info{}; | ||||
3786 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3787 | submit_info.commandBufferCount = 1; | ||||
3788 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
3789 | submit_info.waitSemaphoreCount = 1; | ||||
3790 | submit_info.pWaitSemaphores = &semaphore; | ||||
3791 | submit_info.pWaitDstStageMask = flags; | ||||
3792 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
3793 | } | ||||
3794 | |||||
3795 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
3796 | |||||
3797 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
3798 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
3799 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
3800 | &command_buffer[0]); | ||||
3801 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
3802 | |||||
3803 | m_errorMonitor->VerifyNotFound(); | ||||
3804 | } | ||||
3805 | |||||
3806 | // This is a positive test. No errors should be generated. | ||||
3807 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { | ||||
3808 | |||||
3809 | TEST_DESCRIPTION( | ||||
3810 | "Two command buffers, each in a separate QueueSubmit call " | ||||
3811 | "on the same queue, no fences, followed by a third QueueSubmit with NO " | ||||
3812 | "SubmitInfos but with a fence, followed by a WaitForFences call."); | ||||
3813 | |||||
3814 | m_errorMonitor->ExpectSuccess(); | ||||
3815 | |||||
3816 | VkFence fence; | ||||
3817 | VkFenceCreateInfo fence_create_info{}; | ||||
3818 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
3819 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
3820 | |||||
3821 | VkCommandPool command_pool; | ||||
3822 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
3823 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3824 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3825 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3826 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3827 | &command_pool); | ||||
3828 | |||||
3829 | VkCommandBuffer command_buffer[2]; | ||||
3830 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
3831 | command_buffer_allocate_info.sType = | ||||
3832 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3833 | command_buffer_allocate_info.commandPool = command_pool; | ||||
3834 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
3835 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3836 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
3837 | command_buffer); | ||||
3838 | |||||
3839 | { | ||||
3840 | VkCommandBufferBeginInfo begin_info{}; | ||||
3841 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3842 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
3843 | |||||
3844 | vkCmdPipelineBarrier(command_buffer[0], | ||||
3845 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
3846 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
3847 | 0, nullptr, 0, nullptr); | ||||
3848 | |||||
3849 | VkViewport viewport{}; | ||||
3850 | viewport.maxDepth = 1.0f; | ||||
3851 | viewport.minDepth = 0.0f; | ||||
3852 | viewport.width = 512; | ||||
3853 | viewport.height = 512; | ||||
3854 | viewport.x = 0; | ||||
3855 | viewport.y = 0; | ||||
3856 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
3857 | vkEndCommandBuffer(command_buffer[0]); | ||||
3858 | } | ||||
3859 | { | ||||
3860 | VkCommandBufferBeginInfo begin_info{}; | ||||
3861 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3862 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
3863 | |||||
3864 | VkViewport viewport{}; | ||||
3865 | viewport.maxDepth = 1.0f; | ||||
3866 | viewport.minDepth = 0.0f; | ||||
3867 | viewport.width = 512; | ||||
3868 | viewport.height = 512; | ||||
3869 | viewport.x = 0; | ||||
3870 | viewport.y = 0; | ||||
3871 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
3872 | vkEndCommandBuffer(command_buffer[1]); | ||||
3873 | } | ||||
3874 | { | ||||
3875 | VkSubmitInfo submit_info{}; | ||||
3876 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3877 | submit_info.commandBufferCount = 1; | ||||
3878 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
3879 | submit_info.signalSemaphoreCount = 0; | ||||
3880 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; | ||||
3881 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
3882 | } | ||||
3883 | { | ||||
3884 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
3885 | VkSubmitInfo submit_info{}; | ||||
3886 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3887 | submit_info.commandBufferCount = 1; | ||||
3888 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
3889 | submit_info.waitSemaphoreCount = 0; | ||||
3890 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; | ||||
3891 | submit_info.pWaitDstStageMask = flags; | ||||
3892 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
3893 | } | ||||
3894 | |||||
3895 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); | ||||
3896 | |||||
3897 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
3898 | |||||
3899 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
3900 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
3901 | &command_buffer[0]); | ||||
3902 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
3903 | |||||
3904 | m_errorMonitor->VerifyNotFound(); | ||||
3905 | } | ||||
3906 | |||||
3907 | // This is a positive test. No errors should be generated. | ||||
3908 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { | ||||
3909 | |||||
3910 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
3911 | "on the same queue, the second having a fence, followed " | ||||
3912 | "by a WaitForFences call."); | ||||
3913 | |||||
3914 | m_errorMonitor->ExpectSuccess(); | ||||
3915 | |||||
3916 | VkFence fence; | ||||
3917 | VkFenceCreateInfo fence_create_info{}; | ||||
3918 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
3919 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
3920 | |||||
3921 | VkCommandPool command_pool; | ||||
3922 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
3923 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3924 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3925 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3926 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3927 | &command_pool); | ||||
3928 | |||||
3929 | VkCommandBuffer command_buffer[2]; | ||||
3930 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
3931 | command_buffer_allocate_info.sType = | ||||
3932 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3933 | command_buffer_allocate_info.commandPool = command_pool; | ||||
3934 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
3935 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3936 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
3937 | command_buffer); | ||||
3938 | |||||
3939 | { | ||||
3940 | VkCommandBufferBeginInfo begin_info{}; | ||||
3941 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3942 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
3943 | |||||
3944 | vkCmdPipelineBarrier(command_buffer[0], | ||||
3945 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
3946 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
3947 | 0, nullptr, 0, nullptr); | ||||
3948 | |||||
3949 | VkViewport viewport{}; | ||||
3950 | viewport.maxDepth = 1.0f; | ||||
3951 | viewport.minDepth = 0.0f; | ||||
3952 | viewport.width = 512; | ||||
3953 | viewport.height = 512; | ||||
3954 | viewport.x = 0; | ||||
3955 | viewport.y = 0; | ||||
3956 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
3957 | vkEndCommandBuffer(command_buffer[0]); | ||||
3958 | } | ||||
3959 | { | ||||
3960 | VkCommandBufferBeginInfo begin_info{}; | ||||
3961 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3962 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
3963 | |||||
3964 | VkViewport viewport{}; | ||||
3965 | viewport.maxDepth = 1.0f; | ||||
3966 | viewport.minDepth = 0.0f; | ||||
3967 | viewport.width = 512; | ||||
3968 | viewport.height = 512; | ||||
3969 | viewport.x = 0; | ||||
3970 | viewport.y = 0; | ||||
3971 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
3972 | vkEndCommandBuffer(command_buffer[1]); | ||||
3973 | } | ||||
3974 | { | ||||
3975 | VkSubmitInfo submit_info{}; | ||||
3976 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3977 | submit_info.commandBufferCount = 1; | ||||
3978 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
3979 | submit_info.signalSemaphoreCount = 0; | ||||
3980 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; | ||||
3981 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
3982 | } | ||||
3983 | { | ||||
3984 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
3985 | VkSubmitInfo submit_info{}; | ||||
3986 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
3987 | submit_info.commandBufferCount = 1; | ||||
3988 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
3989 | submit_info.waitSemaphoreCount = 0; | ||||
3990 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; | ||||
3991 | submit_info.pWaitDstStageMask = flags; | ||||
3992 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
3993 | } | ||||
3994 | |||||
3995 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
3996 | |||||
3997 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
3998 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
3999 | &command_buffer[0]); | ||||
4000 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
4001 | |||||
4002 | m_errorMonitor->VerifyNotFound(); | ||||
4003 | } | ||||
4004 | |||||
4005 | // This is a positive test. No errors should be generated. | ||||
4006 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { | ||||
4007 | |||||
4008 | TEST_DESCRIPTION( | ||||
4009 | "Two command buffers each in a separate SubmitInfo sent in a single " | ||||
4010 | "QueueSubmit call followed by a WaitForFences call."); | ||||
4011 | |||||
4012 | m_errorMonitor->ExpectSuccess(); | ||||
4013 | |||||
4014 | VkFence fence; | ||||
4015 | VkFenceCreateInfo fence_create_info{}; | ||||
4016 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
4017 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
4018 | |||||
4019 | VkSemaphore semaphore; | ||||
4020 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
4021 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
4022 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
4023 | &semaphore); | ||||
4024 | |||||
4025 | VkCommandPool command_pool; | ||||
4026 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
4027 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
4028 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
4029 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
4030 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
4031 | &command_pool); | ||||
4032 | |||||
4033 | VkCommandBuffer command_buffer[2]; | ||||
4034 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
4035 | command_buffer_allocate_info.sType = | ||||
4036 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
4037 | command_buffer_allocate_info.commandPool = command_pool; | ||||
4038 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
4039 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
4040 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
4041 | command_buffer); | ||||
4042 | |||||
4043 | { | ||||
4044 | VkCommandBufferBeginInfo begin_info{}; | ||||
4045 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
4046 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
4047 | |||||
4048 | vkCmdPipelineBarrier(command_buffer[0], | ||||
4049 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
4050 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
4051 | 0, nullptr, 0, nullptr); | ||||
4052 | |||||
4053 | VkViewport viewport{}; | ||||
4054 | viewport.maxDepth = 1.0f; | ||||
4055 | viewport.minDepth = 0.0f; | ||||
4056 | viewport.width = 512; | ||||
4057 | viewport.height = 512; | ||||
4058 | viewport.x = 0; | ||||
4059 | viewport.y = 0; | ||||
4060 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
4061 | vkEndCommandBuffer(command_buffer[0]); | ||||
4062 | } | ||||
4063 | { | ||||
4064 | VkCommandBufferBeginInfo begin_info{}; | ||||
4065 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
4066 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
4067 | |||||
4068 | VkViewport viewport{}; | ||||
4069 | viewport.maxDepth = 1.0f; | ||||
4070 | viewport.minDepth = 0.0f; | ||||
4071 | viewport.width = 512; | ||||
4072 | viewport.height = 512; | ||||
4073 | viewport.x = 0; | ||||
4074 | viewport.y = 0; | ||||
4075 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
4076 | vkEndCommandBuffer(command_buffer[1]); | ||||
4077 | } | ||||
4078 | { | ||||
4079 | VkSubmitInfo submit_info[2]; | ||||
4080 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
4081 | |||||
4082 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
4083 | submit_info[0].pNext = NULL; | ||||
4084 | submit_info[0].commandBufferCount = 1; | ||||
4085 | submit_info[0].pCommandBuffers = &command_buffer[0]; | ||||
4086 | submit_info[0].signalSemaphoreCount = 1; | ||||
4087 | submit_info[0].pSignalSemaphores = &semaphore; | ||||
4088 | submit_info[0].waitSemaphoreCount = 0; | ||||
4089 | submit_info[0].pWaitSemaphores = NULL; | ||||
4090 | submit_info[0].pWaitDstStageMask = 0; | ||||
4091 | |||||
4092 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
4093 | submit_info[1].pNext = NULL; | ||||
4094 | submit_info[1].commandBufferCount = 1; | ||||
4095 | submit_info[1].pCommandBuffers = &command_buffer[1]; | ||||
4096 | submit_info[1].waitSemaphoreCount = 1; | ||||
4097 | submit_info[1].pWaitSemaphores = &semaphore; | ||||
4098 | submit_info[1].pWaitDstStageMask = flags; | ||||
4099 | submit_info[1].signalSemaphoreCount = 0; | ||||
4100 | submit_info[1].pSignalSemaphores = NULL; | ||||
4101 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); | ||||
4102 | } | ||||
4103 | |||||
4104 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
4105 | |||||
4106 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
4107 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
4108 | &command_buffer[0]); | ||||
4109 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4110 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4111 | |
4112 | m_errorMonitor->VerifyNotFound(); | ||||
4113 | } | ||||
4114 | |||||
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4115 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4116 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4117 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
4118 | "state is required but not correctly bound."); | ||||
4119 | |||||
4120 | // Dynamic depth bias | ||||
4121 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4122 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4123 | "Dynamic depth bias state not set for this command buffer"); | ||||
4124 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, | ||||
4125 | BsoFailDepthBias); | ||||
4126 | m_errorMonitor->VerifyFound(); | ||||
4127 | } | ||||
4128 | |||||
4129 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { | ||||
4130 | TEST_DESCRIPTION( | ||||
4131 | "Run a simple draw calls to validate failure when Line Width dynamic " | ||||
4132 | "state is required but not correctly bound."); | ||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4133 | |
4134 | // Dynamic line width | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4135 | m_errorMonitor->SetDesiredFailureMsg( |
4136 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4137 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4138 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
4139 | BsoFailLineWidth); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4140 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4141 | } |
4142 | |||||
4143 | TEST_F(VkLayerTest, DynamicViewportNotBound) { | ||||
4144 | TEST_DESCRIPTION( | ||||
4145 | "Run a simple draw calls to validate failure when Viewport dynamic " | ||||
4146 | "state is required but not correctly bound."); | ||||
4147 | |||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4148 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4149 | m_errorMonitor->SetDesiredFailureMsg( |
4150 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4151 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4152 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
4153 | BsoFailViewport); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4154 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4155 | } |
4156 | |||||
4157 | TEST_F(VkLayerTest, DynamicScissorNotBound) { | ||||
4158 | TEST_DESCRIPTION( | ||||
4159 | "Run a simple draw calls to validate failure when Scissor dynamic " | ||||
4160 | "state is required but not correctly bound."); | ||||
4161 | |||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4162 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4163 | m_errorMonitor->SetDesiredFailureMsg( |
4164 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4165 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4166 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
4167 | BsoFailScissor); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4168 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4169 | } |
4170 | |||||
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4171 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4172 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4173 | "Run a simple draw calls to validate failure when Blend Constants " |
4174 | "dynamic state is required but not correctly bound."); | ||||
4175 | // Dynamic blend constant state | ||||
4176 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4177 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4178 | "Dynamic blend constants state not set for this command buffer"); | ||||
4179 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, | ||||
4180 | BsoFailBlend); | ||||
4181 | m_errorMonitor->VerifyFound(); | ||||
4182 | } | ||||
4183 | |||||
4184 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { | ||||
4185 | TEST_DESCRIPTION( | ||||
4186 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " | ||||
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4187 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 4188 | if (!m_device->phy().features().depthBounds) { |
4189 | printf("Device does not support depthBounds test; skipped.\n"); | ||||
4190 | return; | ||||
4191 | } | ||||
4192 | // Dynamic depth bounds | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4193 | m_errorMonitor->SetDesiredFailureMsg( |
4194 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4195 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4196 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
4197 | BsoFailDepthBounds); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4198 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4199 | } |
4200 | |||||
4201 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { | ||||
4202 | TEST_DESCRIPTION( | ||||
4203 | "Run a simple draw calls to validate failure when Stencil Read dynamic " | ||||
4204 | "state is required but not correctly bound."); | ||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4205 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4206 | m_errorMonitor->SetDesiredFailureMsg( |
4207 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4208 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4209 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
4210 | BsoFailStencilReadMask); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4211 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4212 | } |
4213 | |||||
4214 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { | ||||
4215 | TEST_DESCRIPTION( | ||||
4216 | "Run a simple draw calls to validate failure when Stencil Write dynamic" | ||||
4217 | " state is required but not correctly bound."); | ||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4218 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4219 | m_errorMonitor->SetDesiredFailureMsg( |
4220 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4221 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4222 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
4223 | BsoFailStencilWriteMask); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4224 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4225 | } |
4226 | |||||
4227 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { | ||||
4228 | TEST_DESCRIPTION( | ||||
4229 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " | ||||
4230 | "state is required but not correctly bound."); | ||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4231 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4232 | m_errorMonitor->SetDesiredFailureMsg( |
4233 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4234 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4235 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
4236 | BsoFailStencilReference); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4237 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 4238 | } |
4239 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4240 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4241 | m_errorMonitor->SetDesiredFailureMsg( |
4242 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4243 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " | ||||
4244 | "been submitted"); | ||||
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4245 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4246 | ASSERT_NO_FATAL_FAILURE(InitState()); |
4247 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
4248 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
4249 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4250 | // We luck out b/c by default the framework creates CB w/ the |
4251 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set | ||||
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4252 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4253 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
4254 | m_stencil_clear_color, NULL); | ||||
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4255 | EndCommandBuffer(); |
4256 | |||||
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4257 | // Bypass framework since it does the waits automatically |
4258 | VkResult err = VK_SUCCESS; | ||||
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4259 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 4260 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
4261 | submit_info.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4262 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4263 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 4264 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4265 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4266 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4267 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4268 | submit_info.pSignalSemaphores = NULL; |
4269 | |||||
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 4270 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4271 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4272 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4273 | // Cause validation error by re-submitting cmd buffer that should only be |
4274 | // submitted once | ||||
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 4275 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4276 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4277 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4278 | } |
4279 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4280 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4281 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4282 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4283 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4284 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4285 | "Unable to allocate 1 descriptors of " |
4286 | "type " | ||||
4287 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4288 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4289 | ASSERT_NO_FATAL_FAILURE(InitState()); |
4290 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4291 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4292 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
4293 | // descriptor from it | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4294 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4295 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
4296 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4297 | |
4298 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4299 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
4300 | ds_pool_ci.pNext = NULL; | ||||
4301 | ds_pool_ci.flags = 0; | ||||
4302 | ds_pool_ci.maxSets = 1; | ||||
4303 | ds_pool_ci.poolSizeCount = 1; | ||||
4304 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4305 | |
4306 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4307 | err = |
4308 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4309 | ASSERT_VK_SUCCESS(err); |
4310 | |||||
4311 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4312 | dsl_binding.binding = 0; |
4313 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
4314 | dsl_binding.descriptorCount = 1; | ||||
4315 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
4316 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4317 | |
4318 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4319 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
4320 | ds_layout_ci.pNext = NULL; | ||||
4321 | ds_layout_ci.bindingCount = 1; | ||||
4322 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4323 | |
4324 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4325 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
4326 | &ds_layout); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4327 | ASSERT_VK_SUCCESS(err); |
4328 | |||||
4329 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4330 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4331 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4332 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4333 | alloc_info.descriptorPool = ds_pool; |
4334 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4335 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
4336 | &descriptorSet); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4337 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4338 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4339 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4340 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
4341 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4342 | } |
4343 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4344 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
4345 | VkResult err; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4346 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4347 | m_errorMonitor->SetDesiredFailureMsg( |
4348 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4349 | "It is invalid to call vkFreeDescriptorSets() with a pool created " | ||||
4350 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4351 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4352 | ASSERT_NO_FATAL_FAILURE(InitState()); |
4353 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4354 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4355 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4356 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
4357 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4358 | |
4359 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4360 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
4361 | ds_pool_ci.pNext = NULL; | ||||
4362 | ds_pool_ci.maxSets = 1; | ||||
4363 | ds_pool_ci.poolSizeCount = 1; | ||||
4364 | ds_pool_ci.flags = 0; | ||||
4365 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means | ||||
4366 | // app can only call vkResetDescriptorPool on this pool.; | ||||
4367 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4368 | |
4369 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4370 | err = |
4371 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4372 | ASSERT_VK_SUCCESS(err); |
4373 | |||||
4374 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4375 | dsl_binding.binding = 0; |
4376 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
4377 | dsl_binding.descriptorCount = 1; | ||||
4378 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
4379 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4380 | |
4381 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4382 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
4383 | ds_layout_ci.pNext = NULL; | ||||
4384 | ds_layout_ci.bindingCount = 1; | ||||
4385 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4386 | |
4387 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4388 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
4389 | &ds_layout); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4390 | ASSERT_VK_SUCCESS(err); |
4391 | |||||
4392 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4393 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4394 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4395 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4396 | alloc_info.descriptorPool = ds_pool; |
4397 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4398 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
4399 | &descriptorSet); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4400 | ASSERT_VK_SUCCESS(err); |
4401 | |||||
4402 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4403 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4404 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4405 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
4406 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4407 | } |
4408 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4409 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4410 | // Attempt to clear Descriptor Pool with bad object. |
4411 | // ObjectTracker should catch this. | ||||
4412 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4413 | "Invalid VkDescriptorPool Object 0xbaad6001"); | ||||
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4414 | uint64_t fake_pool_handle = 0xbaad6001; |
4415 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); | ||||
4416 | vkResetDescriptorPool(device(), bad_pool, 0); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4417 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4418 | } |
4419 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4420 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4421 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
4422 | // ObjectTracker should catch this. | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4423 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4424 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4425 | |
4426 | uint64_t fake_set_handle = 0xbaad6001; | ||||
4427 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4428 | VkResult err; |
4429 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4430 | "Invalid VkDescriptorSet Object 0xbaad6001"); | ||||
4431 | |||||
4432 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4433 | |||||
4434 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; | ||||
4435 | layout_bindings[0].binding = 0; | ||||
4436 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
4437 | layout_bindings[0].descriptorCount = 1; | ||||
4438 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; | ||||
4439 | layout_bindings[0].pImmutableSamplers = NULL; | ||||
4440 | |||||
4441 | VkDescriptorSetLayout descriptor_set_layout; | ||||
4442 | VkDescriptorSetLayoutCreateInfo dslci = {}; | ||||
4443 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
4444 | dslci.pNext = NULL; | ||||
4445 | dslci.bindingCount = 1; | ||||
4446 | dslci.pBindings = layout_bindings; | ||||
4447 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); | ||||
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4448 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4449 | |
4450 | VkPipelineLayout pipeline_layout; | ||||
4451 | VkPipelineLayoutCreateInfo plci = {}; | ||||
4452 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
4453 | plci.pNext = NULL; | ||||
4454 | plci.setLayoutCount = 1; | ||||
4455 | plci.pSetLayouts = &descriptor_set_layout; | ||||
4456 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); | ||||
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4457 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4458 | |
4459 | BeginCommandBuffer(); | ||||
4460 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4461 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4462 | m_errorMonitor->VerifyFound(); |
4463 | EndCommandBuffer(); | ||||
4464 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); | ||||
4465 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4466 | } |
4467 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4468 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4469 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
4470 | // ObjectTracker should catch this. | ||||
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4471 | uint64_t fake_layout_handle = 0xbaad6001; |
4472 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4473 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
4474 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); | ||||
4475 | |||||
4476 | VkPipelineLayout pipeline_layout; | ||||
4477 | VkPipelineLayoutCreateInfo plci = {}; | ||||
4478 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
4479 | plci.pNext = NULL; | ||||
4480 | plci.setLayoutCount = 1; | ||||
4481 | plci.pSetLayouts = &bad_layout; | ||||
4482 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); | ||||
4483 | |||||
4484 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4485 | } |
4486 | |||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4487 | TEST_F(VkLayerTest, WriteDescriptorSetIntegrityCheck) { |
4488 | TEST_DESCRIPTION("This test verifies some requirements of chapter 13.2.3 of the Vulkan Spec " | ||||
4489 | "1) A uniform buffer update must have a valid buffer index." | ||||
4490 | "2) When using an array of descriptors in a single WriteDescriptor," | ||||
4491 | " the descriptor types and stageflags must all be the same." | ||||
4492 | "3) Immutable Sampler state must match across descriptors"); | ||||
4493 | |||||
4494 | const char *invalid_BufferInfo_ErrorMessage = | ||||
4495 | "vkUpdateDescriptorSets: if pDescriptorWrites[0].descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, " | ||||
4496 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or " | ||||
4497 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pDescriptorWrites[0].pBufferInfo must not be NULL"; | ||||
4498 | const char *stateFlag_ErrorMessage = | ||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame^] | 4499 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4500 | const char *immutable_ErrorMessage = |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame^] | 4501 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4502 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4503 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, invalid_BufferInfo_ErrorMessage); |
4504 | |||||
4505 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4506 | VkDescriptorPoolSize ds_type_count[4] = {}; | ||||
4507 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
4508 | ds_type_count[0].descriptorCount = 1; | ||||
4509 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; | ||||
4510 | ds_type_count[1].descriptorCount = 1; | ||||
4511 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; | ||||
4512 | ds_type_count[2].descriptorCount = 1; | ||||
4513 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; | ||||
4514 | ds_type_count[3].descriptorCount = 1; | ||||
4515 | |||||
4516 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
4517 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
4518 | ds_pool_ci.maxSets = 1; | ||||
4519 | ds_pool_ci.poolSizeCount = sizeof(ds_type_count) / sizeof(VkDescriptorPoolSize); | ||||
4520 | ds_pool_ci.pPoolSizes = ds_type_count; | ||||
4521 | |||||
4522 | VkDescriptorPool ds_pool; | ||||
4523 | VkResult err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
4524 | ASSERT_VK_SUCCESS(err); | ||||
4525 | |||||
Mark Mueller | b989672 | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 4526 | VkDescriptorSetLayoutBinding layout_binding[3] = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4527 | layout_binding[0].binding = 0; |
4528 | layout_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
4529 | layout_binding[0].descriptorCount = 1; | ||||
4530 | layout_binding[0].stageFlags = VK_SHADER_STAGE_ALL; | ||||
4531 | layout_binding[0].pImmutableSamplers = NULL; | ||||
4532 | |||||
4533 | layout_binding[1].binding = 1; | ||||
4534 | layout_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
4535 | layout_binding[1].descriptorCount = 1; | ||||
4536 | layout_binding[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; | ||||
4537 | layout_binding[1].pImmutableSamplers = NULL; | ||||
4538 | |||||
4539 | VkSamplerCreateInfo sampler_ci = {}; | ||||
4540 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; | ||||
4541 | sampler_ci.pNext = NULL; | ||||
4542 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
4543 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
4544 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
4545 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
4546 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
4547 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
4548 | sampler_ci.mipLodBias = 1.0; | ||||
4549 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
4550 | sampler_ci.maxAnisotropy = 1; | ||||
4551 | sampler_ci.compareEnable = VK_FALSE; | ||||
4552 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
4553 | sampler_ci.minLod = 1.0; | ||||
4554 | sampler_ci.maxLod = 1.0; | ||||
4555 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
4556 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
4557 | VkSampler sampler; | ||||
4558 | |||||
4559 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); | ||||
4560 | ASSERT_VK_SUCCESS(err); | ||||
4561 | |||||
4562 | layout_binding[2].binding = 2; | ||||
4563 | layout_binding[2].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
4564 | layout_binding[2].descriptorCount = 1; | ||||
4565 | layout_binding[2].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; | ||||
4566 | layout_binding[2].pImmutableSamplers = static_cast<VkSampler *>(&sampler); | ||||
4567 | |||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4568 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
4569 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
4570 | ds_layout_ci.bindingCount = sizeof(layout_binding) / sizeof(VkDescriptorSetLayoutBinding); | ||||
4571 | ds_layout_ci.pBindings = layout_binding; | ||||
4572 | VkDescriptorSetLayout ds_layout; | ||||
4573 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); | ||||
4574 | ASSERT_VK_SUCCESS(err); | ||||
4575 | |||||
4576 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
4577 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
4578 | alloc_info.descriptorSetCount = 1; | ||||
4579 | alloc_info.descriptorPool = ds_pool; | ||||
4580 | alloc_info.pSetLayouts = &ds_layout; | ||||
4581 | VkDescriptorSet descriptorSet; | ||||
4582 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); | ||||
4583 | ASSERT_VK_SUCCESS(err); | ||||
4584 | |||||
4585 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
4586 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
4587 | pipeline_layout_ci.pNext = NULL; | ||||
4588 | pipeline_layout_ci.setLayoutCount = 1; | ||||
4589 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
4590 | |||||
4591 | VkPipelineLayout pipeline_layout; | ||||
4592 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); | ||||
4593 | ASSERT_VK_SUCCESS(err); | ||||
4594 | |||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame^] | 4595 | VkWriteDescriptorSet descriptor_write = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4596 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
4597 | descriptor_write.dstSet = descriptorSet; | ||||
4598 | descriptor_write.dstBinding = 0; | ||||
4599 | descriptor_write.descriptorCount = 1; | ||||
4600 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
4601 | |||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame^] | 4602 | // 1) The uniform buffer is intentionally invalid here |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4603 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
4604 | m_errorMonitor->VerifyFound(); | ||||
4605 | |||||
4606 | // Create a buffer to update the descriptor with | ||||
4607 | uint32_t qfi = 0; | ||||
4608 | VkBufferCreateInfo buffCI = {}; | ||||
4609 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
4610 | buffCI.size = 1024; | ||||
4611 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
4612 | buffCI.queueFamilyIndexCount = 1; | ||||
4613 | buffCI.pQueueFamilyIndices = &qfi; | ||||
4614 | |||||
4615 | VkBuffer dyub; | ||||
4616 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); | ||||
4617 | ASSERT_VK_SUCCESS(err); | ||||
4618 | VkDescriptorBufferInfo buffInfo = {}; | ||||
4619 | buffInfo.buffer = dyub; | ||||
4620 | buffInfo.offset = 0; | ||||
4621 | buffInfo.range = 1024; | ||||
4622 | |||||
4623 | descriptor_write.pBufferInfo = &buffInfo; | ||||
4624 | descriptor_write.descriptorCount = 2; | ||||
4625 | |||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame^] | 4626 | // 2) The stateFlags don't match between the first and second descriptor |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4627 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, stateFlag_ErrorMessage); |
4628 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
4629 | m_errorMonitor->VerifyFound(); | ||||
4630 | |||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame^] | 4631 | // 3) The second descriptor has a null_ptr pImmutableSamplers and |
4632 | // the third descriptor contains an immutable sampler | ||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4633 | descriptor_write.dstBinding = 1; |
4634 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame^] | 4635 | |
4636 | |||||
4637 | // Make pImageInfo index non-null to avoid complaints of it missing | ||||
4638 | VkDescriptorImageInfo imageInfo = {}; | ||||
4639 | imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
4640 | descriptor_write.pImageInfo = &imageInfo; | ||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4641 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, immutable_ErrorMessage); |
4642 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
4643 | m_errorMonitor->VerifyFound(); | ||||
4644 | |||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 4645 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
4646 | vkDestroySampler(m_device->device(), sampler, NULL); | ||||
4647 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
4648 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
4649 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
4650 | } | ||||
4651 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4652 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4653 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
4654 | // ObjectTracker should catch this. | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4655 | // Create a valid cmd buffer |
4656 | // call vkCmdBindPipeline w/ false Pipeline | ||||
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4657 | uint64_t fake_pipeline_handle = 0xbaad6001; |
4658 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4659 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
4660 | "Invalid VkPipeline Object 0xbaad6001"); | ||||
4661 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4662 | BeginCommandBuffer(); | ||||
4663 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
4664 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); | ||||
4665 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4666 | // Now issue a draw call with no pipeline bound |
4667 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4668 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4669 | "At Draw/Dispatch time no valid VkPipeline is bound!"); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 4670 | |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4671 | BeginCommandBuffer(); |
4672 | Draw(1, 0, 0, 0); | ||||
4673 | m_errorMonitor->VerifyFound(); | ||||
4674 | // Finally same check once more but with Dispatch/Compute | ||||
4675 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4676 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4677 | "At Draw/Dispatch time no valid VkPipeline is bound!"); | ||||
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4678 | BeginCommandBuffer(); |
4679 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); | ||||
4680 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4681 | } |
4682 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4683 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
4684 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on | ||||
4685 | // CommandBuffer | ||||
4686 | VkResult err; | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4687 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4688 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4689 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4690 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4691 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4692 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
4693 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4694 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4695 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
4696 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4697 | |
4698 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4699 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
4700 | ds_pool_ci.pNext = NULL; | ||||
4701 | ds_pool_ci.maxSets = 1; | ||||
4702 | ds_pool_ci.poolSizeCount = 1; | ||||
4703 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4704 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4705 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4706 | err = |
4707 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4708 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4709 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4710 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4711 | dsl_binding.binding = 0; |
4712 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
4713 | dsl_binding.descriptorCount = 1; | ||||
4714 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
4715 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4716 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4717 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4718 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
4719 | ds_layout_ci.pNext = NULL; | ||||
4720 | ds_layout_ci.bindingCount = 1; | ||||
4721 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4722 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4723 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
4724 | &ds_layout); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4725 | ASSERT_VK_SUCCESS(err); |
4726 | |||||
4727 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4728 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4729 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4730 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4731 | alloc_info.descriptorPool = ds_pool; |
4732 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4733 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
4734 | &descriptorSet); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4735 | ASSERT_VK_SUCCESS(err); |
4736 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4737 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4738 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
4739 | pipeline_layout_ci.pNext = NULL; | ||||
4740 | pipeline_layout_ci.setLayoutCount = 1; | ||||
4741 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4742 | |
4743 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4744 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
4745 | &pipeline_layout); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4746 | ASSERT_VK_SUCCESS(err); |
4747 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4748 | VkShaderObj vs(m_device, bindStateVertShaderText, |
4749 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4750 | // 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] | 4751 | // on more devices |
4752 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
4753 | VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4754 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4755 | VkPipelineObj pipe(m_device); |
4756 | pipe.AddShader(&vs); | ||||
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4757 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4758 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4759 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4760 | |
4761 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4762 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
4763 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
4764 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
4765 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
4766 | 1, &descriptorSet, 0, NULL); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4767 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4768 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4769 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4770 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
4771 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
4772 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4773 | } |
4774 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4775 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4776 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4777 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4778 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4779 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4780 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
4781 | "descriptor with invalid buffer view"); | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4782 | |
4783 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4784 | VkDescriptorPoolSize ds_type_count = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4785 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
4786 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4787 | |
4788 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4789 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
4790 | ds_pool_ci.pNext = NULL; | ||||
4791 | ds_pool_ci.maxSets = 1; | ||||
4792 | ds_pool_ci.poolSizeCount = 1; | ||||
4793 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4794 | |
4795 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4796 | err = |
4797 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4798 | ASSERT_VK_SUCCESS(err); |
4799 | |||||
4800 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4801 | dsl_binding.binding = 0; |
4802 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; | ||||
4803 | dsl_binding.descriptorCount = 1; | ||||
4804 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
4805 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4806 | |
4807 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4808 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
4809 | ds_layout_ci.pNext = NULL; | ||||
4810 | ds_layout_ci.bindingCount = 1; | ||||
4811 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4812 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4813 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
4814 | &ds_layout); | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4815 | ASSERT_VK_SUCCESS(err); |
4816 | |||||
4817 | VkDescriptorSet descriptorSet; | ||||
4818 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4819 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4820 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4821 | alloc_info.descriptorPool = ds_pool; |
4822 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4823 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
4824 | &descriptorSet); | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4825 | ASSERT_VK_SUCCESS(err); |
4826 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4827 | VkBufferView view = |
4828 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4829 | VkWriteDescriptorSet descriptor_write; |
4830 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
4831 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
4832 | descriptor_write.dstSet = descriptorSet; | ||||
4833 | descriptor_write.dstBinding = 0; | ||||
4834 | descriptor_write.descriptorCount = 1; | ||||
4835 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; | ||||
4836 | descriptor_write.pTexelBufferView = &view; | ||||
4837 | |||||
4838 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
4839 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4840 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4841 | |
4842 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
4843 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
4844 | } | ||||
4845 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4846 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
4847 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error | ||||
4848 | // cases: | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4849 | // 1. No dynamicOffset supplied |
4850 | // 2. Too many dynamicOffsets supplied | ||||
4851 | // 3. Dynamic offset oversteps buffer being updated | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4852 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4853 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4854 | " requires 1 dynamicOffsets, but only " |
4855 | "0 dynamicOffsets are left in " | ||||
4856 | "pDynamicOffsets "); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4857 | |
4858 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4859 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
4860 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
4861 | |||||
4862 | VkDescriptorPoolSize ds_type_count = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4863 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
4864 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4865 | |
4866 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4867 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
4868 | ds_pool_ci.pNext = NULL; | ||||
4869 | ds_pool_ci.maxSets = 1; | ||||
4870 | ds_pool_ci.poolSizeCount = 1; | ||||
4871 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4872 | |
4873 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4874 | err = |
4875 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4876 | ASSERT_VK_SUCCESS(err); |
4877 | |||||
4878 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4879 | dsl_binding.binding = 0; |
4880 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; | ||||
4881 | dsl_binding.descriptorCount = 1; | ||||
4882 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
4883 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4884 | |
4885 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4886 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
4887 | ds_layout_ci.pNext = NULL; | ||||
4888 | ds_layout_ci.bindingCount = 1; | ||||
4889 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4890 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4891 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
4892 | &ds_layout); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4893 | ASSERT_VK_SUCCESS(err); |
4894 | |||||
4895 | VkDescriptorSet descriptorSet; | ||||
4896 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4897 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4898 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4899 | alloc_info.descriptorPool = ds_pool; |
4900 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4901 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
4902 | &descriptorSet); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4903 | ASSERT_VK_SUCCESS(err); |
4904 | |||||
4905 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4906 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
4907 | pipeline_layout_ci.pNext = NULL; | ||||
4908 | pipeline_layout_ci.setLayoutCount = 1; | ||||
4909 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4910 | |
4911 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4912 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
4913 | &pipeline_layout); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4914 | ASSERT_VK_SUCCESS(err); |
4915 | |||||
4916 | // Create a buffer to update the descriptor with | ||||
4917 | uint32_t qfi = 0; | ||||
4918 | VkBufferCreateInfo buffCI = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4919 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
4920 | buffCI.size = 1024; | ||||
4921 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
4922 | buffCI.queueFamilyIndexCount = 1; | ||||
4923 | buffCI.pQueueFamilyIndices = &qfi; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4924 | |
4925 | VkBuffer dyub; | ||||
4926 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); | ||||
4927 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4928 | // Allocate memory and bind to buffer so we can make it to the appropriate |
4929 | // error | ||||
4930 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
4931 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
4932 | mem_alloc.pNext = NULL; | ||||
4933 | mem_alloc.allocationSize = 1024; | ||||
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 4934 | mem_alloc.memoryTypeIndex = 0; |
4935 | |||||
4936 | VkMemoryRequirements memReqs; | ||||
4937 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); | ||||
4938 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, | ||||
4939 | 0); | ||||
4940 | if (!pass) { | ||||
4941 | vkDestroyBuffer(m_device->device(), dyub, NULL); | ||||
4942 | return; | ||||
4943 | } | ||||
4944 | |||||
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4945 | VkDeviceMemory mem; |
4946 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); | ||||
4947 | ASSERT_VK_SUCCESS(err); | ||||
4948 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); | ||||
4949 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4950 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
4951 | VkDescriptorBufferInfo buffInfo = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4952 | buffInfo.buffer = dyub; |
4953 | buffInfo.offset = 0; | ||||
4954 | buffInfo.range = 1024; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4955 | |
4956 | VkWriteDescriptorSet descriptor_write; | ||||
4957 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
4958 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
4959 | descriptor_write.dstSet = descriptorSet; | ||||
4960 | descriptor_write.dstBinding = 0; | ||||
4961 | descriptor_write.descriptorCount = 1; | ||||
4962 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; | ||||
4963 | descriptor_write.pBufferInfo = &buffInfo; | ||||
4964 | |||||
4965 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
4966 | |||||
4967 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4968 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
4969 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
4970 | 1, &descriptorSet, 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4971 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4972 | uint32_t pDynOff[2] = {512, 756}; |
4973 | // 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] | 4974 | m_errorMonitor->SetDesiredFailureMsg( |
4975 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4976 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4977 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
4978 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
4979 | 1, &descriptorSet, 2, pDynOff); | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4980 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4981 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4982 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
4983 | " dynamic offset 512 combined with " | ||||
4984 | "offset 0 and range 1024 that " | ||||
4985 | "oversteps the buffer size of 1024"); | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4986 | // Create PSO to be used for draw-time errors below |
4987 | char const *vsSource = | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4988 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4989 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4990 | "out gl_PerVertex { \n" |
4991 | " vec4 gl_Position;\n" | ||||
4992 | "};\n" | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4993 | "void main(){\n" |
4994 | " gl_Position = vec4(1);\n" | ||||
4995 | "}\n"; | ||||
4996 | char const *fsSource = | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4997 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4998 | "\n" |
4999 | "layout(location=0) out vec4 x;\n" | ||||
5000 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" | ||||
5001 | "void main(){\n" | ||||
5002 | " x = vec4(bar.y);\n" | ||||
5003 | "}\n"; | ||||
5004 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
5005 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
5006 | VkPipelineObj pipe(m_device); | ||||
5007 | pipe.AddShader(&vs); | ||||
5008 | pipe.AddShader(&fs); | ||||
5009 | pipe.AddColorAttachment(); | ||||
5010 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
5011 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5012 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
5013 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
5014 | // This update should succeed, but offset size of 512 will overstep buffer | ||||
5015 | // /w range 1024 & size 1024 | ||||
5016 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
5017 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
5018 | 1, &descriptorSet, 1, pDynOff); | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 5019 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5020 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5021 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5022 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 5023 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5024 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5025 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5026 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 5027 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
5028 | } | ||||
5029 | |||||
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5030 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5031 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5032 | ASSERT_NO_FATAL_FAILURE(InitState()); |
5033 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
5034 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
5035 | |||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5036 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5037 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5038 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
5039 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
5040 | pipeline_layout_ci.pushConstantRangeCount = 1; | ||||
5041 | pipeline_layout_ci.pPushConstantRanges = &pc_range; | ||||
5042 | |||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5043 | // |
5044 | // Check for invalid push constant ranges in pipeline layouts. | ||||
5045 | // | ||||
5046 | struct PipelineLayoutTestCase { | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5047 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5048 | char const *msg; |
5049 | }; | ||||
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5050 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5051 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
5052 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ | ||||
5053 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, | ||||
5054 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
5055 | "size 0."}, | ||||
5056 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, | ||||
5057 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
5058 | "size 1."}, | ||||
5059 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, | ||||
5060 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
5061 | "size 1."}, | ||||
5062 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, | ||||
5063 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
5064 | "size 0."}, | ||||
5065 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, | ||||
5066 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
5067 | "offset 1. Offset must"}, | ||||
5068 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, | ||||
5069 | "vkCreatePipelineLayout() call has push constants index 0 " | ||||
5070 | "with offset "}, | ||||
5071 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, | ||||
5072 | "vkCreatePipelineLayout() call has push constants " | ||||
5073 | "index 0 with offset "}, | ||||
5074 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, | ||||
5075 | "vkCreatePipelineLayout() call has push constants index 0 " | ||||
5076 | "with offset "}, | ||||
5077 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, | ||||
5078 | "vkCreatePipelineLayout() call has push " | ||||
5079 | "constants index 0 with offset "}, | ||||
5080 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, | ||||
5081 | "vkCreatePipelineLayout() call has push " | ||||
5082 | "constants index 0 with offset "}, | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5083 | }}; |
5084 | |||||
5085 | // Check for invalid offset and size | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5086 | for (const auto &iter : range_tests) { |
5087 | pc_range = iter.range; | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5088 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
5089 | iter.msg); | ||||
5090 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, | ||||
5091 | NULL, &pipeline_layout); | ||||
5092 | m_errorMonitor->VerifyFound(); | ||||
5093 | if (VK_SUCCESS == err) { | ||||
5094 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
5095 | } | ||||
5096 | } | ||||
5097 | |||||
5098 | // Check for invalid stage flag | ||||
5099 | pc_range.offset = 0; | ||||
5100 | pc_range.size = 16; | ||||
5101 | pc_range.stageFlags = 0; | ||||
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5102 | m_errorMonitor->SetDesiredFailureMsg( |
5103 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5104 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5105 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
5106 | &pipeline_layout); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5107 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5108 | if (VK_SUCCESS == err) { |
5109 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
5110 | } | ||||
5111 | |||||
5112 | // Check for overlapping ranges | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5113 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5114 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5115 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5116 | char const *msg; |
5117 | }; | ||||
5118 | |||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5119 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5120 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
5121 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
5122 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
5123 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
5124 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, | ||||
5125 | "vkCreatePipelineLayout() call has push constants with overlapping " | ||||
5126 | "ranges: 0:[0, 4), 1:[0, 4)"}, | ||||
5127 | { | ||||
5128 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
5129 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, | ||||
5130 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, | ||||
5131 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, | ||||
5132 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, | ||||
5133 | "vkCreatePipelineLayout() call has push constants with " | ||||
5134 | "overlapping " | ||||
5135 | "ranges: 3:[12, 20), 4:[16, 20)", | ||||
5136 | }, | ||||
5137 | { | ||||
5138 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, | ||||
5139 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, | ||||
5140 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, | ||||
5141 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, | ||||
5142 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, | ||||
5143 | "vkCreatePipelineLayout() call has push constants with " | ||||
5144 | "overlapping " | ||||
5145 | "ranges: 0:[16, 20), 1:[12, 20)", | ||||
5146 | }, | ||||
5147 | { | ||||
5148 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, | ||||
5149 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, | ||||
5150 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, | ||||
5151 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, | ||||
5152 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, | ||||
5153 | "vkCreatePipelineLayout() call has push constants with " | ||||
5154 | "overlapping " | ||||
5155 | "ranges: 0:[16, 20), 3:[12, 20)", | ||||
5156 | }, | ||||
5157 | { | ||||
5158 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, | ||||
5159 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, | ||||
5160 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, | ||||
5161 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, | ||||
5162 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, | ||||
5163 | "vkCreatePipelineLayout() call has push constants with " | ||||
5164 | "overlapping " | ||||
5165 | "ranges: 0:[16, 20), 2:[4, 100)", | ||||
5166 | }}}; | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5167 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5168 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5169 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5170 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
5171 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5172 | iter.msg); |
5173 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, | ||||
5174 | NULL, &pipeline_layout); | ||||
5175 | m_errorMonitor->VerifyFound(); | ||||
5176 | if (VK_SUCCESS == err) { | ||||
5177 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
5178 | } | ||||
5179 | } | ||||
5180 | |||||
5181 | // 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] | 5182 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
5183 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
5184 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, | ||||
5185 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, | ||||
5186 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, | ||||
5187 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, | ||||
5188 | ""}, | ||||
5189 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, | ||||
5190 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, | ||||
5191 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, | ||||
5192 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, | ||||
5193 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, | ||||
5194 | ""}}}; | ||||
5195 | for (const auto &iter : overlapping_range_tests_pos) { | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5196 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
5197 | m_errorMonitor->ExpectSuccess(); | ||||
5198 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, | ||||
5199 | NULL, &pipeline_layout); | ||||
5200 | m_errorMonitor->VerifyNotFound(); | ||||
5201 | if (VK_SUCCESS == err) { | ||||
5202 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
5203 | } | ||||
5204 | } | ||||
5205 | |||||
5206 | // | ||||
5207 | // CmdPushConstants tests | ||||
5208 | // | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5209 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5210 | |
5211 | // 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] | 5212 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
5213 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, | ||||
5214 | "vkCmdPushConstants() call has push constants with size 0. Size " | ||||
5215 | "must be greater than zero and a multiple of 4."}, | ||||
5216 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, | ||||
5217 | "vkCmdPushConstants() call has push constants with size 1. Size " | ||||
5218 | "must be greater than zero and a multiple of 4."}, | ||||
5219 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, | ||||
5220 | "vkCmdPushConstants() call has push constants with size 1. Size " | ||||
5221 | "must be greater than zero and a multiple of 4."}, | ||||
5222 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, | ||||
5223 | "vkCmdPushConstants() call has push constants with offset 1. " | ||||
5224 | "Offset must be a multiple of 4."}, | ||||
5225 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, | ||||
5226 | "vkCmdPushConstants() call has push constants with offset 1. " | ||||
5227 | "Offset must be a multiple of 4."}, | ||||
5228 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, | ||||
5229 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " | ||||
5230 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
5231 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, | ||||
5232 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " | ||||
5233 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
5234 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, | ||||
5235 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " | ||||
5236 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
5237 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, | ||||
5238 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " | ||||
5239 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
5240 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, | ||||
5241 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " | ||||
5242 | "any of the ranges in pipeline layout"}, | ||||
5243 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, | ||||
5244 | 0, 16}, | ||||
5245 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " | ||||
5246 | "any of the ranges in pipeline layout"}, | ||||
5247 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5248 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5249 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5250 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5251 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5252 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5253 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5254 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5255 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5256 | "vkCmdPushConstants() call has push constants with offset "}, |
5257 | }}; | ||||
5258 | |||||
5259 | // Two ranges for testing robustness | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5260 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5261 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5262 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5263 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5264 | pipeline_layout_ci.pushConstantRangeCount = |
5265 | sizeof(pc_range2) / sizeof(VkPushConstantRange); | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5266 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5267 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
5268 | &pipeline_layout); | ||||
5269 | ASSERT_VK_SUCCESS(err); | ||||
5270 | BeginCommandBuffer(); | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5271 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5272 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
5273 | iter.msg); | ||||
5274 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5275 | iter.range.stageFlags, iter.range.offset, |
5276 | iter.range.size, dummy_values); | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5277 | m_errorMonitor->VerifyFound(); |
5278 | } | ||||
5279 | |||||
5280 | // Check for invalid stage flag | ||||
5281 | m_errorMonitor->SetDesiredFailureMsg( | ||||
5282 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
5283 | "vkCmdPushConstants() call has no stageFlags set."); | ||||
5284 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5285 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5286 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5287 | EndCommandBuffer(); |
5288 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); | ||||
5289 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 5290 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 5291 | // overlapping range tests with cmd |
5292 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ | ||||
5293 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, | ||||
5294 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " | ||||
5295 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
5296 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, | ||||
5297 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " | ||||
5298 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
5299 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, | ||||
5300 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " | ||||
5301 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
5302 | }}; | ||||
5303 | const VkPushConstantRange pc_range3[] = { | ||||
5304 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, | ||||
5305 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, | ||||
5306 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
5307 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, | ||||
5308 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, | ||||
5309 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, | ||||
5310 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, | ||||
5311 | }; | ||||
5312 | pipeline_layout_ci.pushConstantRangeCount = | ||||
5313 | sizeof(pc_range3) / sizeof(VkPushConstantRange); | ||||
5314 | pipeline_layout_ci.pPushConstantRanges = pc_range3; | ||||
5315 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
5316 | &pipeline_layout); | ||||
5317 | ASSERT_VK_SUCCESS(err); | ||||
5318 | BeginCommandBuffer(); | ||||
5319 | for (const auto &iter : cmd_overlap_tests) { | ||||
5320 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
5321 | iter.msg); | ||||
5322 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, | ||||
5323 | iter.range.stageFlags, iter.range.offset, | ||||
5324 | iter.range.size, dummy_values); | ||||
5325 | m_errorMonitor->VerifyFound(); | ||||
5326 | } | ||||
5327 | EndCommandBuffer(); | ||||
5328 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); | ||||
5329 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
5330 | |||||
5331 | // positive overlapping range tests with cmd | ||||
5332 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ | ||||
5333 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, | ||||
5334 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, | ||||
5335 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, | ||||
5336 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, | ||||
5337 | }}; | ||||
5338 | const VkPushConstantRange pc_range4[] = { | ||||
5339 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, | ||||
5340 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, | ||||
5341 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, | ||||
5342 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
5343 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, | ||||
5344 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, | ||||
5345 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, | ||||
5346 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, | ||||
5347 | }; | ||||
5348 | pipeline_layout_ci.pushConstantRangeCount = | ||||
5349 | sizeof(pc_range4) / sizeof(VkPushConstantRange); | ||||
5350 | pipeline_layout_ci.pPushConstantRanges = pc_range4; | ||||
5351 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
5352 | &pipeline_layout); | ||||
5353 | ASSERT_VK_SUCCESS(err); | ||||
5354 | BeginCommandBuffer(); | ||||
5355 | for (const auto &iter : cmd_overlap_tests_pos) { | ||||
5356 | m_errorMonitor->ExpectSuccess(); | ||||
5357 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, | ||||
5358 | iter.range.stageFlags, iter.range.offset, | ||||
5359 | iter.range.size, dummy_values); | ||||
5360 | m_errorMonitor->VerifyNotFound(); | ||||
5361 | } | ||||
5362 | EndCommandBuffer(); | ||||
5363 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); | ||||
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5364 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
5365 | } | ||||
5366 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5367 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5368 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5369 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5370 | |
5371 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
5372 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
5373 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
5374 | |||||
5375 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; | ||||
5376 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5377 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
5378 | ds_type_count[0].descriptorCount = 10; | ||||
5379 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
5380 | ds_type_count[1].descriptorCount = 2; | ||||
5381 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; | ||||
5382 | ds_type_count[2].descriptorCount = 2; | ||||
5383 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
5384 | ds_type_count[3].descriptorCount = 5; | ||||
5385 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT | ||||
5386 | // type | ||||
5387 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; | ||||
5388 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; | ||||
5389 | ds_type_count[4].descriptorCount = 2; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5390 | |
5391 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5392 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
5393 | ds_pool_ci.pNext = NULL; | ||||
5394 | ds_pool_ci.maxSets = 5; | ||||
5395 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; | ||||
5396 | ds_pool_ci.pPoolSizes = ds_type_count; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5397 | |
5398 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5399 | err = |
5400 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5401 | ASSERT_VK_SUCCESS(err); |
5402 | |||||
5403 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; | ||||
5404 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5405 | dsl_binding[0].binding = 0; |
5406 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
5407 | dsl_binding[0].descriptorCount = 5; | ||||
5408 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; | ||||
5409 | dsl_binding[0].pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5410 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5411 | // Create layout identical to set0 layout but w/ different stageFlags |
5412 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5413 | dsl_fs_stage_only.binding = 0; |
5414 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
5415 | dsl_fs_stage_only.descriptorCount = 5; | ||||
5416 | dsl_fs_stage_only.stageFlags = | ||||
5417 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at | ||||
5418 | // bind time | ||||
5419 | dsl_fs_stage_only.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5420 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5421 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
5422 | ds_layout_ci.pNext = NULL; | ||||
5423 | ds_layout_ci.bindingCount = 1; | ||||
5424 | ds_layout_ci.pBindings = dsl_binding; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5425 | static const uint32_t NUM_LAYOUTS = 4; |
5426 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5427 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5428 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
5429 | // layout for error case | ||||
5430 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
5431 | &ds_layout[0]); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5432 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5433 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5434 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
5435 | &ds_layout_fs_only); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5436 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5437 | dsl_binding[0].binding = 0; |
5438 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5439 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5440 | dsl_binding[1].binding = 1; |
5441 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; | ||||
5442 | dsl_binding[1].descriptorCount = 2; | ||||
5443 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; | ||||
5444 | dsl_binding[1].pImmutableSamplers = NULL; | ||||
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5445 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5446 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5447 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
5448 | &ds_layout[1]); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5449 | ASSERT_VK_SUCCESS(err); |
5450 | dsl_binding[0].binding = 0; | ||||
5451 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5452 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5453 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5454 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
5455 | &ds_layout[2]); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5456 | ASSERT_VK_SUCCESS(err); |
5457 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5458 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5459 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
5460 | &ds_layout[3]); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5461 | ASSERT_VK_SUCCESS(err); |
5462 | |||||
5463 | static const uint32_t NUM_SETS = 4; | ||||
5464 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; | ||||
5465 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5466 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5467 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5468 | alloc_info.descriptorPool = ds_pool; |
5469 | alloc_info.pSetLayouts = ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5470 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
5471 | descriptorSet); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5472 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5473 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5474 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5475 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5476 | err = |
5477 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5478 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5479 | |
5480 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5481 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
5482 | pipeline_layout_ci.pNext = NULL; | ||||
5483 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; | ||||
5484 | pipeline_layout_ci.pSetLayouts = ds_layout; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5485 | |
5486 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5487 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
5488 | &pipeline_layout); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5489 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5490 | // Create pipelineLayout with only one setLayout |
5491 | pipeline_layout_ci.setLayoutCount = 1; | ||||
5492 | VkPipelineLayout single_pipe_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5493 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
5494 | &single_pipe_layout); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5495 | ASSERT_VK_SUCCESS(err); |
5496 | // Create pipelineLayout with 2 descriptor setLayout at index 0 | ||||
5497 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; | ||||
5498 | VkPipelineLayout pipe_layout_one_desc; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5499 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
5500 | &pipe_layout_one_desc); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5501 | ASSERT_VK_SUCCESS(err); |
5502 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 | ||||
5503 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; | ||||
5504 | VkPipelineLayout pipe_layout_five_samp; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5505 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
5506 | &pipe_layout_five_samp); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5507 | ASSERT_VK_SUCCESS(err); |
5508 | // Create pipelineLayout with UB type, but stageFlags for FS only | ||||
5509 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; | ||||
5510 | VkPipelineLayout pipe_layout_fs_only; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5511 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
5512 | &pipe_layout_fs_only); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5513 | ASSERT_VK_SUCCESS(err); |
5514 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine | ||||
5515 | VkDescriptorSetLayout pl_bad_s0[2] = {}; | ||||
5516 | pl_bad_s0[0] = ds_layout_fs_only; | ||||
5517 | pl_bad_s0[1] = ds_layout[1]; | ||||
5518 | pipeline_layout_ci.setLayoutCount = 2; | ||||
5519 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; | ||||
5520 | VkPipelineLayout pipe_layout_bad_set0; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5521 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
5522 | &pipe_layout_bad_set0); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5523 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5524 | |
5525 | // Create a buffer to update the descriptor with | ||||
5526 | uint32_t qfi = 0; | ||||
5527 | VkBufferCreateInfo buffCI = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5528 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
5529 | buffCI.size = 1024; | ||||
5530 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
5531 | buffCI.queueFamilyIndexCount = 1; | ||||
5532 | buffCI.pQueueFamilyIndices = &qfi; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5533 | |
5534 | VkBuffer dyub; | ||||
5535 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); | ||||
5536 | ASSERT_VK_SUCCESS(err); | ||||
5537 | // Correctly update descriptor to avoid "NOT_UPDATED" error | ||||
5538 | static const uint32_t NUM_BUFFS = 5; | ||||
5539 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5540 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5541 | buffInfo[i].buffer = dyub; |
5542 | buffInfo[i].offset = 0; | ||||
5543 | buffInfo[i].range = 1024; | ||||
5544 | } | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5545 | VkImage image; |
5546 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
5547 | const int32_t tex_width = 32; | ||||
5548 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5549 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5550 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
5551 | image_create_info.pNext = NULL; | ||||
5552 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
5553 | image_create_info.format = tex_format; | ||||
5554 | image_create_info.extent.width = tex_width; | ||||
5555 | image_create_info.extent.height = tex_height; | ||||
5556 | image_create_info.extent.depth = 1; | ||||
5557 | image_create_info.mipLevels = 1; | ||||
5558 | image_create_info.arrayLayers = 1; | ||||
5559 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
5560 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
5561 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
5562 | image_create_info.flags = 0; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5563 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
5564 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5565 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5566 | VkMemoryRequirements memReqs; |
5567 | VkDeviceMemory imageMem; | ||||
5568 | bool pass; | ||||
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5569 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5570 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
5571 | memAlloc.pNext = NULL; | ||||
5572 | memAlloc.allocationSize = 0; | ||||
5573 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5574 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
5575 | memAlloc.allocationSize = memReqs.size; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5576 | pass = |
5577 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5578 | ASSERT_TRUE(pass); |
5579 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); | ||||
5580 | ASSERT_VK_SUCCESS(err); | ||||
5581 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); | ||||
5582 | ASSERT_VK_SUCCESS(err); | ||||
5583 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5584 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5585 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
5586 | image_view_create_info.image = image; | ||||
5587 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
5588 | image_view_create_info.format = tex_format; | ||||
5589 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
5590 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
5591 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
5592 | image_view_create_info.subresourceRange.aspectMask = | ||||
5593 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5594 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5595 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5596 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
5597 | &view); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5598 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5599 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5600 | imageInfo[0].imageView = view; |
5601 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
5602 | imageInfo[1].imageView = view; | ||||
5603 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5604 | imageInfo[2].imageView = view; |
5605 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
5606 | imageInfo[3].imageView = view; | ||||
5607 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5608 | |
5609 | static const uint32_t NUM_SET_UPDATES = 3; | ||||
5610 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; | ||||
5611 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
5612 | descriptor_write[0].dstSet = descriptorSet[0]; | ||||
5613 | descriptor_write[0].dstBinding = 0; | ||||
5614 | descriptor_write[0].descriptorCount = 5; | ||||
5615 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
5616 | descriptor_write[0].pBufferInfo = buffInfo; | ||||
5617 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
5618 | descriptor_write[1].dstSet = descriptorSet[1]; | ||||
5619 | descriptor_write[1].dstBinding = 0; | ||||
5620 | descriptor_write[1].descriptorCount = 2; | ||||
5621 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
5622 | descriptor_write[1].pImageInfo = imageInfo; | ||||
5623 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
5624 | descriptor_write[2].dstSet = descriptorSet[1]; | ||||
5625 | descriptor_write[2].dstBinding = 1; | ||||
5626 | descriptor_write[2].descriptorCount = 2; | ||||
5627 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; | ||||
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5628 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5629 | |
5630 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5631 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5632 | // Create PSO to be used for draw-time errors below |
5633 | char const *vsSource = | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5634 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5635 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5636 | "out gl_PerVertex {\n" |
5637 | " vec4 gl_Position;\n" | ||||
5638 | "};\n" | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5639 | "void main(){\n" |
5640 | " gl_Position = vec4(1);\n" | ||||
5641 | "}\n"; | ||||
5642 | char const *fsSource = | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5643 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5644 | "\n" |
5645 | "layout(location=0) out vec4 x;\n" | ||||
5646 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" | ||||
5647 | "void main(){\n" | ||||
5648 | " x = vec4(bar.y);\n" | ||||
5649 | "}\n"; | ||||
5650 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
5651 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5652 | VkPipelineObj pipe(m_device); |
5653 | pipe.AddShader(&vs); | ||||
5654 | pipe.AddShader(&fs); | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5655 | pipe.AddColorAttachment(); |
5656 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5657 | |
5658 | BeginCommandBuffer(); | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5659 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5660 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
5661 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
5662 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding | ||||
5663 | // of PSO | ||||
5664 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of | ||||
5665 | // cmd_pipeline.c | ||||
5666 | // due to the fact that cmd_alloc_dset_data() has not been called in | ||||
5667 | // cmd_bind_graphics_pipeline() | ||||
5668 | // TODO : Want to cause various binding incompatibility issues here to test | ||||
5669 | // DrawState | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5670 | // First cause various verify_layout_compatibility() fails |
5671 | // Second disturb early and late sets and verify INFO msgs | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5672 | // verify_set_layout_compatibility fail cases: |
5673 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5674 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
5675 | " due to: invalid VkPipelineLayout "); | ||||
5676 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
5677 | VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
5678 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, | ||||
5679 | &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5680 | m_errorMonitor->VerifyFound(); |
5681 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5682 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5683 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
5684 | " attempting to bind set to index 1"); | ||||
5685 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
5686 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, | ||||
5687 | 0, 2, &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5688 | m_errorMonitor->VerifyFound(); |
5689 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5690 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5691 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
5692 | // descriptors | ||||
5693 | m_errorMonitor->SetDesiredFailureMsg( | ||||
5694 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5695 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5696 | vkCmdBindDescriptorSets( |
5697 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
5698 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5699 | m_errorMonitor->VerifyFound(); |
5700 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5701 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
5702 | // 4. same # of descriptors but mismatch in type | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5703 | m_errorMonitor->SetDesiredFailureMsg( |
5704 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5705 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5706 | vkCmdBindDescriptorSets( |
5707 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
5708 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5709 | m_errorMonitor->VerifyFound(); |
5710 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5711 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
5712 | // 5. same # of descriptors but mismatch in stageFlags | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5713 | m_errorMonitor->SetDesiredFailureMsg( |
5714 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5715 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5716 | vkCmdBindDescriptorSets( |
5717 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
5718 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5719 | m_errorMonitor->VerifyFound(); |
5720 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5721 | // Cause INFO messages due to disturbing previously bound Sets |
5722 | // First bind sets 0 & 1 | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5723 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
5724 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
5725 | 2, &descriptorSet[0], 0, NULL); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5726 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5727 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5728 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5729 | " previously bound as set #0 was disturbed "); |
5730 | vkCmdBindDescriptorSets( | ||||
5731 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
5732 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5733 | m_errorMonitor->VerifyFound(); |
5734 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5735 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
5736 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
5737 | 2, &descriptorSet[0], 0, NULL); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5738 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5739 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5740 | " newly bound as set #0 so set #1 and " |
5741 | "any subsequent sets were disturbed "); | ||||
5742 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
5743 | VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
5744 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5745 | m_errorMonitor->VerifyFound(); |
5746 | |||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5747 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5748 | // 1. Error due to not binding required set (we actually use same code as |
5749 | // above to disturb set0) | ||||
5750 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
5751 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
5752 | 2, &descriptorSet[0], 0, NULL); | ||||
5753 | vkCmdBindDescriptorSets( | ||||
5754 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
5755 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); | ||||
5756 | m_errorMonitor->SetDesiredFailureMsg( | ||||
5757 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
5758 | " uses set #0 but that set is not bound."); | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5759 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5760 | m_errorMonitor->VerifyFound(); |
5761 | |||||
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5762 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5763 | // 2. Error due to bound set not being compatible with PSO's |
5764 | // VkPipelineLayout (diff stageFlags in this case) | ||||
5765 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
5766 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
5767 | 2, &descriptorSet[0], 0, NULL); | ||||
5768 | m_errorMonitor->SetDesiredFailureMsg( | ||||
5769 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
5770 | " bound as set #0 is not compatible with "); | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5771 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5772 | m_errorMonitor->VerifyFound(); |
5773 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5774 | // Remaining clean-up |
5775 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5776 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5777 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
5778 | } | ||||
5779 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); | ||||
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 5780 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
5781 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5782 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5783 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
5784 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5785 | vkFreeMemory(m_device->device(), imageMem, NULL); |
5786 | vkDestroyImage(m_device->device(), image, NULL); | ||||
5787 | vkDestroyImageView(m_device->device(), view, NULL); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5788 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5789 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5790 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5791 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5792 | m_errorMonitor->SetDesiredFailureMsg( |
5793 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5794 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5795 | |
5796 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5797 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5798 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5799 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5800 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5801 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5802 | } |
5803 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5804 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
5805 | VkResult err; | ||||
5806 | VkCommandBuffer draw_cmd; | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5807 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5808 | m_errorMonitor->SetDesiredFailureMsg( |
5809 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 5810 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5811 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5812 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5813 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5814 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5815 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5816 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5817 | cmd.commandPool = m_commandPool; |
5818 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; | ||||
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5819 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5820 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5821 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5822 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5823 | |
5824 | // Force the failure by not setting the Renderpass and Framebuffer fields | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5825 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5826 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5827 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5828 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5829 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
5830 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; | ||||
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5831 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5832 | |
5833 | // The error should be caught by validation of the BeginCommandBuffer call | ||||
5834 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); | ||||
5835 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5836 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5837 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5838 | } |
5839 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5840 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5841 | // Cause error due to Begin while recording CB |
5842 | // Then cause 2 errors for attempting to reset CB w/o having | ||||
5843 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from | ||||
5844 | // which CBs were allocated. Note that this bit is off by default. | ||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5845 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5846 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5847 | |
5848 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
5849 | |||||
5850 | // Calls AllocateCommandBuffers | ||||
5851 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); | ||||
5852 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5853 | // Force the failure by setting the Renderpass and Framebuffer fields with |
5854 | // (fake) data | ||||
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5855 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5856 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5857 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
5858 | cmd_buf_info.pNext = NULL; | ||||
5859 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; | ||||
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5860 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5861 | |
5862 | // Begin CB to transition to recording state | ||||
5863 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); | ||||
5864 | // Can't re-begin. This should trigger error | ||||
5865 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5866 | m_errorMonitor->VerifyFound(); |
5867 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5868 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
5869 | "Attempt to reset command buffer "); | ||||
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5870 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
5871 | // Reset attempt will trigger error due to incorrect CommandPool state | ||||
5872 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5873 | m_errorMonitor->VerifyFound(); |
5874 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5875 | m_errorMonitor->SetDesiredFailureMsg( |
5876 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
5877 | " attempts to implicitly reset cmdBuffer created from "); | ||||
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5878 | // Transition CB to RECORDED state |
5879 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); | ||||
5880 | // Now attempting to Begin will implicitly reset, which triggers error | ||||
5881 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5882 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5883 | } |
5884 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5885 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5886 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5887 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5888 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5889 | m_errorMonitor->SetDesiredFailureMsg( |
5890 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5891 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
5892 | |||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5893 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5894 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5895 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5896 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5897 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
5898 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5899 | |
5900 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5901 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
5902 | ds_pool_ci.pNext = NULL; | ||||
5903 | ds_pool_ci.maxSets = 1; | ||||
5904 | ds_pool_ci.poolSizeCount = 1; | ||||
5905 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5906 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5907 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5908 | err = |
5909 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5910 | ASSERT_VK_SUCCESS(err); |
5911 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5912 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5913 | dsl_binding.binding = 0; |
5914 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
5915 | dsl_binding.descriptorCount = 1; | ||||
5916 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
5917 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5918 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5919 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5920 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
5921 | ds_layout_ci.pNext = NULL; | ||||
5922 | ds_layout_ci.bindingCount = 1; | ||||
5923 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5924 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5925 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5926 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
5927 | &ds_layout); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5928 | ASSERT_VK_SUCCESS(err); |
5929 | |||||
5930 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5931 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5932 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5933 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5934 | alloc_info.descriptorPool = ds_pool; |
5935 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5936 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
5937 | &descriptorSet); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5938 | ASSERT_VK_SUCCESS(err); |
5939 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5940 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5941 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
5942 | pipeline_layout_ci.setLayoutCount = 1; | ||||
5943 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5944 | |
5945 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5946 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
5947 | &pipeline_layout); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5948 | ASSERT_VK_SUCCESS(err); |
5949 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5950 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5951 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5952 | |
5953 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5954 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
5955 | vp_state_ci.scissorCount = 1; | ||||
5956 | vp_state_ci.pScissors = ≻ | ||||
5957 | vp_state_ci.viewportCount = 1; | ||||
5958 | vp_state_ci.pViewports = &vp; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5959 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5960 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
5961 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
5962 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; | ||||
5963 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; | ||||
5964 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; | ||||
5965 | rs_state_ci.depthClampEnable = VK_FALSE; | ||||
5966 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; | ||||
5967 | rs_state_ci.depthBiasEnable = VK_FALSE; | ||||
5968 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5969 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5970 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
5971 | gp_ci.pViewportState = &vp_state_ci; | ||||
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5972 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5973 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
5974 | gp_ci.layout = pipeline_layout; | ||||
5975 | gp_ci.renderPass = renderPass(); | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5976 | |
5977 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5978 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
5979 | pc_ci.initialDataSize = 0; | ||||
5980 | pc_ci.pInitialData = 0; | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5981 | |
5982 | VkPipeline pipeline; | ||||
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5983 | VkPipelineCache pipelineCache; |
5984 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5985 | err = |
5986 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5987 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5988 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
5989 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5990 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5991 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5992 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5993 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
5994 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
5995 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
5996 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5997 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5998 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
5999 | TEST_F(VkLayerTest, InvalidPatchControlPoints) | ||||
6000 | { | ||||
6001 | // Attempt to Create Gfx Pipeline w/o a VS | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6002 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6003 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6004 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6005 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
6006 | primitive "); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6007 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6008 | ASSERT_NO_FATAL_FAILURE(InitState()); |
6009 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6010 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6011 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6012 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6013 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6014 | |
6015 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
6016 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
6017 | ds_pool_ci.pNext = NULL; | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6018 | ds_pool_ci.poolSizeCount = 1; |
6019 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6020 | |
6021 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6022 | err = vkCreateDescriptorPool(m_device->device(), |
6023 | 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] | 6024 | ASSERT_VK_SUCCESS(err); |
6025 | |||||
6026 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6027 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6028 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6029 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6030 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
6031 | dsl_binding.pImmutableSamplers = NULL; | ||||
6032 | |||||
6033 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6034 | ds_layout_ci.sType = |
6035 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6036 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6037 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6038 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6039 | |
6040 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6041 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
6042 | &ds_layout); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6043 | ASSERT_VK_SUCCESS(err); |
6044 | |||||
6045 | VkDescriptorSet descriptorSet; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6046 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
6047 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6048 | ASSERT_VK_SUCCESS(err); |
6049 | |||||
6050 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6051 | pipeline_layout_ci.sType = |
6052 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6053 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6054 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6055 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
6056 | |||||
6057 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6058 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
6059 | &pipeline_layout); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6060 | ASSERT_VK_SUCCESS(err); |
6061 | |||||
6062 | VkPipelineShaderStageCreateInfo shaderStages[3]; | ||||
6063 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); | ||||
6064 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6065 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
6066 | this); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6067 | // 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] | 6068 | VkShaderObj |
6069 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, | ||||
6070 | this); | ||||
6071 | VkShaderObj | ||||
6072 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, | ||||
6073 | this); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6074 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6075 | shaderStages[0].sType = |
6076 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; | ||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6077 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6078 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6079 | shaderStages[1].sType = |
6080 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; | ||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6081 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6082 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6083 | shaderStages[2].sType = |
6084 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; | ||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6085 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6086 | shaderStages[2].shader = te.handle(); |
6087 | |||||
6088 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6089 | iaCI.sType = |
6090 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6091 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6092 | |
6093 | VkPipelineTessellationStateCreateInfo tsCI = {}; | ||||
6094 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; | ||||
6095 | tsCI.patchControlPoints = 0; // This will cause an error | ||||
6096 | |||||
6097 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
6098 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; | ||||
6099 | gp_ci.pNext = NULL; | ||||
6100 | gp_ci.stageCount = 3; | ||||
6101 | gp_ci.pStages = shaderStages; | ||||
6102 | gp_ci.pVertexInputState = NULL; | ||||
6103 | gp_ci.pInputAssemblyState = &iaCI; | ||||
6104 | gp_ci.pTessellationState = &tsCI; | ||||
6105 | gp_ci.pViewportState = NULL; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6106 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6107 | gp_ci.pMultisampleState = NULL; |
6108 | gp_ci.pDepthStencilState = NULL; | ||||
6109 | gp_ci.pColorBlendState = NULL; | ||||
6110 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
6111 | gp_ci.layout = pipeline_layout; | ||||
6112 | gp_ci.renderPass = renderPass(); | ||||
6113 | |||||
6114 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
6115 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; | ||||
6116 | pc_ci.pNext = NULL; | ||||
6117 | pc_ci.initialSize = 0; | ||||
6118 | pc_ci.initialData = 0; | ||||
6119 | pc_ci.maxSize = 0; | ||||
6120 | |||||
6121 | VkPipeline pipeline; | ||||
6122 | VkPipelineCache pipelineCache; | ||||
6123 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6124 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
6125 | &pipelineCache); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6126 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6127 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
6128 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6129 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6130 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6131 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6132 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
6133 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
6134 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
6135 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 6136 | } |
6137 | */ | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6138 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6139 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6140 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6141 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6142 | m_errorMonitor->SetDesiredFailureMsg( |
6143 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6144 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
6145 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6146 | ASSERT_NO_FATAL_FAILURE(InitState()); |
6147 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6148 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6149 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6150 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
6151 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6152 | |
6153 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6154 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
6155 | ds_pool_ci.maxSets = 1; | ||||
6156 | ds_pool_ci.poolSizeCount = 1; | ||||
6157 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6158 | |
6159 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6160 | err = |
6161 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6162 | ASSERT_VK_SUCCESS(err); |
6163 | |||||
6164 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6165 | dsl_binding.binding = 0; |
6166 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6167 | dsl_binding.descriptorCount = 1; | ||||
6168 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6169 | |
6170 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6171 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
6172 | ds_layout_ci.bindingCount = 1; | ||||
6173 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6174 | |
6175 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6176 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
6177 | &ds_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6178 | ASSERT_VK_SUCCESS(err); |
6179 | |||||
6180 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6181 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6182 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6183 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6184 | alloc_info.descriptorPool = ds_pool; |
6185 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6186 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
6187 | &descriptorSet); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6188 | ASSERT_VK_SUCCESS(err); |
6189 | |||||
6190 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6191 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
6192 | pipeline_layout_ci.setLayoutCount = 1; | ||||
6193 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6194 | |
6195 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6196 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
6197 | &pipeline_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6198 | ASSERT_VK_SUCCESS(err); |
6199 | |||||
6200 | VkViewport vp = {}; // Just need dummy vp to point to | ||||
6201 | |||||
6202 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6203 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
6204 | vp_state_ci.scissorCount = 0; | ||||
6205 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error | ||||
6206 | vp_state_ci.pViewports = &vp; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6207 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6208 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
6209 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
6210 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; | ||||
6211 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; | ||||
6212 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; | ||||
6213 | rs_state_ci.depthClampEnable = VK_FALSE; | ||||
6214 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; | ||||
6215 | rs_state_ci.depthBiasEnable = VK_FALSE; | ||||
6216 | |||||
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6217 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6218 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6219 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6220 | VkShaderObj vs(m_device, bindStateVertShaderText, |
6221 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
6222 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
6223 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6224 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6225 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6226 | shaderStages[0] = vs.GetStageCreateInfo(); |
6227 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6228 | |
6229 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6230 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
6231 | gp_ci.stageCount = 2; | ||||
6232 | gp_ci.pStages = shaderStages; | ||||
6233 | gp_ci.pViewportState = &vp_state_ci; | ||||
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6234 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6235 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
6236 | gp_ci.layout = pipeline_layout; | ||||
6237 | gp_ci.renderPass = renderPass(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6238 | |
6239 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6240 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6241 | |
6242 | VkPipeline pipeline; | ||||
6243 | VkPipelineCache pipelineCache; | ||||
6244 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6245 | err = |
6246 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6247 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6248 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
6249 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6250 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6251 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6252 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6253 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
6254 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
6255 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
6256 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6257 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6258 | // Don't set viewport state in PSO. This is an error b/c we always need this |
6259 | // state | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6260 | // 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] | 6261 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6262 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6263 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6264 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6265 | m_errorMonitor->SetDesiredFailureMsg( |
6266 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6267 | "Gfx Pipeline pViewportState is null. Even if "); |
6268 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6269 | ASSERT_NO_FATAL_FAILURE(InitState()); |
6270 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6271 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6272 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6273 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
6274 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6275 | |
6276 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6277 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
6278 | ds_pool_ci.maxSets = 1; | ||||
6279 | ds_pool_ci.poolSizeCount = 1; | ||||
6280 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6281 | |
6282 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6283 | err = |
6284 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6285 | ASSERT_VK_SUCCESS(err); |
6286 | |||||
6287 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6288 | dsl_binding.binding = 0; |
6289 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6290 | dsl_binding.descriptorCount = 1; | ||||
6291 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6292 | |
6293 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6294 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
6295 | ds_layout_ci.bindingCount = 1; | ||||
6296 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6297 | |
6298 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6299 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
6300 | &ds_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6301 | ASSERT_VK_SUCCESS(err); |
6302 | |||||
6303 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6304 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6305 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6306 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6307 | alloc_info.descriptorPool = ds_pool; |
6308 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6309 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
6310 | &descriptorSet); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6311 | ASSERT_VK_SUCCESS(err); |
6312 | |||||
6313 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6314 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
6315 | pipeline_layout_ci.setLayoutCount = 1; | ||||
6316 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6317 | |
6318 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6319 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
6320 | &pipeline_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6321 | ASSERT_VK_SUCCESS(err); |
6322 | |||||
6323 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; | ||||
6324 | // Set scissor as dynamic to avoid second error | ||||
6325 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6326 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
6327 | dyn_state_ci.dynamicStateCount = 1; | ||||
6328 | dyn_state_ci.pDynamicStates = &sc_state; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6329 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6330 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6331 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6332 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6333 | VkShaderObj vs(m_device, bindStateVertShaderText, |
6334 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
6335 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
6336 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6337 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6338 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6339 | shaderStages[0] = vs.GetStageCreateInfo(); |
6340 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6341 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6342 | |
6343 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; | ||||
6344 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
6345 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; | ||||
6346 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; | ||||
6347 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; | ||||
6348 | rs_state_ci.depthClampEnable = VK_FALSE; | ||||
6349 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; | ||||
6350 | rs_state_ci.depthBiasEnable = VK_FALSE; | ||||
6351 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6352 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6353 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
6354 | gp_ci.stageCount = 2; | ||||
6355 | gp_ci.pStages = shaderStages; | ||||
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 6356 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6357 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
6358 | // should cause validation error | ||||
6359 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
6360 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
6361 | gp_ci.layout = pipeline_layout; | ||||
6362 | gp_ci.renderPass = renderPass(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6363 | |
6364 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6365 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6366 | |
6367 | VkPipeline pipeline; | ||||
6368 | VkPipelineCache pipelineCache; | ||||
6369 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6370 | err = |
6371 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6372 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6373 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
6374 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6375 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6376 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6377 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6378 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
6379 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
6380 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
6381 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6382 | } |
6383 | // Create PSO w/o non-zero viewportCount but no viewport data | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6384 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
6385 | // count | ||||
6386 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { | ||||
6387 | VkResult err; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6388 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6389 | m_errorMonitor->SetDesiredFailureMsg( |
6390 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6391 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
6392 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6393 | ASSERT_NO_FATAL_FAILURE(InitState()); |
6394 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6395 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6396 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6397 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
6398 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6399 | |
6400 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6401 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
6402 | ds_pool_ci.maxSets = 1; | ||||
6403 | ds_pool_ci.poolSizeCount = 1; | ||||
6404 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6405 | |
6406 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6407 | err = |
6408 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6409 | ASSERT_VK_SUCCESS(err); |
6410 | |||||
6411 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6412 | dsl_binding.binding = 0; |
6413 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6414 | dsl_binding.descriptorCount = 1; | ||||
6415 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6416 | |
6417 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6418 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
6419 | ds_layout_ci.bindingCount = 1; | ||||
6420 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6421 | |
6422 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6423 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
6424 | &ds_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6425 | ASSERT_VK_SUCCESS(err); |
6426 | |||||
6427 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6428 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6429 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6430 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6431 | alloc_info.descriptorPool = ds_pool; |
6432 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6433 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
6434 | &descriptorSet); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6435 | ASSERT_VK_SUCCESS(err); |
6436 | |||||
6437 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6438 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
6439 | pipeline_layout_ci.setLayoutCount = 1; | ||||
6440 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6441 | |
6442 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6443 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
6444 | &pipeline_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6445 | ASSERT_VK_SUCCESS(err); |
6446 | |||||
6447 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6448 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
6449 | vp_state_ci.viewportCount = 1; | ||||
6450 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error | ||||
6451 | vp_state_ci.scissorCount = 1; | ||||
6452 | vp_state_ci.pScissors = | ||||
6453 | NULL; // Scissor is dynamic (below) so this won't cause error | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6454 | |
6455 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; | ||||
6456 | // Set scissor as dynamic to avoid that error | ||||
6457 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6458 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
6459 | dyn_state_ci.dynamicStateCount = 1; | ||||
6460 | dyn_state_ci.pDynamicStates = &sc_state; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6461 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6462 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6463 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6464 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6465 | VkShaderObj vs(m_device, bindStateVertShaderText, |
6466 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
6467 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
6468 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6469 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6470 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6471 | shaderStages[0] = vs.GetStageCreateInfo(); |
6472 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6473 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6474 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
6475 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; | ||||
6476 | vi_ci.pNext = nullptr; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6477 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6478 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6479 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6480 | vi_ci.pVertexAttributeDescriptions = nullptr; |
6481 | |||||
6482 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; | ||||
6483 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
6484 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; | ||||
6485 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6486 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6487 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6488 | rs_ci.pNext = nullptr; |
6489 | |||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6490 | VkPipelineColorBlendAttachmentState att = {}; |
6491 | att.blendEnable = VK_FALSE; | ||||
6492 | att.colorWriteMask = 0xf; | ||||
6493 | |||||
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6494 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
6495 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; | ||||
6496 | cb_ci.pNext = nullptr; | ||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6497 | cb_ci.attachmentCount = 1; |
6498 | cb_ci.pAttachments = &att; | ||||
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6499 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6500 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6501 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
6502 | gp_ci.stageCount = 2; | ||||
6503 | gp_ci.pStages = shaderStages; | ||||
6504 | gp_ci.pVertexInputState = &vi_ci; | ||||
6505 | gp_ci.pInputAssemblyState = &ia_ci; | ||||
6506 | gp_ci.pViewportState = &vp_state_ci; | ||||
6507 | gp_ci.pRasterizationState = &rs_ci; | ||||
6508 | gp_ci.pColorBlendState = &cb_ci; | ||||
6509 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
6510 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
6511 | gp_ci.layout = pipeline_layout; | ||||
6512 | gp_ci.renderPass = renderPass(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6513 | |
6514 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6515 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6516 | |
6517 | VkPipeline pipeline; | ||||
6518 | VkPipelineCache pipelineCache; | ||||
6519 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6520 | err = |
6521 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6522 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6523 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
6524 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6525 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6526 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6527 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6528 | // 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] | 6529 | // First need to successfully create the PSO from above by setting |
6530 | // pViewports | ||||
6531 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6532 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6533 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " | ||||
6534 | "scissorCount is 1. These counts must match."); | ||||
6535 | |||||
6536 | VkViewport vp = {}; // Just need dummy vp to point to | ||||
6537 | vp_state_ci.pViewports = &vp; | ||||
6538 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
6539 | &gp_ci, NULL, &pipeline); | ||||
6540 | ASSERT_VK_SUCCESS(err); | ||||
6541 | BeginCommandBuffer(); | ||||
6542 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
6543 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); | ||||
6544 | VkRect2D scissors[2] = {}; // don't care about data | ||||
6545 | // Count of 2 doesn't match PSO count of 1 | ||||
6546 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); | ||||
6547 | Draw(1, 0, 0, 0); | ||||
6548 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6549 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6550 | |
6551 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); | ||||
6552 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
6553 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
6554 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6555 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6556 | } |
6557 | // Create PSO w/o non-zero scissorCount but no scissor data | ||||
6558 | // Then run second test where dynamic viewportCount doesn't match PSO | ||||
6559 | // viewportCount | ||||
6560 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { | ||||
6561 | VkResult err; | ||||
6562 | |||||
6563 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6564 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6565 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); | ||||
6566 | |||||
6567 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6568 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
6569 | |||||
6570 | VkDescriptorPoolSize ds_type_count = {}; | ||||
6571 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6572 | ds_type_count.descriptorCount = 1; | ||||
6573 | |||||
6574 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
6575 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
6576 | ds_pool_ci.maxSets = 1; | ||||
6577 | ds_pool_ci.poolSizeCount = 1; | ||||
6578 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
6579 | |||||
6580 | VkDescriptorPool ds_pool; | ||||
6581 | err = | ||||
6582 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
6583 | ASSERT_VK_SUCCESS(err); | ||||
6584 | |||||
6585 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
6586 | dsl_binding.binding = 0; | ||||
6587 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6588 | dsl_binding.descriptorCount = 1; | ||||
6589 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
6590 | |||||
6591 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
6592 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
6593 | ds_layout_ci.bindingCount = 1; | ||||
6594 | ds_layout_ci.pBindings = &dsl_binding; | ||||
6595 | |||||
6596 | VkDescriptorSetLayout ds_layout; | ||||
6597 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
6598 | &ds_layout); | ||||
6599 | ASSERT_VK_SUCCESS(err); | ||||
6600 | |||||
6601 | VkDescriptorSet descriptorSet; | ||||
6602 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
6603 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
6604 | alloc_info.descriptorSetCount = 1; | ||||
6605 | alloc_info.descriptorPool = ds_pool; | ||||
6606 | alloc_info.pSetLayouts = &ds_layout; | ||||
6607 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
6608 | &descriptorSet); | ||||
6609 | ASSERT_VK_SUCCESS(err); | ||||
6610 | |||||
6611 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
6612 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
6613 | pipeline_layout_ci.setLayoutCount = 1; | ||||
6614 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
6615 | |||||
6616 | VkPipelineLayout pipeline_layout; | ||||
6617 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
6618 | &pipeline_layout); | ||||
6619 | ASSERT_VK_SUCCESS(err); | ||||
6620 | |||||
6621 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
6622 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; | ||||
6623 | vp_state_ci.scissorCount = 1; | ||||
6624 | vp_state_ci.pScissors = | ||||
6625 | NULL; // Null scissor w/ count of 1 should cause error | ||||
6626 | vp_state_ci.viewportCount = 1; | ||||
6627 | vp_state_ci.pViewports = | ||||
6628 | NULL; // vp is dynamic (below) so this won't cause error | ||||
6629 | |||||
6630 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; | ||||
6631 | // Set scissor as dynamic to avoid that error | ||||
6632 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
6633 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; | ||||
6634 | dyn_state_ci.dynamicStateCount = 1; | ||||
6635 | dyn_state_ci.pDynamicStates = &vp_state; | ||||
6636 | |||||
6637 | VkPipelineShaderStageCreateInfo shaderStages[2]; | ||||
6638 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); | ||||
6639 | |||||
6640 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
6641 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
6642 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
6643 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6644 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6645 | // but add it to be able to run on more devices |
6646 | shaderStages[0] = vs.GetStageCreateInfo(); | ||||
6647 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
6648 | |||||
6649 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; | ||||
6650 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; | ||||
6651 | vi_ci.pNext = nullptr; | ||||
6652 | vi_ci.vertexBindingDescriptionCount = 0; | ||||
6653 | vi_ci.pVertexBindingDescriptions = nullptr; | ||||
6654 | vi_ci.vertexAttributeDescriptionCount = 0; | ||||
6655 | vi_ci.pVertexAttributeDescriptions = nullptr; | ||||
6656 | |||||
6657 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; | ||||
6658 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
6659 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; | ||||
6660 | |||||
6661 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; | ||||
6662 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
6663 | rs_ci.pNext = nullptr; | ||||
6664 | |||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6665 | VkPipelineColorBlendAttachmentState att = {}; |
6666 | att.blendEnable = VK_FALSE; | ||||
6667 | att.colorWriteMask = 0xf; | ||||
6668 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6669 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
6670 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; | ||||
6671 | cb_ci.pNext = nullptr; | ||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6672 | cb_ci.attachmentCount = 1; |
6673 | cb_ci.pAttachments = &att; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6674 | |
6675 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
6676 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; | ||||
6677 | gp_ci.stageCount = 2; | ||||
6678 | gp_ci.pStages = shaderStages; | ||||
6679 | gp_ci.pVertexInputState = &vi_ci; | ||||
6680 | gp_ci.pInputAssemblyState = &ia_ci; | ||||
6681 | gp_ci.pViewportState = &vp_state_ci; | ||||
6682 | gp_ci.pRasterizationState = &rs_ci; | ||||
6683 | gp_ci.pColorBlendState = &cb_ci; | ||||
6684 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
6685 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
6686 | gp_ci.layout = pipeline_layout; | ||||
6687 | gp_ci.renderPass = renderPass(); | ||||
6688 | |||||
6689 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
6690 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; | ||||
6691 | |||||
6692 | VkPipeline pipeline; | ||||
6693 | VkPipelineCache pipelineCache; | ||||
6694 | |||||
6695 | err = | ||||
6696 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
6697 | ASSERT_VK_SUCCESS(err); | ||||
6698 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
6699 | &gp_ci, NULL, &pipeline); | ||||
6700 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6701 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6702 | |
6703 | // Now hit second fail case where we set scissor w/ different count than PSO | ||||
6704 | // First need to successfully create the PSO from above by setting | ||||
6705 | // pViewports | ||||
6706 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6707 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6708 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " | ||||
6709 | "viewportCount is 1. These counts must match."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6710 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6711 | VkRect2D sc = {}; // Just need dummy vp to point to |
6712 | vp_state_ci.pScissors = ≻ | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6713 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
6714 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6715 | ASSERT_VK_SUCCESS(err); |
6716 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6717 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
6718 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6719 | VkViewport viewports[2] = {}; // don't care about data |
6720 | // Count of 2 doesn't match PSO count of 1 | ||||
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 6721 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6722 | Draw(1, 0, 0, 0); |
6723 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6724 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6725 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6726 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
6727 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
6728 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
6729 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6730 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6731 | } |
6732 | |||||
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6733 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
6734 | VkResult err; | ||||
6735 | |||||
6736 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6737 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6738 | |
6739 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6740 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
6741 | |||||
6742 | VkDescriptorPoolSize ds_type_count = {}; | ||||
6743 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6744 | ds_type_count.descriptorCount = 1; | ||||
6745 | |||||
6746 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
6747 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
6748 | ds_pool_ci.maxSets = 1; | ||||
6749 | ds_pool_ci.poolSizeCount = 1; | ||||
6750 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
6751 | |||||
6752 | VkDescriptorPool ds_pool; | ||||
6753 | err = | ||||
6754 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
6755 | ASSERT_VK_SUCCESS(err); | ||||
6756 | |||||
6757 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
6758 | dsl_binding.binding = 0; | ||||
6759 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6760 | dsl_binding.descriptorCount = 1; | ||||
6761 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
6762 | |||||
6763 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
6764 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
6765 | ds_layout_ci.bindingCount = 1; | ||||
6766 | ds_layout_ci.pBindings = &dsl_binding; | ||||
6767 | |||||
6768 | VkDescriptorSetLayout ds_layout; | ||||
6769 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
6770 | &ds_layout); | ||||
6771 | ASSERT_VK_SUCCESS(err); | ||||
6772 | |||||
6773 | VkDescriptorSet descriptorSet; | ||||
6774 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
6775 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
6776 | alloc_info.descriptorSetCount = 1; | ||||
6777 | alloc_info.descriptorPool = ds_pool; | ||||
6778 | alloc_info.pSetLayouts = &ds_layout; | ||||
6779 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
6780 | &descriptorSet); | ||||
6781 | ASSERT_VK_SUCCESS(err); | ||||
6782 | |||||
6783 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
6784 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
6785 | pipeline_layout_ci.setLayoutCount = 1; | ||||
6786 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
6787 | |||||
6788 | VkPipelineLayout pipeline_layout; | ||||
6789 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
6790 | &pipeline_layout); | ||||
6791 | ASSERT_VK_SUCCESS(err); | ||||
6792 | |||||
6793 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
6794 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; | ||||
6795 | vp_state_ci.scissorCount = 1; | ||||
6796 | vp_state_ci.pScissors = NULL; | ||||
6797 | vp_state_ci.viewportCount = 1; | ||||
6798 | vp_state_ci.pViewports = NULL; | ||||
6799 | |||||
6800 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, | ||||
6801 | VK_DYNAMIC_STATE_SCISSOR, | ||||
6802 | VK_DYNAMIC_STATE_LINE_WIDTH}; | ||||
6803 | // Set scissor as dynamic to avoid that error | ||||
6804 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
6805 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; | ||||
6806 | dyn_state_ci.dynamicStateCount = 2; | ||||
6807 | dyn_state_ci.pDynamicStates = dynamic_states; | ||||
6808 | |||||
6809 | VkPipelineShaderStageCreateInfo shaderStages[2]; | ||||
6810 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); | ||||
6811 | |||||
6812 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
6813 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
6814 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
6815 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
6816 | this); // TODO - We shouldn't need a fragment shader | ||||
6817 | // but add it to be able to run on more devices | ||||
6818 | shaderStages[0] = vs.GetStageCreateInfo(); | ||||
6819 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
6820 | |||||
6821 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; | ||||
6822 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; | ||||
6823 | vi_ci.pNext = nullptr; | ||||
6824 | vi_ci.vertexBindingDescriptionCount = 0; | ||||
6825 | vi_ci.pVertexBindingDescriptions = nullptr; | ||||
6826 | vi_ci.vertexAttributeDescriptionCount = 0; | ||||
6827 | vi_ci.pVertexAttributeDescriptions = nullptr; | ||||
6828 | |||||
6829 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; | ||||
6830 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
6831 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; | ||||
6832 | |||||
6833 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; | ||||
6834 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
6835 | rs_ci.pNext = nullptr; | ||||
6836 | |||||
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6837 | // Check too low (line width of -1.0f). |
6838 | rs_ci.lineWidth = -1.0f; | ||||
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6839 | |
6840 | VkPipelineColorBlendAttachmentState att = {}; | ||||
6841 | att.blendEnable = VK_FALSE; | ||||
6842 | att.colorWriteMask = 0xf; | ||||
6843 | |||||
6844 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; | ||||
6845 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; | ||||
6846 | cb_ci.pNext = nullptr; | ||||
6847 | cb_ci.attachmentCount = 1; | ||||
6848 | cb_ci.pAttachments = &att; | ||||
6849 | |||||
6850 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
6851 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; | ||||
6852 | gp_ci.stageCount = 2; | ||||
6853 | gp_ci.pStages = shaderStages; | ||||
6854 | gp_ci.pVertexInputState = &vi_ci; | ||||
6855 | gp_ci.pInputAssemblyState = &ia_ci; | ||||
6856 | gp_ci.pViewportState = &vp_state_ci; | ||||
6857 | gp_ci.pRasterizationState = &rs_ci; | ||||
6858 | gp_ci.pColorBlendState = &cb_ci; | ||||
6859 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
6860 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
6861 | gp_ci.layout = pipeline_layout; | ||||
6862 | gp_ci.renderPass = renderPass(); | ||||
6863 | |||||
6864 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
6865 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; | ||||
6866 | |||||
6867 | VkPipeline pipeline; | ||||
6868 | VkPipelineCache pipelineCache; | ||||
6869 | |||||
6870 | err = | ||||
6871 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
6872 | ASSERT_VK_SUCCESS(err); | ||||
6873 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
6874 | &gp_ci, NULL, &pipeline); | ||||
6875 | |||||
6876 | m_errorMonitor->VerifyFound(); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6877 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6878 | |
6879 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6880 | "Attempt to set lineWidth to 65536"); | ||||
6881 | |||||
6882 | // Check too high (line width of 65536.0f). | ||||
6883 | rs_ci.lineWidth = 65536.0f; | ||||
6884 | |||||
6885 | err = | ||||
6886 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
6887 | ASSERT_VK_SUCCESS(err); | ||||
6888 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
6889 | &gp_ci, NULL, &pipeline); | ||||
6890 | |||||
6891 | m_errorMonitor->VerifyFound(); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6892 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6893 | |
6894 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6895 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6896 | |
6897 | dyn_state_ci.dynamicStateCount = 3; | ||||
6898 | |||||
6899 | rs_ci.lineWidth = 1.0f; | ||||
6900 | |||||
6901 | err = | ||||
6902 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
6903 | ASSERT_VK_SUCCESS(err); | ||||
6904 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
6905 | &gp_ci, NULL, &pipeline); | ||||
6906 | BeginCommandBuffer(); | ||||
6907 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
6908 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); | ||||
6909 | |||||
6910 | // Check too low with dynamic setting. | ||||
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6911 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6912 | m_errorMonitor->VerifyFound(); |
6913 | |||||
6914 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6915 | "Attempt to set lineWidth to 65536"); | ||||
6916 | |||||
6917 | // Check too high with dynamic setting. | ||||
6918 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); | ||||
6919 | m_errorMonitor->VerifyFound(); | ||||
6920 | EndCommandBuffer(); | ||||
6921 | |||||
6922 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); | ||||
6923 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
6924 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
6925 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6926 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6927 | } |
6928 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6929 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6930 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6931 | m_errorMonitor->SetDesiredFailureMsg( |
6932 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6933 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6934 | |
6935 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6936 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6937 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6938 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6939 | // Don't care about RenderPass handle b/c error should be flagged before |
6940 | // that | ||||
6941 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, | ||||
6942 | VK_SUBPASS_CONTENTS_INLINE); | ||||
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6943 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6944 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6945 | } |
6946 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6947 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6948 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6949 | m_errorMonitor->SetDesiredFailureMsg( |
6950 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6951 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6952 | |
6953 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6954 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6955 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6956 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6957 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
6958 | // proper error | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6959 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6960 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
6961 | rp_begin.pNext = NULL; | ||||
6962 | rp_begin.renderPass = renderPass(); | ||||
6963 | rp_begin.framebuffer = framebuffer(); | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6964 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6965 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
6966 | VK_SUBPASS_CONTENTS_INLINE); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6967 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6968 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6969 | } |
6970 | |||||
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 6971 | TEST_F(VkLayerTest, RenderPassClearOpMismatch) { |
6972 | TEST_DESCRIPTION("Begin a renderPass where clearValueCount is less than" | ||||
6973 | "the number of renderPass attachments that use loadOp" | ||||
6974 | "VK_ATTACHMENT_LOAD_OP_CLEAR."); | ||||
6975 | |||||
6976 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6977 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
6978 | |||||
6979 | // Create a renderPass with a single attachment that uses loadOp CLEAR | ||||
6980 | VkAttachmentReference attach = {}; | ||||
6981 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
6982 | VkSubpassDescription subpass = {}; | ||||
6983 | subpass.inputAttachmentCount = 1; | ||||
6984 | subpass.pInputAttachments = &attach; | ||||
6985 | VkRenderPassCreateInfo rpci = {}; | ||||
6986 | rpci.subpassCount = 1; | ||||
6987 | rpci.pSubpasses = &subpass; | ||||
6988 | rpci.attachmentCount = 1; | ||||
6989 | VkAttachmentDescription attach_desc = {}; | ||||
6990 | attach_desc.format = VK_FORMAT_UNDEFINED; | ||||
6991 | // Set loadOp to CLEAR | ||||
6992 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; | ||||
6993 | rpci.pAttachments = &attach_desc; | ||||
6994 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; | ||||
6995 | VkRenderPass rp; | ||||
6996 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
6997 | |||||
6998 | VkCommandBufferInheritanceInfo hinfo = {}; | ||||
6999 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; | ||||
7000 | hinfo.renderPass = VK_NULL_HANDLE; | ||||
7001 | hinfo.subpass = 0; | ||||
7002 | hinfo.framebuffer = VK_NULL_HANDLE; | ||||
7003 | hinfo.occlusionQueryEnable = VK_FALSE; | ||||
7004 | hinfo.queryFlags = 0; | ||||
7005 | hinfo.pipelineStatistics = 0; | ||||
7006 | VkCommandBufferBeginInfo info = {}; | ||||
7007 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; | ||||
7008 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
7009 | info.pInheritanceInfo = &hinfo; | ||||
7010 | |||||
7011 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); | ||||
7012 | VkRenderPassBeginInfo rp_begin = {}; | ||||
7013 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; | ||||
7014 | rp_begin.pNext = NULL; | ||||
7015 | rp_begin.renderPass = renderPass(); | ||||
7016 | rp_begin.framebuffer = framebuffer(); | ||||
7017 | rp_begin.clearValueCount = 0; // Should be 1 | ||||
7018 | |||||
7019 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7020 | " has a clearValueCount of 0 but the " | ||||
7021 | "actual number of attachments in " | ||||
7022 | "renderPass "); | ||||
7023 | |||||
7024 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, | ||||
7025 | VK_SUBPASS_CONTENTS_INLINE); | ||||
7026 | |||||
7027 | m_errorMonitor->VerifyFound(); | ||||
Mark Lobodzinski | 5c70ebd | 2016-06-09 13:45:00 -0600 | [diff] [blame] | 7028 | |
7029 | vkDestroyRenderPass(m_device->device(), rp, NULL); | ||||
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 7030 | } |
7031 | |||||
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 7032 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
7033 | |||||
7034 | TEST_DESCRIPTION("End a command buffer with an active render pass"); | ||||
7035 | |||||
7036 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7037 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7038 | "It is invalid to issue this call inside an active render pass"); | ||||
7039 | |||||
7040 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7041 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
7042 | |||||
7043 | // The framework's BeginCommandBuffer calls CreateRenderPass | ||||
7044 | BeginCommandBuffer(); | ||||
7045 | |||||
7046 | // Call directly into vkEndCommandBuffer instead of the | ||||
7047 | // the framework's EndCommandBuffer, which inserts a | ||||
7048 | // vkEndRenderPass | ||||
7049 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); | ||||
7050 | |||||
7051 | m_errorMonitor->VerifyFound(); | ||||
7052 | |||||
7053 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY | ||||
7054 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT | ||||
7055 | } | ||||
7056 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7057 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7058 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7059 | m_errorMonitor->SetDesiredFailureMsg( |
7060 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7061 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7062 | |
7063 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7064 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7065 | |
7066 | // Renderpass is started here | ||||
7067 | BeginCommandBuffer(); | ||||
7068 | |||||
7069 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7070 | vk_testing::Buffer dstBuffer; |
7071 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7072 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7073 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7074 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7075 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7076 | } |
7077 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7078 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7079 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7080 | m_errorMonitor->SetDesiredFailureMsg( |
7081 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7082 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7083 | |
7084 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7085 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7086 | |
7087 | // Renderpass is started here | ||||
7088 | BeginCommandBuffer(); | ||||
7089 | |||||
7090 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7091 | vk_testing::Buffer dstBuffer; |
7092 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7093 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7094 | VkDeviceSize dstOffset = 0; |
7095 | VkDeviceSize dataSize = 1024; | ||||
7096 | const uint32_t *pData = NULL; | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7097 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7098 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
7099 | dstOffset, dataSize, pData); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7100 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7101 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7102 | } |
7103 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7104 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7105 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7106 | m_errorMonitor->SetDesiredFailureMsg( |
7107 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7108 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7109 | |
7110 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7111 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7112 | |
7113 | // Renderpass is started here | ||||
7114 | BeginCommandBuffer(); | ||||
7115 | |||||
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 7116 | VkClearColorValue clear_color; |
7117 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7118 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
7119 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
7120 | const int32_t tex_width = 32; | ||||
7121 | const int32_t tex_height = 32; | ||||
7122 | VkImageCreateInfo image_create_info = {}; | ||||
7123 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
7124 | image_create_info.pNext = NULL; | ||||
7125 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
7126 | image_create_info.format = tex_format; | ||||
7127 | image_create_info.extent.width = tex_width; | ||||
7128 | image_create_info.extent.height = tex_height; | ||||
7129 | image_create_info.extent.depth = 1; | ||||
7130 | image_create_info.mipLevels = 1; | ||||
7131 | image_create_info.arrayLayers = 1; | ||||
7132 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
7133 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
7134 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7135 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7136 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7137 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
7138 | reqs); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7139 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7140 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
7141 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7142 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7143 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
7144 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7145 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7146 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7147 | } |
7148 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7149 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7150 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7151 | m_errorMonitor->SetDesiredFailureMsg( |
7152 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7153 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7154 | |
7155 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7156 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7157 | |
7158 | // Renderpass is started here | ||||
7159 | BeginCommandBuffer(); | ||||
7160 | |||||
7161 | VkClearDepthStencilValue clear_value = {0}; | ||||
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 7162 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7163 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
7164 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
7165 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
7166 | image_create_info.extent.width = 64; | ||||
7167 | image_create_info.extent.height = 64; | ||||
7168 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
7169 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7170 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7171 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7172 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
7173 | reqs); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7174 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7175 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
7176 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7177 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7178 | vkCmdClearDepthStencilImage( |
7179 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), | ||||
7180 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, | ||||
7181 | &range); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7182 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7183 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7184 | } |
7185 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7186 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 7187 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7188 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7189 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7190 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7191 | "vkCmdClearAttachments: This call " |
7192 | "must be issued inside an active " | ||||
7193 | "render pass"); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7194 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7195 | ASSERT_NO_FATAL_FAILURE(InitState()); |
7196 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7197 | |
7198 | // Start no RenderPass | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7199 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7200 | ASSERT_VK_SUCCESS(err); |
7201 | |||||
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 7202 | VkClearAttachment color_attachment; |
7203 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
7204 | color_attachment.clearValue.color.float32[0] = 0; | ||||
7205 | color_attachment.clearValue.color.float32[1] = 0; | ||||
7206 | color_attachment.clearValue.color.float32[2] = 0; | ||||
7207 | color_attachment.clearValue.color.float32[3] = 0; | ||||
7208 | color_attachment.colorAttachment = 0; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7209 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
7210 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, | ||||
7211 | &color_attachment, 1, &clear_rect); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7212 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7213 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 7214 | } |
7215 | |||||
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 7216 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
7217 | // Try to add a buffer memory barrier with no buffer. | ||||
7218 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7219 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7220 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); | ||||
7221 | |||||
7222 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7223 | BeginCommandBuffer(); | ||||
7224 | |||||
7225 | VkBufferMemoryBarrier buf_barrier = {}; | ||||
7226 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; | ||||
7227 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
7228 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
7229 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
7230 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
7231 | buf_barrier.buffer = VK_NULL_HANDLE; | ||||
7232 | buf_barrier.offset = 0; | ||||
7233 | buf_barrier.size = VK_WHOLE_SIZE; | ||||
7234 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
7235 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, | ||||
7236 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); | ||||
7237 | |||||
7238 | m_errorMonitor->VerifyFound(); | ||||
7239 | } | ||||
7240 | |||||
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 7241 | TEST_F(VkLayerTest, InvalidBarriers) { |
7242 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); | ||||
7243 | |||||
7244 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7245 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); | ||||
7246 | |||||
7247 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7248 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
7249 | |||||
7250 | VkMemoryBarrier mem_barrier = {}; | ||||
7251 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; | ||||
7252 | mem_barrier.pNext = NULL; | ||||
7253 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
7254 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
7255 | BeginCommandBuffer(); | ||||
7256 | // BeginCommandBuffer() starts a render pass | ||||
7257 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
7258 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
7259 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, | ||||
7260 | &mem_barrier, 0, nullptr, 0, nullptr); | ||||
7261 | m_errorMonitor->VerifyFound(); | ||||
7262 | |||||
7263 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7264 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7265 | "Image Layout cannot be transitioned to UNDEFINED"); | ||||
7266 | VkImageObj image(m_device); | ||||
7267 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
7268 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); | ||||
7269 | ASSERT_TRUE(image.initialized()); | ||||
7270 | VkImageMemoryBarrier img_barrier = {}; | ||||
7271 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; | ||||
7272 | img_barrier.pNext = NULL; | ||||
7273 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
7274 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
7275 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
7276 | // New layout can't be UNDEFINED | ||||
7277 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; | ||||
7278 | img_barrier.image = image.handle(); | ||||
7279 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
7280 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
7281 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
7282 | img_barrier.subresourceRange.baseArrayLayer = 0; | ||||
7283 | img_barrier.subresourceRange.baseMipLevel = 0; | ||||
7284 | img_barrier.subresourceRange.layerCount = 1; | ||||
7285 | img_barrier.subresourceRange.levelCount = 1; | ||||
7286 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
7287 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
7288 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
7289 | nullptr, 1, &img_barrier); | ||||
7290 | m_errorMonitor->VerifyFound(); | ||||
7291 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
7292 | |||||
7293 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7294 | "Subresource must have the sum of the " | ||||
7295 | "baseArrayLayer"); | ||||
7296 | // baseArrayLayer + layerCount must be <= image's arrayLayers | ||||
7297 | img_barrier.subresourceRange.baseArrayLayer = 1; | ||||
7298 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
7299 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
7300 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
7301 | nullptr, 1, &img_barrier); | ||||
7302 | m_errorMonitor->VerifyFound(); | ||||
7303 | img_barrier.subresourceRange.baseArrayLayer = 0; | ||||
7304 | |||||
7305 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7306 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7307 | "Subresource must have the sum of the baseMipLevel"); | ||||
7308 | // baseMipLevel + levelCount must be <= image's mipLevels | ||||
7309 | img_barrier.subresourceRange.baseMipLevel = 1; | ||||
7310 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
7311 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
7312 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
7313 | nullptr, 1, &img_barrier); | ||||
7314 | m_errorMonitor->VerifyFound(); | ||||
7315 | img_barrier.subresourceRange.baseMipLevel = 0; | ||||
7316 | |||||
7317 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7318 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7319 | "Buffer Barriers cannot be used during a render pass"); | ||||
7320 | vk_testing::Buffer buffer; | ||||
7321 | buffer.init(*m_device, 256); | ||||
7322 | VkBufferMemoryBarrier buf_barrier = {}; | ||||
7323 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; | ||||
7324 | buf_barrier.pNext = NULL; | ||||
7325 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
7326 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
7327 | buf_barrier.buffer = buffer.handle(); | ||||
7328 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
7329 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
7330 | buf_barrier.offset = 0; | ||||
7331 | buf_barrier.size = VK_WHOLE_SIZE; | ||||
7332 | // Can't send buffer barrier during a render pass | ||||
7333 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
7334 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
7335 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, | ||||
7336 | &buf_barrier, 0, nullptr); | ||||
7337 | m_errorMonitor->VerifyFound(); | ||||
7338 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); | ||||
7339 | |||||
7340 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7341 | "which is not less than total size"); | ||||
7342 | buf_barrier.offset = 257; | ||||
7343 | // Offset greater than total size | ||||
7344 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
7345 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
7346 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, | ||||
7347 | &buf_barrier, 0, nullptr); | ||||
7348 | m_errorMonitor->VerifyFound(); | ||||
7349 | buf_barrier.offset = 0; | ||||
7350 | |||||
7351 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7352 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); | ||||
7353 | buf_barrier.size = 257; | ||||
7354 | // Size greater than total size | ||||
7355 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
7356 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
7357 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, | ||||
7358 | &buf_barrier, 0, nullptr); | ||||
7359 | m_errorMonitor->VerifyFound(); | ||||
7360 | buf_barrier.size = VK_WHOLE_SIZE; | ||||
7361 | |||||
7362 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7363 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7364 | "Image is a depth and stencil format and thus must " | ||||
7365 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " | ||||
7366 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); | ||||
7367 | VkDepthStencilObj ds_image(m_device); | ||||
7368 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); | ||||
7369 | ASSERT_TRUE(ds_image.initialized()); | ||||
7370 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
7371 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
7372 | img_barrier.image = ds_image.handle(); | ||||
7373 | // Leave aspectMask at COLOR on purpose | ||||
7374 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
7375 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
7376 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
7377 | nullptr, 1, &img_barrier); | ||||
7378 | m_errorMonitor->VerifyFound(); | ||||
7379 | } | ||||
7380 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7381 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7382 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7383 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7384 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7385 | m_errorMonitor->SetDesiredFailureMsg( |
7386 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7387 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
7388 | |||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7389 | ASSERT_NO_FATAL_FAILURE(InitState()); |
7390 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7391 | uint32_t qfi = 0; |
7392 | VkBufferCreateInfo buffCI = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7393 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
7394 | buffCI.size = 1024; | ||||
7395 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; | ||||
7396 | buffCI.queueFamilyIndexCount = 1; | ||||
7397 | buffCI.pQueueFamilyIndices = &qfi; | ||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7398 | |
7399 | VkBuffer ib; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7400 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7401 | ASSERT_VK_SUCCESS(err); |
7402 | |||||
7403 | BeginCommandBuffer(); | ||||
7404 | ASSERT_VK_SUCCESS(err); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7405 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
7406 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7407 | // 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] | 7408 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
7409 | VK_INDEX_TYPE_UINT16); | ||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7410 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7411 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7412 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7413 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 7414 | } |
7415 | |||||
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7416 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
7417 | // Create an out-of-range queueFamilyIndex | ||||
7418 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7419 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 7420 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
7421 | "of the indices specified when the device was created, via the " | ||||
7422 | "VkDeviceQueueCreateInfo structure."); | ||||
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7423 | |
7424 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7425 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
7426 | VkBufferCreateInfo buffCI = {}; | ||||
7427 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
7428 | buffCI.size = 1024; | ||||
7429 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; | ||||
7430 | buffCI.queueFamilyIndexCount = 1; | ||||
7431 | // Introduce failure by specifying invalid queue_family_index | ||||
7432 | uint32_t qfi = 777; | ||||
7433 | buffCI.pQueueFamilyIndices = &qfi; | ||||
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 7434 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7435 | |
7436 | VkBuffer ib; | ||||
7437 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); | ||||
7438 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7439 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7440 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7441 | } |
7442 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7443 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
7444 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be | ||||
7445 | // secondary) | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7446 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7447 | m_errorMonitor->SetDesiredFailureMsg( |
7448 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7449 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7450 | |
7451 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7452 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7453 | |
7454 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7455 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7456 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
7457 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); | ||||
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7458 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7459 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7460 | } |
7461 | |||||
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7462 | TEST_F(VkLayerTest, DSUsageBitsErrors) { |
7463 | TEST_DESCRIPTION("Attempt to update descriptor sets for images and buffers " | ||||
7464 | "that do not have correct usage bits sets."); | ||||
7465 | VkResult err; | ||||
7466 | |||||
7467 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7468 | VkDescriptorPoolSize ds_type_count[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; | ||||
7469 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { | ||||
7470 | ds_type_count[i].type = VkDescriptorType(i); | ||||
7471 | ds_type_count[i].descriptorCount = 1; | ||||
7472 | } | ||||
7473 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
7474 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
7475 | ds_pool_ci.pNext = NULL; | ||||
7476 | ds_pool_ci.maxSets = VK_DESCRIPTOR_TYPE_RANGE_SIZE; | ||||
7477 | ds_pool_ci.poolSizeCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; | ||||
7478 | ds_pool_ci.pPoolSizes = ds_type_count; | ||||
7479 | |||||
7480 | VkDescriptorPool ds_pool; | ||||
7481 | err = | ||||
7482 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
7483 | ASSERT_VK_SUCCESS(err); | ||||
7484 | |||||
7485 | // Create 10 layouts where each has a single descriptor of different type | ||||
7486 | VkDescriptorSetLayoutBinding dsl_binding[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = | ||||
7487 | {}; | ||||
7488 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { | ||||
7489 | dsl_binding[i].binding = 0; | ||||
7490 | dsl_binding[i].descriptorType = VkDescriptorType(i); | ||||
7491 | dsl_binding[i].descriptorCount = 1; | ||||
7492 | dsl_binding[i].stageFlags = VK_SHADER_STAGE_ALL; | ||||
7493 | dsl_binding[i].pImmutableSamplers = NULL; | ||||
7494 | } | ||||
7495 | |||||
7496 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
7497 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
7498 | ds_layout_ci.pNext = NULL; | ||||
7499 | ds_layout_ci.bindingCount = 1; | ||||
7500 | VkDescriptorSetLayout ds_layouts[VK_DESCRIPTOR_TYPE_RANGE_SIZE]; | ||||
7501 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { | ||||
7502 | ds_layout_ci.pBindings = dsl_binding + i; | ||||
7503 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, | ||||
7504 | NULL, ds_layouts + i); | ||||
7505 | ASSERT_VK_SUCCESS(err); | ||||
7506 | } | ||||
7507 | VkDescriptorSet descriptor_sets[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; | ||||
7508 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
7509 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
7510 | alloc_info.descriptorSetCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; | ||||
7511 | alloc_info.descriptorPool = ds_pool; | ||||
7512 | alloc_info.pSetLayouts = ds_layouts; | ||||
7513 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
7514 | descriptor_sets); | ||||
7515 | ASSERT_VK_SUCCESS(err); | ||||
7516 | |||||
7517 | // Create a buffer & bufferView to be used for invalid updates | ||||
7518 | VkBufferCreateInfo buff_ci = {}; | ||||
7519 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
7520 | // This usage is not valid for any descriptor type | ||||
7521 | buff_ci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; | ||||
7522 | buff_ci.size = 256; | ||||
7523 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
7524 | VkBuffer buffer; | ||||
7525 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); | ||||
7526 | ASSERT_VK_SUCCESS(err); | ||||
7527 | |||||
7528 | VkBufferViewCreateInfo buff_view_ci = {}; | ||||
7529 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; | ||||
7530 | buff_view_ci.buffer = buffer; | ||||
7531 | buff_view_ci.format = VK_FORMAT_R8_UNORM; | ||||
7532 | buff_view_ci.range = VK_WHOLE_SIZE; | ||||
7533 | VkBufferView buff_view; | ||||
7534 | err = | ||||
7535 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); | ||||
7536 | ASSERT_VK_SUCCESS(err); | ||||
7537 | |||||
7538 | // Create an image to be used for invalid updates | ||||
7539 | VkImageCreateInfo image_ci = {}; | ||||
7540 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
7541 | image_ci.imageType = VK_IMAGE_TYPE_2D; | ||||
7542 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
7543 | image_ci.extent.width = 64; | ||||
7544 | image_ci.extent.height = 64; | ||||
7545 | image_ci.extent.depth = 1; | ||||
7546 | image_ci.mipLevels = 1; | ||||
7547 | image_ci.arrayLayers = 1; | ||||
7548 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
7549 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; | ||||
7550 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | ||||
7551 | // This usage is not valid for any descriptor type | ||||
7552 | image_ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
7553 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
7554 | VkImage image; | ||||
7555 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); | ||||
7556 | ASSERT_VK_SUCCESS(err); | ||||
7557 | // Bind memory to image | ||||
7558 | VkMemoryRequirements mem_reqs; | ||||
7559 | VkDeviceMemory image_mem; | ||||
7560 | bool pass; | ||||
7561 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
7562 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
7563 | mem_alloc.pNext = NULL; | ||||
7564 | mem_alloc.allocationSize = 0; | ||||
7565 | mem_alloc.memoryTypeIndex = 0; | ||||
7566 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
7567 | mem_alloc.allocationSize = mem_reqs.size; | ||||
7568 | pass = | ||||
7569 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
7570 | ASSERT_TRUE(pass); | ||||
7571 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); | ||||
7572 | ASSERT_VK_SUCCESS(err); | ||||
7573 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); | ||||
7574 | ASSERT_VK_SUCCESS(err); | ||||
7575 | // Now create view for image | ||||
7576 | VkImageViewCreateInfo image_view_ci = {}; | ||||
7577 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
7578 | image_view_ci.image = image; | ||||
7579 | image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
7580 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
7581 | image_view_ci.subresourceRange.layerCount = 1; | ||||
7582 | image_view_ci.subresourceRange.baseArrayLayer = 0; | ||||
7583 | image_view_ci.subresourceRange.levelCount = 1; | ||||
7584 | image_view_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
7585 | VkImageView image_view; | ||||
7586 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, | ||||
7587 | &image_view); | ||||
7588 | ASSERT_VK_SUCCESS(err); | ||||
7589 | |||||
7590 | VkDescriptorBufferInfo buff_info = {}; | ||||
7591 | buff_info.buffer = buffer; | ||||
7592 | VkDescriptorImageInfo img_info = {}; | ||||
7593 | img_info.imageView = image_view; | ||||
7594 | VkWriteDescriptorSet descriptor_write = {}; | ||||
7595 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
7596 | descriptor_write.dstBinding = 0; | ||||
7597 | descriptor_write.descriptorCount = 1; | ||||
7598 | descriptor_write.pTexelBufferView = &buff_view; | ||||
7599 | descriptor_write.pBufferInfo = &buff_info; | ||||
7600 | descriptor_write.pImageInfo = &img_info; | ||||
7601 | |||||
7602 | // These error messages align with VkDescriptorType struct | ||||
7603 | const char *error_msgs[] = { | ||||
7604 | "", // placeholder, no error for SAMPLER descriptor | ||||
7605 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", | ||||
7606 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", | ||||
7607 | " does not have VK_IMAGE_USAGE_STORAGE_BIT set.", | ||||
7608 | " does not have VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT set.", | ||||
7609 | " does not have VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT set.", | ||||
7610 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", | ||||
7611 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", | ||||
7612 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", | ||||
7613 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", | ||||
7614 | " does not have VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set."}; | ||||
7615 | // Start loop at 1 as SAMPLER desc type has no usage bit error | ||||
7616 | for (uint32_t i = 1; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { | ||||
7617 | descriptor_write.descriptorType = VkDescriptorType(i); | ||||
7618 | descriptor_write.dstSet = descriptor_sets[i]; | ||||
7619 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7620 | error_msgs[i]); | ||||
7621 | |||||
7622 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, | ||||
7623 | NULL); | ||||
7624 | |||||
7625 | m_errorMonitor->VerifyFound(); | ||||
7626 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[i], NULL); | ||||
7627 | } | ||||
7628 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[0], NULL); | ||||
7629 | vkDestroyImage(m_device->device(), image, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7630 | vkFreeMemory(m_device->device(), image_mem, NULL); |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 7631 | vkDestroyImageView(m_device->device(), image_view, NULL); |
7632 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
7633 | vkDestroyBufferView(m_device->device(), buff_view, NULL); | ||||
7634 | vkFreeDescriptorSets(m_device->device(), ds_pool, | ||||
7635 | VK_DESCRIPTOR_TYPE_RANGE_SIZE, descriptor_sets); | ||||
7636 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
7637 | } | ||||
7638 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7639 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7640 | // 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] | 7641 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7642 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7643 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7644 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
7645 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " | ||||
7646 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7647 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7648 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7649 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7650 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7651 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
7652 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7653 | |
7654 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7655 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
7656 | ds_pool_ci.pNext = NULL; | ||||
7657 | ds_pool_ci.maxSets = 1; | ||||
7658 | ds_pool_ci.poolSizeCount = 1; | ||||
7659 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7660 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7661 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7662 | err = |
7663 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7664 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7665 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7666 | dsl_binding.binding = 0; |
7667 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
7668 | dsl_binding.descriptorCount = 1; | ||||
7669 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
7670 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7671 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7672 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7673 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
7674 | ds_layout_ci.pNext = NULL; | ||||
7675 | ds_layout_ci.bindingCount = 1; | ||||
7676 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7677 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7678 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7679 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
7680 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7681 | ASSERT_VK_SUCCESS(err); |
7682 | |||||
7683 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7684 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7685 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7686 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7687 | alloc_info.descriptorPool = ds_pool; |
7688 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7689 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
7690 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7691 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7692 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7693 | VkSamplerCreateInfo sampler_ci = {}; |
7694 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; | ||||
7695 | sampler_ci.pNext = NULL; | ||||
7696 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
7697 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
7698 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
7699 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
7700 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
7701 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
7702 | sampler_ci.mipLodBias = 1.0; | ||||
7703 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
7704 | sampler_ci.maxAnisotropy = 1; | ||||
7705 | sampler_ci.compareEnable = VK_FALSE; | ||||
7706 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
7707 | sampler_ci.minLod = 1.0; | ||||
7708 | sampler_ci.maxLod = 1.0; | ||||
7709 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
7710 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
7711 | VkSampler sampler; | ||||
7712 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); | ||||
7713 | ASSERT_VK_SUCCESS(err); | ||||
7714 | |||||
7715 | VkDescriptorImageInfo info = {}; | ||||
7716 | info.sampler = sampler; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7717 | |
7718 | VkWriteDescriptorSet descriptor_write; | ||||
7719 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
7720 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7721 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7722 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7723 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7724 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7725 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7726 | |
7727 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
7728 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7729 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7730 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7731 | vkDestroySampler(m_device->device(), sampler, NULL); |
7732 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
7733 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7734 | } |
7735 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7736 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7737 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7738 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7739 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7740 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7741 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
7742 | " binding #0 with 1 total descriptors but update of 1 descriptors " | ||||
7743 | "starting at binding offset of 0 combined with update array element " | ||||
7744 | "offset of 1 oversteps the size of this descriptor set."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7745 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7746 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7747 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7748 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7749 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
7750 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7751 | |
7752 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7753 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
7754 | ds_pool_ci.pNext = NULL; | ||||
7755 | ds_pool_ci.maxSets = 1; | ||||
7756 | ds_pool_ci.poolSizeCount = 1; | ||||
7757 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7758 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7759 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7760 | err = |
7761 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7762 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7763 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7764 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7765 | dsl_binding.binding = 0; |
7766 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
7767 | dsl_binding.descriptorCount = 1; | ||||
7768 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
7769 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7770 | |
7771 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7772 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
7773 | ds_layout_ci.pNext = NULL; | ||||
7774 | ds_layout_ci.bindingCount = 1; | ||||
7775 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7776 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7777 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7778 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
7779 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7780 | ASSERT_VK_SUCCESS(err); |
7781 | |||||
7782 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7783 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7784 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7785 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7786 | alloc_info.descriptorPool = ds_pool; |
7787 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7788 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
7789 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7790 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7791 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7792 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
7793 | VkDescriptorBufferInfo buff_info = {}; | ||||
7794 | buff_info.buffer = | ||||
7795 | VkBuffer(0); // Don't care about buffer handle for this test | ||||
7796 | buff_info.offset = 0; | ||||
7797 | buff_info.range = 1024; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7798 | |
7799 | VkWriteDescriptorSet descriptor_write; | ||||
7800 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
7801 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7802 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7803 | descriptor_write.dstArrayElement = |
7804 | 1; /* This index out of bounds for the update */ | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7805 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7806 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
7807 | descriptor_write.pBufferInfo = &buff_info; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7808 | |
7809 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
7810 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7811 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7812 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7813 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
7814 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7815 | } |
7816 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7817 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
7818 | // Create layout w/ count of 1 and attempt update to that layout w/ binding | ||||
7819 | // index 2 | ||||
7820 | VkResult err; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7821 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7822 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
7823 | " does not have binding 2."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7824 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7825 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7826 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7827 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7828 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
7829 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7830 | |
7831 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7832 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
7833 | ds_pool_ci.pNext = NULL; | ||||
7834 | ds_pool_ci.maxSets = 1; | ||||
7835 | ds_pool_ci.poolSizeCount = 1; | ||||
7836 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7837 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7838 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7839 | err = |
7840 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7841 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7842 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7843 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7844 | dsl_binding.binding = 0; |
7845 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
7846 | dsl_binding.descriptorCount = 1; | ||||
7847 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
7848 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7849 | |
7850 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7851 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
7852 | ds_layout_ci.pNext = NULL; | ||||
7853 | ds_layout_ci.bindingCount = 1; | ||||
7854 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7855 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7856 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
7857 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7858 | ASSERT_VK_SUCCESS(err); |
7859 | |||||
7860 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7861 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7862 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7863 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7864 | alloc_info.descriptorPool = ds_pool; |
7865 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7866 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
7867 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7868 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7869 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7870 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7871 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
7872 | sampler_ci.pNext = NULL; | ||||
7873 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
7874 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
7875 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
7876 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
7877 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
7878 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
7879 | sampler_ci.mipLodBias = 1.0; | ||||
7880 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
7881 | sampler_ci.maxAnisotropy = 1; | ||||
7882 | sampler_ci.compareEnable = VK_FALSE; | ||||
7883 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
7884 | sampler_ci.minLod = 1.0; | ||||
7885 | sampler_ci.maxLod = 1.0; | ||||
7886 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
7887 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7888 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7889 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7890 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7891 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7892 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7893 | VkDescriptorImageInfo info = {}; |
7894 | info.sampler = sampler; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7895 | |
7896 | VkWriteDescriptorSet descriptor_write; | ||||
7897 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
7898 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7899 | descriptor_write.dstSet = descriptorSet; |
7900 | descriptor_write.dstBinding = 2; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7901 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7902 | // 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] | 7903 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7904 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7905 | |
7906 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
7907 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7908 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7909 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7910 | vkDestroySampler(m_device->device(), sampler, NULL); |
7911 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
7912 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7913 | } |
7914 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7915 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
7916 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* | ||||
7917 | // types | ||||
7918 | VkResult err; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7919 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7920 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 7921 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7922 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7923 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7924 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7925 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7926 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
7927 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7928 | |
7929 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7930 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
7931 | ds_pool_ci.pNext = NULL; | ||||
7932 | ds_pool_ci.maxSets = 1; | ||||
7933 | ds_pool_ci.poolSizeCount = 1; | ||||
7934 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7935 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7936 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7937 | err = |
7938 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7939 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7940 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7941 | dsl_binding.binding = 0; |
7942 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
7943 | dsl_binding.descriptorCount = 1; | ||||
7944 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
7945 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7946 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7947 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7948 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
7949 | ds_layout_ci.pNext = NULL; | ||||
7950 | ds_layout_ci.bindingCount = 1; | ||||
7951 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7952 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7953 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7954 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
7955 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7956 | ASSERT_VK_SUCCESS(err); |
7957 | |||||
7958 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7959 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7960 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7961 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7962 | alloc_info.descriptorPool = ds_pool; |
7963 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7964 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
7965 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7966 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7967 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7968 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7969 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
7970 | sampler_ci.pNext = NULL; | ||||
7971 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
7972 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
7973 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
7974 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
7975 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
7976 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
7977 | sampler_ci.mipLodBias = 1.0; | ||||
7978 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
7979 | sampler_ci.maxAnisotropy = 1; | ||||
7980 | sampler_ci.compareEnable = VK_FALSE; | ||||
7981 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
7982 | sampler_ci.minLod = 1.0; | ||||
7983 | sampler_ci.maxLod = 1.0; | ||||
7984 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
7985 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7986 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7987 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7988 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7989 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7990 | VkDescriptorImageInfo info = {}; |
7991 | info.sampler = sampler; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7992 | |
7993 | VkWriteDescriptorSet descriptor_write; | ||||
7994 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7995 | descriptor_write.sType = |
7996 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7997 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7998 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7999 | // 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] | 8000 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 8001 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 8002 | |
8003 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
8004 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8005 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8006 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8007 | vkDestroySampler(m_device->device(), sampler, NULL); |
8008 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8009 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8010 | } |
8011 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8012 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8013 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8014 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8015 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8016 | m_errorMonitor->SetDesiredFailureMsg( |
8017 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8018 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8019 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8020 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8021 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
8022 | // code | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8023 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8024 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
8025 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8026 | |
8027 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8028 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8029 | ds_pool_ci.pNext = NULL; | ||||
8030 | ds_pool_ci.maxSets = 1; | ||||
8031 | ds_pool_ci.poolSizeCount = 1; | ||||
8032 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8033 | |
8034 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8035 | err = |
8036 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8037 | ASSERT_VK_SUCCESS(err); |
8038 | |||||
8039 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8040 | dsl_binding.binding = 0; |
8041 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
8042 | dsl_binding.descriptorCount = 1; | ||||
8043 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
8044 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8045 | |
8046 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8047 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
8048 | ds_layout_ci.pNext = NULL; | ||||
8049 | ds_layout_ci.bindingCount = 1; | ||||
8050 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8051 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8052 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8053 | &ds_layout); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8054 | ASSERT_VK_SUCCESS(err); |
8055 | |||||
8056 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8057 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8058 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8059 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8060 | alloc_info.descriptorPool = ds_pool; |
8061 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8062 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
8063 | &descriptorSet); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8064 | ASSERT_VK_SUCCESS(err); |
8065 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8066 | VkSampler sampler = |
8067 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8068 | |
8069 | VkDescriptorImageInfo descriptor_info; | ||||
8070 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); | ||||
8071 | descriptor_info.sampler = sampler; | ||||
8072 | |||||
8073 | VkWriteDescriptorSet descriptor_write; | ||||
8074 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
8075 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8076 | descriptor_write.dstSet = descriptorSet; |
8077 | descriptor_write.dstBinding = 0; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8078 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8079 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
8080 | descriptor_write.pImageInfo = &descriptor_info; | ||||
8081 | |||||
8082 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
8083 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8084 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8085 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8086 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
8087 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8088 | } |
8089 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8090 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
8091 | // Create a single combined Image/Sampler descriptor and send it an invalid | ||||
8092 | // imageView | ||||
8093 | VkResult err; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8094 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8095 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
8096 | "Attempted write update to combined " | ||||
8097 | "image sampler descriptor failed due " | ||||
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 8098 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8099 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8100 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8101 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8102 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
8103 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8104 | |
8105 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8106 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8107 | ds_pool_ci.pNext = NULL; | ||||
8108 | ds_pool_ci.maxSets = 1; | ||||
8109 | ds_pool_ci.poolSizeCount = 1; | ||||
8110 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8111 | |
8112 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8113 | err = |
8114 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8115 | ASSERT_VK_SUCCESS(err); |
8116 | |||||
8117 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8118 | dsl_binding.binding = 0; |
8119 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; | ||||
8120 | dsl_binding.descriptorCount = 1; | ||||
8121 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
8122 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8123 | |
8124 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8125 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
8126 | ds_layout_ci.pNext = NULL; | ||||
8127 | ds_layout_ci.bindingCount = 1; | ||||
8128 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8129 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8130 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8131 | &ds_layout); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8132 | ASSERT_VK_SUCCESS(err); |
8133 | |||||
8134 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8135 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8136 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8137 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8138 | alloc_info.descriptorPool = ds_pool; |
8139 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8140 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
8141 | &descriptorSet); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8142 | ASSERT_VK_SUCCESS(err); |
8143 | |||||
8144 | VkSamplerCreateInfo sampler_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8145 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
8146 | sampler_ci.pNext = NULL; | ||||
8147 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
8148 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
8149 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
8150 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
8151 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
8152 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
8153 | sampler_ci.mipLodBias = 1.0; | ||||
8154 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
8155 | sampler_ci.maxAnisotropy = 1; | ||||
8156 | sampler_ci.compareEnable = VK_FALSE; | ||||
8157 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
8158 | sampler_ci.minLod = 1.0; | ||||
8159 | sampler_ci.maxLod = 1.0; | ||||
8160 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
8161 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8162 | |
8163 | VkSampler sampler; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8164 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8165 | ASSERT_VK_SUCCESS(err); |
8166 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8167 | VkImageView view = |
8168 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8169 | |
8170 | VkDescriptorImageInfo descriptor_info; | ||||
8171 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); | ||||
8172 | descriptor_info.sampler = sampler; | ||||
8173 | descriptor_info.imageView = view; | ||||
8174 | |||||
8175 | VkWriteDescriptorSet descriptor_write; | ||||
8176 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
8177 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8178 | descriptor_write.dstSet = descriptorSet; |
8179 | descriptor_write.dstBinding = 0; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8180 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8181 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
8182 | descriptor_write.pImageInfo = &descriptor_info; | ||||
8183 | |||||
8184 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
8185 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8186 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8187 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8188 | vkDestroySampler(m_device->device(), sampler, NULL); |
8189 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8190 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8191 | } |
8192 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8193 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
8194 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update | ||||
8195 | // into the other | ||||
8196 | VkResult err; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8197 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8198 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
8199 | " binding #1 with type " | ||||
8200 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " | ||||
8201 | "not match."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8202 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8203 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8204 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8205 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8206 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
8207 | ds_type_count[0].descriptorCount = 1; | ||||
8208 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
8209 | ds_type_count[1].descriptorCount = 1; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8210 | |
8211 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8212 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8213 | ds_pool_ci.pNext = NULL; | ||||
8214 | ds_pool_ci.maxSets = 1; | ||||
8215 | ds_pool_ci.poolSizeCount = 2; | ||||
8216 | ds_pool_ci.pPoolSizes = ds_type_count; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8217 | |
8218 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8219 | err = |
8220 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8221 | ASSERT_VK_SUCCESS(err); |
8222 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8223 | dsl_binding[0].binding = 0; |
8224 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8225 | dsl_binding[0].descriptorCount = 1; | ||||
8226 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; | ||||
8227 | dsl_binding[0].pImmutableSamplers = NULL; | ||||
8228 | dsl_binding[1].binding = 1; | ||||
8229 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
8230 | dsl_binding[1].descriptorCount = 1; | ||||
8231 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; | ||||
8232 | dsl_binding[1].pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8233 | |
8234 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8235 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
8236 | ds_layout_ci.pNext = NULL; | ||||
8237 | ds_layout_ci.bindingCount = 2; | ||||
8238 | ds_layout_ci.pBindings = dsl_binding; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8239 | |
8240 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8241 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8242 | &ds_layout); | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8243 | ASSERT_VK_SUCCESS(err); |
8244 | |||||
8245 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8246 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8247 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8248 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8249 | alloc_info.descriptorPool = ds_pool; |
8250 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8251 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
8252 | &descriptorSet); | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8253 | ASSERT_VK_SUCCESS(err); |
8254 | |||||
8255 | VkSamplerCreateInfo sampler_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8256 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
8257 | sampler_ci.pNext = NULL; | ||||
8258 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
8259 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
8260 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
8261 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
8262 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
8263 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
8264 | sampler_ci.mipLodBias = 1.0; | ||||
8265 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
8266 | sampler_ci.maxAnisotropy = 1; | ||||
8267 | sampler_ci.compareEnable = VK_FALSE; | ||||
8268 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
8269 | sampler_ci.minLod = 1.0; | ||||
8270 | sampler_ci.maxLod = 1.0; | ||||
8271 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
8272 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8273 | |
8274 | VkSampler sampler; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8275 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8276 | ASSERT_VK_SUCCESS(err); |
8277 | |||||
8278 | VkDescriptorImageInfo info = {}; | ||||
8279 | info.sampler = sampler; | ||||
8280 | |||||
8281 | VkWriteDescriptorSet descriptor_write; | ||||
8282 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); | ||||
8283 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8284 | descriptor_write.dstSet = descriptorSet; |
8285 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8286 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8287 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
8288 | descriptor_write.pImageInfo = &info; | ||||
8289 | // This write update should succeed | ||||
8290 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
8291 | // Now perform a copy update that fails due to type mismatch | ||||
8292 | VkCopyDescriptorSet copy_ds_update; | ||||
8293 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); | ||||
8294 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; | ||||
8295 | copy_ds_update.srcSet = descriptorSet; | ||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8296 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8297 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8298 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8299 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8300 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
8301 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8302 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8303 | // 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] | 8304 | m_errorMonitor->SetDesiredFailureMsg( |
8305 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8306 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8307 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
8308 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; | ||||
8309 | copy_ds_update.srcSet = descriptorSet; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8310 | copy_ds_update.srcBinding = |
8311 | 3; // ERROR : Invalid binding for matching layout | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8312 | copy_ds_update.dstSet = descriptorSet; |
8313 | copy_ds_update.dstBinding = 0; | ||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8314 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8315 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
8316 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8317 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8318 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8319 | // 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] | 8320 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 8321 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
8322 | "update array offset of 0 and update of " | ||||
8323 | "5 descriptors oversteps total number " | ||||
8324 | "of descriptors in set: 2."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8325 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8326 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
8327 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; | ||||
8328 | copy_ds_update.srcSet = descriptorSet; | ||||
8329 | copy_ds_update.srcBinding = 1; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8330 | copy_ds_update.dstSet = descriptorSet; |
8331 | copy_ds_update.dstBinding = 0; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8332 | copy_ds_update.descriptorCount = |
8333 | 5; // ERROR copy 5 descriptors (out of bounds for layout) | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8334 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
8335 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8336 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8337 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8338 | vkDestroySampler(m_device->device(), sampler, NULL); |
8339 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8340 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 8341 | } |
8342 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8343 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
8344 | // Create CommandBuffer where MSAA samples doesn't match RenderPass | ||||
8345 | // sampleCount | ||||
8346 | VkResult err; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8347 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8348 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8349 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8350 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8351 | ASSERT_NO_FATAL_FAILURE(InitState()); |
8352 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8353 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8354 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8355 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8356 | |
8357 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8358 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8359 | ds_pool_ci.pNext = NULL; | ||||
8360 | ds_pool_ci.maxSets = 1; | ||||
8361 | ds_pool_ci.poolSizeCount = 1; | ||||
8362 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8363 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8364 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8365 | err = |
8366 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8367 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8368 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8369 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8370 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8371 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 8372 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8373 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
8374 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8375 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8376 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
8377 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
8378 | ds_layout_ci.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8379 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 8380 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8381 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8382 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8383 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8384 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8385 | ASSERT_VK_SUCCESS(err); |
8386 | |||||
8387 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8388 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8389 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8390 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8391 | alloc_info.descriptorPool = ds_pool; |
8392 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8393 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
8394 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8395 | ASSERT_VK_SUCCESS(err); |
8396 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8397 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8398 | pipe_ms_state_ci.sType = |
8399 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
8400 | pipe_ms_state_ci.pNext = NULL; | ||||
8401 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; | ||||
8402 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
8403 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
8404 | pipe_ms_state_ci.pSampleMask = NULL; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8405 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8406 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8407 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
8408 | pipeline_layout_ci.pNext = NULL; | ||||
8409 | pipeline_layout_ci.setLayoutCount = 1; | ||||
8410 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8411 | |
8412 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8413 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8414 | &pipeline_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8415 | ASSERT_VK_SUCCESS(err); |
8416 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8417 | VkShaderObj vs(m_device, bindStateVertShaderText, |
8418 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
8419 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
8420 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8421 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8422 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8423 | VkPipelineObj pipe(m_device); |
8424 | pipe.AddShader(&vs); | ||||
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8425 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8426 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8427 | pipe.SetMSAA(&pipe_ms_state_ci); |
8428 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8429 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8430 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8431 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
8432 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 8433 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8434 | // Render triangle (the error should trigger on the attempt to draw). |
8435 | Draw(3, 1, 0, 0); | ||||
8436 | |||||
8437 | // Finalize recording of the command buffer | ||||
8438 | EndCommandBuffer(); | ||||
8439 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8440 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8441 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8442 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
8443 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8444 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 8445 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8446 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8447 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
8448 | // Create Pipeline where the number of blend attachments doesn't match the | ||||
8449 | // number of color attachments. In this case, we don't add any color | ||||
8450 | // blend attachments even though we have a color attachment. | ||||
8451 | VkResult err; | ||||
8452 | |||||
8453 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8454 | "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] | 8455 | |
8456 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
8457 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
8458 | VkDescriptorPoolSize ds_type_count = {}; | ||||
8459 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8460 | ds_type_count.descriptorCount = 1; | ||||
8461 | |||||
8462 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
8463 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
8464 | ds_pool_ci.pNext = NULL; | ||||
8465 | ds_pool_ci.maxSets = 1; | ||||
8466 | ds_pool_ci.poolSizeCount = 1; | ||||
8467 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
8468 | |||||
8469 | VkDescriptorPool ds_pool; | ||||
8470 | err = | ||||
8471 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
8472 | ASSERT_VK_SUCCESS(err); | ||||
8473 | |||||
8474 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
8475 | dsl_binding.binding = 0; | ||||
8476 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8477 | dsl_binding.descriptorCount = 1; | ||||
8478 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
8479 | dsl_binding.pImmutableSamplers = NULL; | ||||
8480 | |||||
8481 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
8482 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
8483 | ds_layout_ci.pNext = NULL; | ||||
8484 | ds_layout_ci.bindingCount = 1; | ||||
8485 | ds_layout_ci.pBindings = &dsl_binding; | ||||
8486 | |||||
8487 | VkDescriptorSetLayout ds_layout; | ||||
8488 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
8489 | &ds_layout); | ||||
8490 | ASSERT_VK_SUCCESS(err); | ||||
8491 | |||||
8492 | VkDescriptorSet descriptorSet; | ||||
8493 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
8494 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
8495 | alloc_info.descriptorSetCount = 1; | ||||
8496 | alloc_info.descriptorPool = ds_pool; | ||||
8497 | alloc_info.pSetLayouts = &ds_layout; | ||||
8498 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
8499 | &descriptorSet); | ||||
8500 | ASSERT_VK_SUCCESS(err); | ||||
8501 | |||||
8502 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; | ||||
8503 | pipe_ms_state_ci.sType = | ||||
8504 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
8505 | pipe_ms_state_ci.pNext = NULL; | ||||
8506 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; | ||||
8507 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
8508 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
8509 | pipe_ms_state_ci.pSampleMask = NULL; | ||||
8510 | |||||
8511 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
8512 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
8513 | pipeline_layout_ci.pNext = NULL; | ||||
8514 | pipeline_layout_ci.setLayoutCount = 1; | ||||
8515 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
8516 | |||||
8517 | VkPipelineLayout pipeline_layout; | ||||
8518 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
8519 | &pipeline_layout); | ||||
8520 | ASSERT_VK_SUCCESS(err); | ||||
8521 | |||||
8522 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
8523 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
8524 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
8525 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8526 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8527 | // but add it to be able to run on more devices |
8528 | VkPipelineObj pipe(m_device); | ||||
8529 | pipe.AddShader(&vs); | ||||
8530 | pipe.AddShader(&fs); | ||||
8531 | pipe.SetMSAA(&pipe_ms_state_ci); | ||||
8532 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
8533 | |||||
8534 | BeginCommandBuffer(); | ||||
8535 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
8536 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
8537 | |||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8538 | // Render triangle (the error should trigger on the attempt to draw). |
8539 | Draw(3, 1, 0, 0); | ||||
8540 | |||||
8541 | // Finalize recording of the command buffer | ||||
8542 | EndCommandBuffer(); | ||||
8543 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8544 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8545 | |
8546 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
8547 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8548 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
8549 | } | ||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 8550 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 8551 | TEST_F(VkLayerTest, MissingClearAttachment) { |
8552 | TEST_DESCRIPTION("Points to a wrong colorAttachment index in a VkClearAttachment " | ||||
8553 | "structure passed to vkCmdClearAttachments"); | ||||
8554 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8555 | "vkCmdClearAttachments() attachment index 1 not found in attachment " | ||||
8556 | "reference array of active subpass 0"); | ||||
8557 | |||||
8558 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailCmdClearAttachments); | ||||
8559 | m_errorMonitor->VerifyFound(); | ||||
8560 | } | ||||
8561 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8562 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
8563 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior | ||||
8564 | // to issuing a Draw | ||||
8565 | VkResult err; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8566 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8567 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 8568 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8569 | "vkCmdClearAttachments() issued on CB object "); |
8570 | |||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8571 | ASSERT_NO_FATAL_FAILURE(InitState()); |
8572 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8573 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8574 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8575 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
8576 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8577 | |
8578 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8579 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8580 | ds_pool_ci.pNext = NULL; | ||||
8581 | ds_pool_ci.maxSets = 1; | ||||
8582 | ds_pool_ci.poolSizeCount = 1; | ||||
8583 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8584 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8585 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8586 | err = |
8587 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8588 | ASSERT_VK_SUCCESS(err); |
8589 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8590 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8591 | dsl_binding.binding = 0; |
8592 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8593 | dsl_binding.descriptorCount = 1; | ||||
8594 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
8595 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8596 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8597 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8598 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
8599 | ds_layout_ci.pNext = NULL; | ||||
8600 | ds_layout_ci.bindingCount = 1; | ||||
8601 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8602 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8603 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8604 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8605 | &ds_layout); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8606 | ASSERT_VK_SUCCESS(err); |
8607 | |||||
8608 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8609 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8610 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8611 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8612 | alloc_info.descriptorPool = ds_pool; |
8613 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8614 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
8615 | &descriptorSet); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8616 | ASSERT_VK_SUCCESS(err); |
8617 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8618 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8619 | pipe_ms_state_ci.sType = |
8620 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
8621 | pipe_ms_state_ci.pNext = NULL; | ||||
8622 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; | ||||
8623 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
8624 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
8625 | pipe_ms_state_ci.pSampleMask = NULL; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8626 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8627 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8628 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
8629 | pipeline_layout_ci.pNext = NULL; | ||||
8630 | pipeline_layout_ci.setLayoutCount = 1; | ||||
8631 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8632 | |
8633 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8634 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8635 | &pipeline_layout); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8636 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8637 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8638 | VkShaderObj vs(m_device, bindStateVertShaderText, |
8639 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8640 | // 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] | 8641 | // on more devices |
8642 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
8643 | VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8644 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8645 | VkPipelineObj pipe(m_device); |
8646 | pipe.AddShader(&vs); | ||||
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8647 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8648 | pipe.SetMSAA(&pipe_ms_state_ci); |
8649 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8650 | |
8651 | BeginCommandBuffer(); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8652 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8653 | // Main thing we care about for this test is that the VkImage obj we're |
8654 | // clearing matches Color Attachment of FB | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8655 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8656 | VkClearAttachment color_attachment; |
8657 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
8658 | color_attachment.clearValue.color.float32[0] = 1.0; | ||||
8659 | color_attachment.clearValue.color.float32[1] = 1.0; | ||||
8660 | color_attachment.clearValue.color.float32[2] = 1.0; | ||||
8661 | color_attachment.clearValue.color.float32[3] = 1.0; | ||||
8662 | color_attachment.colorAttachment = 0; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8663 | VkClearRect clear_rect = { |
8664 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8665 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8666 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
8667 | &color_attachment, 1, &clear_rect); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8668 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8669 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8670 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8671 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
8672 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8673 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8674 | } |
8675 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8676 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
8677 | VkResult err; | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8678 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8679 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8680 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 8681 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8682 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8683 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8684 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8685 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8686 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8687 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8688 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
8689 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8690 | |
8691 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8692 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8693 | ds_pool_ci.pNext = NULL; | ||||
8694 | ds_pool_ci.maxSets = 1; | ||||
8695 | ds_pool_ci.poolSizeCount = 1; | ||||
8696 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8697 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8698 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8699 | err = |
8700 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8701 | ASSERT_VK_SUCCESS(err); |
8702 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8703 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8704 | dsl_binding.binding = 0; |
8705 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8706 | dsl_binding.descriptorCount = 1; | ||||
8707 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
8708 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8709 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8710 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8711 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
8712 | ds_layout_ci.pNext = NULL; | ||||
8713 | ds_layout_ci.bindingCount = 1; | ||||
8714 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8715 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8716 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8717 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8718 | &ds_layout); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8719 | ASSERT_VK_SUCCESS(err); |
8720 | |||||
8721 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8722 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8723 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8724 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8725 | alloc_info.descriptorPool = ds_pool; |
8726 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8727 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
8728 | &descriptorSet); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8729 | ASSERT_VK_SUCCESS(err); |
8730 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8731 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8732 | pipe_ms_state_ci.sType = |
8733 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
8734 | pipe_ms_state_ci.pNext = NULL; | ||||
8735 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; | ||||
8736 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
8737 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
8738 | pipe_ms_state_ci.pSampleMask = NULL; | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8739 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8740 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8741 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
8742 | pipeline_layout_ci.pNext = NULL; | ||||
8743 | pipeline_layout_ci.setLayoutCount = 1; | ||||
8744 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
8745 | VkPipelineLayout pipeline_layout; | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8746 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8747 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8748 | &pipeline_layout); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8749 | ASSERT_VK_SUCCESS(err); |
8750 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8751 | VkShaderObj vs(m_device, bindStateVertShaderText, |
8752 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
8753 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
8754 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8755 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8756 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8757 | VkPipelineObj pipe(m_device); |
8758 | pipe.AddShader(&vs); | ||||
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8759 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8760 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8761 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8762 | pipe.SetViewport(m_viewports); |
8763 | pipe.SetScissor(m_scissors); | ||||
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8764 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8765 | |
8766 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8767 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
8768 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8769 | // Don't care about actual data, just need to get to draw to flag error |
8770 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8771 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
8772 | (const void *)&vbo_data); | ||||
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8773 | 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] | 8774 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8775 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8776 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8777 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8778 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
8779 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8780 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8781 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8782 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
8783 | TEST_F(VkLayerTest, InvalidImageLayout) { | ||||
8784 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " | ||||
8785 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" | ||||
8786 | "images in the wrong layout when they're copied or transitioned."); | ||||
8787 | // 3 in ValidateCmdBufImageLayouts | ||||
8788 | // * -1 Attempt to submit cmd buf w/ deleted image | ||||
8789 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource | ||||
8790 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource | ||||
8791 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8792 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
8793 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); | ||||
8794 | |||||
8795 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
8796 | // Create src & dst images to use for copy operations | ||||
8797 | VkImage src_image; | ||||
8798 | VkImage dst_image; | ||||
8799 | |||||
8800 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
8801 | const int32_t tex_width = 32; | ||||
8802 | const int32_t tex_height = 32; | ||||
8803 | |||||
8804 | VkImageCreateInfo image_create_info = {}; | ||||
8805 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
8806 | image_create_info.pNext = NULL; | ||||
8807 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
8808 | image_create_info.format = tex_format; | ||||
8809 | image_create_info.extent.width = tex_width; | ||||
8810 | image_create_info.extent.height = tex_height; | ||||
8811 | image_create_info.extent.depth = 1; | ||||
8812 | image_create_info.mipLevels = 1; | ||||
8813 | image_create_info.arrayLayers = 4; | ||||
8814 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
8815 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
8816 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
8817 | image_create_info.flags = 0; | ||||
8818 | |||||
8819 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); | ||||
8820 | ASSERT_VK_SUCCESS(err); | ||||
8821 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); | ||||
8822 | ASSERT_VK_SUCCESS(err); | ||||
8823 | |||||
8824 | BeginCommandBuffer(); | ||||
8825 | VkImageCopy copyRegion; | ||||
8826 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
8827 | copyRegion.srcSubresource.mipLevel = 0; | ||||
8828 | copyRegion.srcSubresource.baseArrayLayer = 0; | ||||
8829 | copyRegion.srcSubresource.layerCount = 1; | ||||
8830 | copyRegion.srcOffset.x = 0; | ||||
8831 | copyRegion.srcOffset.y = 0; | ||||
8832 | copyRegion.srcOffset.z = 0; | ||||
8833 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
8834 | copyRegion.dstSubresource.mipLevel = 0; | ||||
8835 | copyRegion.dstSubresource.baseArrayLayer = 0; | ||||
8836 | copyRegion.dstSubresource.layerCount = 1; | ||||
8837 | copyRegion.dstOffset.x = 0; | ||||
8838 | copyRegion.dstOffset.y = 0; | ||||
8839 | copyRegion.dstOffset.z = 0; | ||||
8840 | copyRegion.extent.width = 1; | ||||
8841 | copyRegion.extent.height = 1; | ||||
8842 | copyRegion.extent.depth = 1; | ||||
8843 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
8844 | m_errorMonitor->VerifyFound(); | ||||
8845 | // Now cause error due to src image layout changing | ||||
8846 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8847 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8848 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); | ||||
8849 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
8850 | m_errorMonitor->VerifyFound(); | ||||
8851 | // Final src error is due to bad layout type | ||||
8852 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8853 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8854 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); | ||||
8855 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
8856 | m_errorMonitor->VerifyFound(); | ||||
8857 | // Now verify same checks for dst | ||||
8858 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8859 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
8860 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); | ||||
8861 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
8862 | m_errorMonitor->VerifyFound(); | ||||
8863 | // Now cause error due to src image layout changing | ||||
8864 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8865 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8866 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); | ||||
8867 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); | ||||
8868 | m_errorMonitor->VerifyFound(); | ||||
8869 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8870 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8871 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); | ||||
8872 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); | ||||
8873 | m_errorMonitor->VerifyFound(); | ||||
8874 | // Now cause error due to bad image layout transition in PipelineBarrier | ||||
8875 | VkImageMemoryBarrier image_barrier[1] = {}; | ||||
8876 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; | ||||
8877 | image_barrier[0].image = src_image; | ||||
8878 | image_barrier[0].subresourceRange.layerCount = 2; | ||||
8879 | image_barrier[0].subresourceRange.levelCount = 2; | ||||
8880 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
8881 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8882 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8883 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); | ||||
8884 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); | ||||
8885 | m_errorMonitor->VerifyFound(); | ||||
8886 | |||||
8887 | // Finally some layout errors at RenderPass create time | ||||
8888 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. | ||||
8889 | VkAttachmentReference attach = {}; | ||||
8890 | // perf warning for GENERAL layout w/ non-DS input attachment | ||||
8891 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
8892 | VkSubpassDescription subpass = {}; | ||||
8893 | subpass.inputAttachmentCount = 1; | ||||
8894 | subpass.pInputAttachments = &attach; | ||||
8895 | VkRenderPassCreateInfo rpci = {}; | ||||
8896 | rpci.subpassCount = 1; | ||||
8897 | rpci.pSubpasses = &subpass; | ||||
8898 | rpci.attachmentCount = 1; | ||||
8899 | VkAttachmentDescription attach_desc = {}; | ||||
8900 | attach_desc.format = VK_FORMAT_UNDEFINED; | ||||
8901 | rpci.pAttachments = &attach_desc; | ||||
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8902 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8903 | VkRenderPass rp; |
8904 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8905 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
8906 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); | ||||
8907 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
8908 | m_errorMonitor->VerifyFound(); | ||||
8909 | // error w/ non-general layout | ||||
8910 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; | ||||
8911 | |||||
8912 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8913 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8914 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); | ||||
8915 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
8916 | m_errorMonitor->VerifyFound(); | ||||
8917 | subpass.inputAttachmentCount = 0; | ||||
8918 | subpass.colorAttachmentCount = 1; | ||||
8919 | subpass.pColorAttachments = &attach; | ||||
8920 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
8921 | // perf warning for GENERAL layout on color attachment | ||||
8922 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8923 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
8924 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); | ||||
8925 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
8926 | m_errorMonitor->VerifyFound(); | ||||
8927 | // error w/ non-color opt or GENERAL layout for color attachment | ||||
8928 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; | ||||
8929 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8930 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8931 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); | ||||
8932 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
8933 | m_errorMonitor->VerifyFound(); | ||||
8934 | subpass.colorAttachmentCount = 0; | ||||
8935 | subpass.pDepthStencilAttachment = &attach; | ||||
8936 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
8937 | // perf warning for GENERAL layout on DS attachment | ||||
8938 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8939 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
8940 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); | ||||
8941 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
8942 | m_errorMonitor->VerifyFound(); | ||||
8943 | // error w/ non-ds opt or GENERAL layout for color attachment | ||||
8944 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; | ||||
8945 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8946 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8947 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); | ||||
8948 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
8949 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8950 | // For this error we need a valid renderpass so create default one |
8951 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; | ||||
8952 | attach.attachment = 0; | ||||
8953 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
8954 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
8955 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; | ||||
8956 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; | ||||
8957 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; | ||||
8958 | // Can't do a CLEAR load on READ_ONLY initialLayout | ||||
8959 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; | ||||
8960 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; | ||||
8961 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
8962 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8963 | " with invalid first layout " | ||||
8964 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" | ||||
8965 | "ONLY_OPTIMAL"); | ||||
8966 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
8967 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8968 | |
8969 | vkDestroyImage(m_device->device(), src_image, NULL); | ||||
8970 | vkDestroyImage(m_device->device(), dst_image, NULL); | ||||
8971 | } | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8972 | #endif // DRAW_STATE_TESTS |
8973 | |||||
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 8974 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8975 | #if GTEST_IS_THREADSAFE |
8976 | struct thread_data_struct { | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8977 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8978 | VkEvent event; |
8979 | bool bailout; | ||||
8980 | }; | ||||
8981 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8982 | extern "C" void *AddToCommandBuffer(void *arg) { |
8983 | struct thread_data_struct *data = (struct thread_data_struct *)arg; | ||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8984 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8985 | for (int i = 0; i < 10000; i++) { |
8986 | vkCmdSetEvent(data->commandBuffer, data->event, | ||||
8987 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); | ||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8988 | if (data->bailout) { |
8989 | break; | ||||
8990 | } | ||||
8991 | } | ||||
8992 | return NULL; | ||||
8993 | } | ||||
8994 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8995 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8996 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8997 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8998 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
8999 | "THREADING ERROR"); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9000 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9001 | ASSERT_NO_FATAL_FAILURE(InitState()); |
9002 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
9003 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9004 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9005 | // Calls AllocateCommandBuffers |
9006 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); | ||||
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 9007 | |
9008 | // Avoid creating RenderPass | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9009 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9010 | |
9011 | VkEventCreateInfo event_info; | ||||
9012 | VkEvent event; | ||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9013 | VkResult err; |
9014 | |||||
9015 | memset(&event_info, 0, sizeof(event_info)); | ||||
9016 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
9017 | |||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9018 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9019 | ASSERT_VK_SUCCESS(err); |
9020 | |||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9021 | err = vkResetEvent(device(), event); |
9022 | ASSERT_VK_SUCCESS(err); | ||||
9023 | |||||
9024 | struct thread_data_struct data; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9025 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9026 | data.event = event; |
9027 | data.bailout = false; | ||||
9028 | m_errorMonitor->SetBailout(&data.bailout); | ||||
9029 | // Add many entries to command buffer from another thread. | ||||
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 9030 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9031 | // Add many entries to command buffer from this thread at the same time. |
9032 | AddToCommandBuffer(&data); | ||||
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 9033 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 9034 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9035 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9036 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 9037 | m_errorMonitor->SetBailout(NULL); |
9038 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9039 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9040 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9041 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 9042 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9043 | #endif // GTEST_IS_THREADSAFE |
9044 | #endif // THREADING_TESTS | ||||
9045 | |||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9046 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9047 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9048 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9049 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9050 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9051 | ASSERT_NO_FATAL_FAILURE(InitState()); |
9052 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9053 | |||||
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9054 | VkShaderModule module; |
9055 | VkShaderModuleCreateInfo moduleCreateInfo; | ||||
9056 | struct icd_spv_header spv; | ||||
9057 | |||||
9058 | spv.magic = ICD_SPV_MAGIC; | ||||
9059 | spv.version = ICD_SPV_VERSION; | ||||
9060 | spv.gen_magic = 0; | ||||
9061 | |||||
9062 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; | ||||
9063 | moduleCreateInfo.pNext = NULL; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9064 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9065 | moduleCreateInfo.codeSize = 4; |
9066 | moduleCreateInfo.flags = 0; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9067 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9068 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9069 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9070 | } |
9071 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9072 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9073 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9074 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9075 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9076 | ASSERT_NO_FATAL_FAILURE(InitState()); |
9077 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9078 | |||||
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9079 | VkShaderModule module; |
9080 | VkShaderModuleCreateInfo moduleCreateInfo; | ||||
9081 | struct icd_spv_header spv; | ||||
9082 | |||||
9083 | spv.magic = ~ICD_SPV_MAGIC; | ||||
9084 | spv.version = ICD_SPV_VERSION; | ||||
9085 | spv.gen_magic = 0; | ||||
9086 | |||||
9087 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; | ||||
9088 | moduleCreateInfo.pNext = NULL; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9089 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9090 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
9091 | moduleCreateInfo.flags = 0; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9092 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9093 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9094 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9095 | } |
9096 | |||||
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9097 | #if 0 |
9098 | // Not currently covered by SPIRV-Tools validator | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9099 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9100 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9101 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9102 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9103 | ASSERT_NO_FATAL_FAILURE(InitState()); |
9104 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9105 | |||||
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9106 | VkShaderModule module; |
9107 | VkShaderModuleCreateInfo moduleCreateInfo; | ||||
9108 | struct icd_spv_header spv; | ||||
9109 | |||||
9110 | spv.magic = ICD_SPV_MAGIC; | ||||
9111 | spv.version = ~ICD_SPV_VERSION; | ||||
9112 | spv.gen_magic = 0; | ||||
9113 | |||||
9114 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; | ||||
9115 | moduleCreateInfo.pNext = NULL; | ||||
9116 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9117 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9118 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
9119 | moduleCreateInfo.flags = 0; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9120 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9121 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9122 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9123 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 9124 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 9125 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9126 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9127 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9128 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9129 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9130 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9131 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9132 | |
9133 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9134 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9135 | "\n" |
9136 | "layout(location=0) out float x;\n" | ||||
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9137 | "out gl_PerVertex {\n" |
9138 | " vec4 gl_Position;\n" | ||||
9139 | "};\n" | ||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9140 | "void main(){\n" |
9141 | " gl_Position = vec4(1);\n" | ||||
9142 | " x = 0;\n" | ||||
9143 | "}\n"; | ||||
9144 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9145 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9146 | "\n" |
9147 | "layout(location=0) out vec4 color;\n" | ||||
9148 | "void main(){\n" | ||||
9149 | " color = vec4(1);\n" | ||||
9150 | "}\n"; | ||||
9151 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9152 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
9153 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9154 | |
9155 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9156 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9157 | pipe.AddShader(&vs); |
9158 | pipe.AddShader(&fs); | ||||
9159 | |||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9160 | VkDescriptorSetObj descriptorSet(m_device); |
9161 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9162 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9163 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9164 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9165 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9166 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9167 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 9168 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9169 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9170 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9171 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9172 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9173 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9174 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9175 | |
9176 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9177 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9178 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9179 | "out gl_PerVertex {\n" |
9180 | " vec4 gl_Position;\n" | ||||
9181 | "};\n" | ||||
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9182 | "void main(){\n" |
9183 | " gl_Position = vec4(1);\n" | ||||
9184 | "}\n"; | ||||
9185 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9186 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9187 | "\n" |
9188 | "layout(location=0) in float x;\n" | ||||
9189 | "layout(location=0) out vec4 color;\n" | ||||
9190 | "void main(){\n" | ||||
9191 | " color = vec4(x);\n" | ||||
9192 | "}\n"; | ||||
9193 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9194 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
9195 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9196 | |
9197 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9198 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9199 | pipe.AddShader(&vs); |
9200 | pipe.AddShader(&fs); | ||||
9201 | |||||
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9202 | VkDescriptorSetObj descriptorSet(m_device); |
9203 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9204 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9205 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9206 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9207 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9208 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 9209 | } |
9210 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9211 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9212 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9213 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9214 | |
9215 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9216 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9217 | |||||
9218 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9219 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9220 | "\n" |
9221 | "out gl_PerVertex {\n" | ||||
9222 | " vec4 gl_Position;\n" | ||||
9223 | "};\n" | ||||
9224 | "void main(){\n" | ||||
9225 | " gl_Position = vec4(1);\n" | ||||
9226 | "}\n"; | ||||
9227 | char const *fsSource = | ||||
9228 | "#version 450\n" | ||||
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9229 | "\n" |
9230 | "in block { layout(location=0) float x; } ins;\n" | ||||
9231 | "layout(location=0) out vec4 color;\n" | ||||
9232 | "void main(){\n" | ||||
9233 | " color = vec4(ins.x);\n" | ||||
9234 | "}\n"; | ||||
9235 | |||||
9236 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9237 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
9238 | |||||
9239 | VkPipelineObj pipe(m_device); | ||||
9240 | pipe.AddColorAttachment(); | ||||
9241 | pipe.AddShader(&vs); | ||||
9242 | pipe.AddShader(&fs); | ||||
9243 | |||||
9244 | VkDescriptorSetObj descriptorSet(m_device); | ||||
9245 | descriptorSet.AppendDummy(); | ||||
9246 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
9247 | |||||
9248 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
9249 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9250 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9251 | } |
9252 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9253 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9254 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9255 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9256 | "output arr[2] of float32' vs 'ptr to " |
9257 | "input arr[3] of float32'"); | ||||
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9258 | |
9259 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9260 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9261 | |||||
9262 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9263 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9264 | "\n" |
9265 | "layout(location=0) out float x[2];\n" | ||||
9266 | "out gl_PerVertex {\n" | ||||
9267 | " vec4 gl_Position;\n" | ||||
9268 | "};\n" | ||||
9269 | "void main(){\n" | ||||
9270 | " x[0] = 0; x[1] = 0;\n" | ||||
9271 | " gl_Position = vec4(1);\n" | ||||
9272 | "}\n"; | ||||
9273 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9274 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9275 | "\n" |
9276 | "layout(location=0) in float x[3];\n" | ||||
9277 | "layout(location=0) out vec4 color;\n" | ||||
9278 | "void main(){\n" | ||||
9279 | " color = vec4(x[0] + x[1] + x[2]);\n" | ||||
9280 | "}\n"; | ||||
9281 | |||||
9282 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9283 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
9284 | |||||
9285 | VkPipelineObj pipe(m_device); | ||||
9286 | pipe.AddColorAttachment(); | ||||
9287 | pipe.AddShader(&vs); | ||||
9288 | pipe.AddShader(&fs); | ||||
9289 | |||||
9290 | VkDescriptorSetObj descriptorSet(m_device); | ||||
9291 | descriptorSet.AppendDummy(); | ||||
9292 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
9293 | |||||
9294 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
9295 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9296 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 9297 | } |
9298 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9299 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9300 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9301 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9302 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9303 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9304 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9305 | |
9306 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9307 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9308 | "\n" |
9309 | "layout(location=0) out int x;\n" | ||||
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9310 | "out gl_PerVertex {\n" |
9311 | " vec4 gl_Position;\n" | ||||
9312 | "};\n" | ||||
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9313 | "void main(){\n" |
9314 | " x = 0;\n" | ||||
9315 | " gl_Position = vec4(1);\n" | ||||
9316 | "}\n"; | ||||
9317 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9318 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9319 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9320 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9321 | "layout(location=0) out vec4 color;\n" |
9322 | "void main(){\n" | ||||
9323 | " color = vec4(x);\n" | ||||
9324 | "}\n"; | ||||
9325 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9326 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
9327 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9328 | |
9329 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9330 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9331 | pipe.AddShader(&vs); |
9332 | pipe.AddShader(&fs); | ||||
9333 | |||||
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9334 | VkDescriptorSetObj descriptorSet(m_device); |
9335 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9336 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9337 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9338 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9339 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9340 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 9341 | } |
9342 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9343 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9344 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9345 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9346 | |
9347 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9348 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9349 | |||||
9350 | char const *vsSource = | ||||
9351 | "#version 450\n" | ||||
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9352 | "\n" |
9353 | "out block { layout(location=0) int x; } outs;\n" | ||||
9354 | "out gl_PerVertex {\n" | ||||
9355 | " vec4 gl_Position;\n" | ||||
9356 | "};\n" | ||||
9357 | "void main(){\n" | ||||
9358 | " outs.x = 0;\n" | ||||
9359 | " gl_Position = vec4(1);\n" | ||||
9360 | "}\n"; | ||||
9361 | char const *fsSource = | ||||
9362 | "#version 450\n" | ||||
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9363 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9364 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9365 | "layout(location=0) out vec4 color;\n" |
9366 | "void main(){\n" | ||||
9367 | " color = vec4(ins.x);\n" | ||||
9368 | "}\n"; | ||||
9369 | |||||
9370 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9371 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
9372 | |||||
9373 | VkPipelineObj pipe(m_device); | ||||
9374 | pipe.AddColorAttachment(); | ||||
9375 | pipe.AddShader(&vs); | ||||
9376 | pipe.AddShader(&fs); | ||||
9377 | |||||
9378 | VkDescriptorSetObj descriptorSet(m_device); | ||||
9379 | descriptorSet.AppendDummy(); | ||||
9380 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
9381 | |||||
9382 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
9383 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9384 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9385 | } |
9386 | |||||
9387 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { | ||||
9388 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9389 | "location 0.0 which is not written by vertex shader"); | ||||
9390 | |||||
9391 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9392 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9393 | |||||
9394 | char const *vsSource = | ||||
9395 | "#version 450\n" | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9396 | "\n" |
9397 | "out block { layout(location=1) float x; } outs;\n" | ||||
9398 | "out gl_PerVertex {\n" | ||||
9399 | " vec4 gl_Position;\n" | ||||
9400 | "};\n" | ||||
9401 | "void main(){\n" | ||||
9402 | " outs.x = 0;\n" | ||||
9403 | " gl_Position = vec4(1);\n" | ||||
9404 | "}\n"; | ||||
9405 | char const *fsSource = | ||||
9406 | "#version 450\n" | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9407 | "\n" |
9408 | "in block { layout(location=0) float x; } ins;\n" | ||||
9409 | "layout(location=0) out vec4 color;\n" | ||||
9410 | "void main(){\n" | ||||
9411 | " color = vec4(ins.x);\n" | ||||
9412 | "}\n"; | ||||
9413 | |||||
9414 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9415 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
9416 | |||||
9417 | VkPipelineObj pipe(m_device); | ||||
9418 | pipe.AddColorAttachment(); | ||||
9419 | pipe.AddShader(&vs); | ||||
9420 | pipe.AddShader(&fs); | ||||
9421 | |||||
9422 | VkDescriptorSetObj descriptorSet(m_device); | ||||
9423 | descriptorSet.AppendDummy(); | ||||
9424 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
9425 | |||||
9426 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
9427 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9428 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9429 | } |
9430 | |||||
9431 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { | ||||
9432 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9433 | "location 0.1 which is not written by vertex shader"); | ||||
9434 | |||||
9435 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9436 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9437 | |||||
9438 | char const *vsSource = | ||||
9439 | "#version 450\n" | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9440 | "\n" |
9441 | "out block { layout(location=0, component=0) float x; } outs;\n" | ||||
9442 | "out gl_PerVertex {\n" | ||||
9443 | " vec4 gl_Position;\n" | ||||
9444 | "};\n" | ||||
9445 | "void main(){\n" | ||||
9446 | " outs.x = 0;\n" | ||||
9447 | " gl_Position = vec4(1);\n" | ||||
9448 | "}\n"; | ||||
9449 | char const *fsSource = | ||||
9450 | "#version 450\n" | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 9451 | "\n" |
9452 | "in block { layout(location=0, component=1) float x; } ins;\n" | ||||
9453 | "layout(location=0) out vec4 color;\n" | ||||
9454 | "void main(){\n" | ||||
9455 | " color = vec4(ins.x);\n" | ||||
9456 | "}\n"; | ||||
9457 | |||||
9458 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9459 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
9460 | |||||
9461 | VkPipelineObj pipe(m_device); | ||||
9462 | pipe.AddColorAttachment(); | ||||
9463 | pipe.AddShader(&vs); | ||||
9464 | pipe.AddShader(&fs); | ||||
9465 | |||||
9466 | VkDescriptorSetObj descriptorSet(m_device); | ||||
9467 | descriptorSet.AppendDummy(); | ||||
9468 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
9469 | |||||
9470 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
9471 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9472 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 9473 | } |
9474 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9475 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9476 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9477 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9478 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9479 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9480 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9481 | |
9482 | VkVertexInputBindingDescription input_binding; | ||||
9483 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
9484 | |||||
9485 | VkVertexInputAttributeDescription input_attrib; | ||||
9486 | memset(&input_attrib, 0, sizeof(input_attrib)); | ||||
9487 | input_attrib.format = VK_FORMAT_R32_SFLOAT; | ||||
9488 | |||||
9489 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9490 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9491 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9492 | "out gl_PerVertex {\n" |
9493 | " vec4 gl_Position;\n" | ||||
9494 | "};\n" | ||||
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9495 | "void main(){\n" |
9496 | " gl_Position = vec4(1);\n" | ||||
9497 | "}\n"; | ||||
9498 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9499 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9500 | "\n" |
9501 | "layout(location=0) out vec4 color;\n" | ||||
9502 | "void main(){\n" | ||||
9503 | " color = vec4(1);\n" | ||||
9504 | "}\n"; | ||||
9505 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9506 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
9507 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9508 | |
9509 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9510 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9511 | pipe.AddShader(&vs); |
9512 | pipe.AddShader(&fs); | ||||
9513 | |||||
9514 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
9515 | pipe.AddVertexInputAttribs(&input_attrib, 1); | ||||
9516 | |||||
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9517 | VkDescriptorSetObj descriptorSet(m_device); |
9518 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9519 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9520 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9521 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9522 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9523 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 9524 | } |
9525 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9526 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9527 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9528 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9529 | |
9530 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9531 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9532 | |||||
9533 | VkVertexInputBindingDescription input_binding; | ||||
9534 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
9535 | |||||
9536 | VkVertexInputAttributeDescription input_attrib; | ||||
9537 | memset(&input_attrib, 0, sizeof(input_attrib)); | ||||
9538 | input_attrib.format = VK_FORMAT_R32_SFLOAT; | ||||
9539 | |||||
9540 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9541 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9542 | "\n" |
9543 | "layout(location=1) in float x;\n" | ||||
9544 | "out gl_PerVertex {\n" | ||||
9545 | " vec4 gl_Position;\n" | ||||
9546 | "};\n" | ||||
9547 | "void main(){\n" | ||||
9548 | " gl_Position = vec4(x);\n" | ||||
9549 | "}\n"; | ||||
9550 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9551 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9552 | "\n" |
9553 | "layout(location=0) out vec4 color;\n" | ||||
9554 | "void main(){\n" | ||||
9555 | " color = vec4(1);\n" | ||||
9556 | "}\n"; | ||||
9557 | |||||
9558 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9559 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
9560 | |||||
9561 | VkPipelineObj pipe(m_device); | ||||
9562 | pipe.AddColorAttachment(); | ||||
9563 | pipe.AddShader(&vs); | ||||
9564 | pipe.AddShader(&fs); | ||||
9565 | |||||
9566 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
9567 | pipe.AddVertexInputAttribs(&input_attrib, 1); | ||||
9568 | |||||
9569 | VkDescriptorSetObj descriptorSet(m_device); | ||||
9570 | descriptorSet.AppendDummy(); | ||||
9571 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
9572 | |||||
9573 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
9574 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9575 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 9576 | } |
9577 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9578 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
9579 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9580 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9581 | "VS consumes input at location 0 but not provided"); |
9582 | |||||
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9583 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9584 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9585 | |
9586 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9587 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9588 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9589 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9590 | "out gl_PerVertex {\n" |
9591 | " vec4 gl_Position;\n" | ||||
9592 | "};\n" | ||||
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9593 | "void main(){\n" |
9594 | " gl_Position = x;\n" | ||||
9595 | "}\n"; | ||||
9596 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9597 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9598 | "\n" |
9599 | "layout(location=0) out vec4 color;\n" | ||||
9600 | "void main(){\n" | ||||
9601 | " color = vec4(1);\n" | ||||
9602 | "}\n"; | ||||
9603 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9604 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
9605 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9606 | |
9607 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9608 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9609 | pipe.AddShader(&vs); |
9610 | pipe.AddShader(&fs); | ||||
9611 | |||||
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9612 | VkDescriptorSetObj descriptorSet(m_device); |
9613 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9614 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9615 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9616 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9617 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9618 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9619 | } |
9620 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9621 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
9622 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9623 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9624 | "location 0 does not match VS input type"); |
9625 | |||||
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9626 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9627 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9628 | |
9629 | VkVertexInputBindingDescription input_binding; | ||||
9630 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
9631 | |||||
9632 | VkVertexInputAttributeDescription input_attrib; | ||||
9633 | memset(&input_attrib, 0, sizeof(input_attrib)); | ||||
9634 | input_attrib.format = VK_FORMAT_R32_SFLOAT; | ||||
9635 | |||||
9636 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9637 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9638 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9639 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9640 | "out gl_PerVertex {\n" |
9641 | " vec4 gl_Position;\n" | ||||
9642 | "};\n" | ||||
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9643 | "void main(){\n" |
9644 | " gl_Position = vec4(x);\n" | ||||
9645 | "}\n"; | ||||
9646 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9647 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9648 | "\n" |
9649 | "layout(location=0) out vec4 color;\n" | ||||
9650 | "void main(){\n" | ||||
9651 | " color = vec4(1);\n" | ||||
9652 | "}\n"; | ||||
9653 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9654 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
9655 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9656 | |
9657 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9658 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9659 | pipe.AddShader(&vs); |
9660 | pipe.AddShader(&fs); | ||||
9661 | |||||
9662 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
9663 | pipe.AddVertexInputAttribs(&input_attrib, 1); | ||||
9664 | |||||
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9665 | VkDescriptorSetObj descriptorSet(m_device); |
9666 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9667 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9668 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9669 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9670 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9671 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9672 | } |
9673 | |||||
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9674 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
9675 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9676 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9677 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); | ||||
9678 | |||||
9679 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9680 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9681 | |||||
9682 | char const *vsSource = | ||||
9683 | "#version 450\n" | ||||
9684 | "\n" | ||||
9685 | "out gl_PerVertex {\n" | ||||
9686 | " vec4 gl_Position;\n" | ||||
9687 | "};\n" | ||||
9688 | "void main(){\n" | ||||
9689 | " gl_Position = vec4(1);\n" | ||||
9690 | "}\n"; | ||||
9691 | char const *fsSource = | ||||
9692 | "#version 450\n" | ||||
9693 | "\n" | ||||
9694 | "layout(location=0) out vec4 color;\n" | ||||
9695 | "void main(){\n" | ||||
9696 | " color = vec4(1);\n" | ||||
9697 | "}\n"; | ||||
9698 | |||||
9699 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9700 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
9701 | |||||
9702 | VkPipelineObj pipe(m_device); | ||||
9703 | pipe.AddColorAttachment(); | ||||
9704 | pipe.AddShader(&vs); | ||||
9705 | pipe.AddShader(&vs); | ||||
9706 | pipe.AddShader(&fs); | ||||
9707 | |||||
9708 | VkDescriptorSetObj descriptorSet(m_device); | ||||
9709 | descriptorSet.AppendDummy(); | ||||
9710 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
9711 | |||||
9712 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
9713 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9714 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9715 | } |
9716 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9717 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9718 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9719 | |
9720 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9721 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9722 | |||||
9723 | VkVertexInputBindingDescription input_binding; | ||||
9724 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
9725 | |||||
9726 | VkVertexInputAttributeDescription input_attribs[2]; | ||||
9727 | memset(input_attribs, 0, sizeof(input_attribs)); | ||||
9728 | |||||
9729 | for (int i = 0; i < 2; i++) { | ||||
9730 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; | ||||
9731 | input_attribs[i].location = i; | ||||
9732 | } | ||||
9733 | |||||
9734 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9735 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9736 | "\n" |
9737 | "layout(location=0) in mat2x4 x;\n" | ||||
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9738 | "out gl_PerVertex {\n" |
9739 | " vec4 gl_Position;\n" | ||||
9740 | "};\n" | ||||
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9741 | "void main(){\n" |
9742 | " gl_Position = x[0] + x[1];\n" | ||||
9743 | "}\n"; | ||||
9744 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9745 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9746 | "\n" |
9747 | "layout(location=0) out vec4 color;\n" | ||||
9748 | "void main(){\n" | ||||
9749 | " color = vec4(1);\n" | ||||
9750 | "}\n"; | ||||
9751 | |||||
9752 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9753 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
9754 | |||||
9755 | VkPipelineObj pipe(m_device); | ||||
9756 | pipe.AddColorAttachment(); | ||||
9757 | pipe.AddShader(&vs); | ||||
9758 | pipe.AddShader(&fs); | ||||
9759 | |||||
9760 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
9761 | pipe.AddVertexInputAttribs(input_attribs, 2); | ||||
9762 | |||||
9763 | VkDescriptorSetObj descriptorSet(m_device); | ||||
9764 | descriptorSet.AppendDummy(); | ||||
9765 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
9766 | |||||
9767 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
9768 | |||||
9769 | /* expect success */ | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9770 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9771 | } |
9772 | |||||
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9773 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
9774 | { | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9775 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9776 | |
9777 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9778 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9779 | |||||
9780 | VkVertexInputBindingDescription input_binding; | ||||
9781 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
9782 | |||||
9783 | VkVertexInputAttributeDescription input_attribs[2]; | ||||
9784 | memset(input_attribs, 0, sizeof(input_attribs)); | ||||
9785 | |||||
9786 | for (int i = 0; i < 2; i++) { | ||||
9787 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; | ||||
9788 | input_attribs[i].location = i; | ||||
9789 | } | ||||
9790 | |||||
9791 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9792 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9793 | "\n" |
9794 | "layout(location=0) in vec4 x[2];\n" | ||||
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9795 | "out gl_PerVertex {\n" |
9796 | " vec4 gl_Position;\n" | ||||
9797 | "};\n" | ||||
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9798 | "void main(){\n" |
9799 | " gl_Position = x[0] + x[1];\n" | ||||
9800 | "}\n"; | ||||
9801 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9802 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9803 | "\n" |
9804 | "layout(location=0) out vec4 color;\n" | ||||
9805 | "void main(){\n" | ||||
9806 | " color = vec4(1);\n" | ||||
9807 | "}\n"; | ||||
9808 | |||||
9809 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9810 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
9811 | |||||
9812 | VkPipelineObj pipe(m_device); | ||||
9813 | pipe.AddColorAttachment(); | ||||
9814 | pipe.AddShader(&vs); | ||||
9815 | pipe.AddShader(&fs); | ||||
9816 | |||||
9817 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
9818 | pipe.AddVertexInputAttribs(input_attribs, 2); | ||||
9819 | |||||
9820 | VkDescriptorSetObj descriptorSet(m_device); | ||||
9821 | descriptorSet.AppendDummy(); | ||||
9822 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
9823 | |||||
9824 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
9825 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9826 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9827 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9828 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9829 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
9830 | { | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9831 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9832 | |
9833 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9834 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9835 | |||||
9836 | char const *vsSource = | ||||
9837 | "#version 450\n" | ||||
9838 | "out gl_PerVertex {\n" | ||||
9839 | " vec4 gl_Position;\n" | ||||
9840 | "};\n" | ||||
9841 | "void main(){\n" | ||||
9842 | " gl_Position = vec4(0);\n" | ||||
9843 | "}\n"; | ||||
9844 | char const *fsSource = | ||||
9845 | "#version 450\n" | ||||
9846 | "\n" | ||||
9847 | "layout(location=0) out vec4 color;\n" | ||||
9848 | "void main(){\n" | ||||
9849 | " color = vec4(1);\n" | ||||
9850 | "}\n"; | ||||
9851 | |||||
9852 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9853 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
9854 | |||||
9855 | VkPipelineObj pipe(m_device); | ||||
9856 | pipe.AddColorAttachment(); | ||||
9857 | pipe.AddShader(&vs); | ||||
9858 | pipe.AddShader(&fs); | ||||
9859 | |||||
9860 | VkDescriptorSetObj descriptorSet(m_device); | ||||
9861 | descriptorSet.AppendDummy(); | ||||
9862 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
9863 | |||||
9864 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
9865 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9866 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9867 | } |
9868 | |||||
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9869 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
9870 | { | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9871 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9872 | |
9873 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block | ||||
9874 | |||||
9875 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9876 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9877 | |||||
9878 | char const *vsSource = | ||||
9879 | "#version 450\n" | ||||
9880 | "out gl_PerVertex {\n" | ||||
9881 | " vec4 gl_Position;\n" | ||||
9882 | "};\n" | ||||
9883 | "layout(location=0) out vec3 x;\n" | ||||
9884 | "layout(location=1) out ivec3 y;\n" | ||||
9885 | "layout(location=2) out vec3 z;\n" | ||||
9886 | "void main(){\n" | ||||
9887 | " gl_Position = vec4(0);\n" | ||||
9888 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" | ||||
9889 | "}\n"; | ||||
9890 | char const *fsSource = | ||||
9891 | "#version 450\n" | ||||
9892 | "\n" | ||||
9893 | "layout(location=0) out vec4 color;\n" | ||||
9894 | "layout(location=0) in float x;\n" | ||||
9895 | "layout(location=1) flat in int y;\n" | ||||
9896 | "layout(location=2) in vec2 z;\n" | ||||
9897 | "void main(){\n" | ||||
9898 | " color = vec4(1 + x + y + z.x);\n" | ||||
9899 | "}\n"; | ||||
9900 | |||||
9901 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9902 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
9903 | |||||
9904 | VkPipelineObj pipe(m_device); | ||||
9905 | pipe.AddColorAttachment(); | ||||
9906 | pipe.AddShader(&vs); | ||||
9907 | pipe.AddShader(&fs); | ||||
9908 | |||||
9909 | VkDescriptorSetObj descriptorSet(m_device); | ||||
9910 | descriptorSet.AppendDummy(); | ||||
9911 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
9912 | |||||
9913 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
9914 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9915 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9916 | } |
9917 | |||||
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9918 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
9919 | { | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9920 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9921 | |
9922 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9923 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9924 | |||||
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9925 | if (!m_device->phy().features().tessellationShader) { |
9926 | printf("Device does not support tessellation shaders; skipped.\n"); | ||||
9927 | return; | ||||
9928 | } | ||||
9929 | |||||
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9930 | char const *vsSource = |
9931 | "#version 450\n" | ||||
9932 | "void main(){}\n"; | ||||
9933 | char const *tcsSource = | ||||
9934 | "#version 450\n" | ||||
9935 | "layout(location=0) out int x[];\n" | ||||
9936 | "layout(vertices=3) out;\n" | ||||
9937 | "void main(){\n" | ||||
9938 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" | ||||
9939 | " gl_TessLevelInner[0] = 1;\n" | ||||
9940 | " x[gl_InvocationID] = gl_InvocationID;\n" | ||||
9941 | "}\n"; | ||||
9942 | char const *tesSource = | ||||
9943 | "#version 450\n" | ||||
9944 | "layout(triangles, equal_spacing, cw) in;\n" | ||||
9945 | "layout(location=0) in int x[];\n" | ||||
9946 | "out gl_PerVertex { vec4 gl_Position; };\n" | ||||
9947 | "void main(){\n" | ||||
9948 | " gl_Position.xyz = gl_TessCoord;\n" | ||||
9949 | " gl_Position.w = x[0] + x[1] + x[2];\n" | ||||
9950 | "}\n"; | ||||
9951 | char const *fsSource = | ||||
9952 | "#version 450\n" | ||||
9953 | "layout(location=0) out vec4 color;\n" | ||||
9954 | "void main(){\n" | ||||
9955 | " color = vec4(1);\n" | ||||
9956 | "}\n"; | ||||
9957 | |||||
9958 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9959 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); | ||||
9960 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); | ||||
9961 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
9962 | |||||
9963 | VkPipelineInputAssemblyStateCreateInfo iasci{ | ||||
9964 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, | ||||
9965 | nullptr, | ||||
9966 | 0, | ||||
9967 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, | ||||
9968 | VK_FALSE}; | ||||
9969 | |||||
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9970 | VkPipelineTessellationStateCreateInfo tsci{ |
9971 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, | ||||
9972 | nullptr, | ||||
9973 | 0, | ||||
9974 | 3}; | ||||
9975 | |||||
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9976 | VkPipelineObj pipe(m_device); |
9977 | pipe.SetInputAssembly(&iasci); | ||||
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9978 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9979 | pipe.AddColorAttachment(); |
9980 | pipe.AddShader(&vs); | ||||
9981 | pipe.AddShader(&tcs); | ||||
9982 | pipe.AddShader(&tes); | ||||
9983 | pipe.AddShader(&fs); | ||||
9984 | |||||
9985 | VkDescriptorSetObj descriptorSet(m_device); | ||||
9986 | descriptorSet.AppendDummy(); | ||||
9987 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
9988 | |||||
9989 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
9990 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9991 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9992 | } |
9993 | |||||
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 9994 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
9995 | { | ||||
9996 | m_errorMonitor->ExpectSuccess(); | ||||
9997 | |||||
9998 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9999 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
10000 | |||||
10001 | if (!m_device->phy().features().geometryShader) { | ||||
10002 | printf("Device does not support geometry shaders; skipped.\n"); | ||||
10003 | return; | ||||
10004 | } | ||||
10005 | |||||
10006 | char const *vsSource = | ||||
10007 | "#version 450\n" | ||||
10008 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" | ||||
10009 | "void main(){\n" | ||||
10010 | " vs_out.x = vec4(1);\n" | ||||
10011 | "}\n"; | ||||
10012 | char const *gsSource = | ||||
10013 | "#version 450\n" | ||||
10014 | "layout(triangles) in;\n" | ||||
10015 | "layout(triangle_strip, max_vertices=3) out;\n" | ||||
10016 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" | ||||
10017 | "out gl_PerVertex { vec4 gl_Position; };\n" | ||||
10018 | "void main() {\n" | ||||
10019 | " gl_Position = gs_in[0].x;\n" | ||||
10020 | " EmitVertex();\n" | ||||
10021 | "}\n"; | ||||
10022 | char const *fsSource = | ||||
10023 | "#version 450\n" | ||||
10024 | "layout(location=0) out vec4 color;\n" | ||||
10025 | "void main(){\n" | ||||
10026 | " color = vec4(1);\n" | ||||
10027 | "}\n"; | ||||
10028 | |||||
10029 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
10030 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); | ||||
10031 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
10032 | |||||
10033 | VkPipelineObj pipe(m_device); | ||||
10034 | pipe.AddColorAttachment(); | ||||
10035 | pipe.AddShader(&vs); | ||||
10036 | pipe.AddShader(&gs); | ||||
10037 | pipe.AddShader(&fs); | ||||
10038 | |||||
10039 | VkDescriptorSetObj descriptorSet(m_device); | ||||
10040 | descriptorSet.AppendDummy(); | ||||
10041 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
10042 | |||||
10043 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
10044 | |||||
10045 | m_errorMonitor->VerifyNotFound(); | ||||
10046 | } | ||||
10047 | |||||
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 10048 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
10049 | { | ||||
10050 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10051 | "is per-vertex in tessellation control shader stage " | ||||
10052 | "but per-patch in tessellation evaluation shader stage"); | ||||
10053 | |||||
10054 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10055 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
10056 | |||||
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 10057 | if (!m_device->phy().features().tessellationShader) { |
10058 | printf("Device does not support tessellation shaders; skipped.\n"); | ||||
10059 | return; | ||||
10060 | } | ||||
10061 | |||||
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 10062 | char const *vsSource = |
10063 | "#version 450\n" | ||||
10064 | "void main(){}\n"; | ||||
10065 | char const *tcsSource = | ||||
10066 | "#version 450\n" | ||||
10067 | "layout(location=0) out int x[];\n" | ||||
10068 | "layout(vertices=3) out;\n" | ||||
10069 | "void main(){\n" | ||||
10070 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" | ||||
10071 | " gl_TessLevelInner[0] = 1;\n" | ||||
10072 | " x[gl_InvocationID] = gl_InvocationID;\n" | ||||
10073 | "}\n"; | ||||
10074 | char const *tesSource = | ||||
10075 | "#version 450\n" | ||||
10076 | "layout(triangles, equal_spacing, cw) in;\n" | ||||
10077 | "layout(location=0) patch in int x;\n" | ||||
10078 | "out gl_PerVertex { vec4 gl_Position; };\n" | ||||
10079 | "void main(){\n" | ||||
10080 | " gl_Position.xyz = gl_TessCoord;\n" | ||||
10081 | " gl_Position.w = x;\n" | ||||
10082 | "}\n"; | ||||
10083 | char const *fsSource = | ||||
10084 | "#version 450\n" | ||||
10085 | "layout(location=0) out vec4 color;\n" | ||||
10086 | "void main(){\n" | ||||
10087 | " color = vec4(1);\n" | ||||
10088 | "}\n"; | ||||
10089 | |||||
10090 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
10091 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); | ||||
10092 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); | ||||
10093 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
10094 | |||||
10095 | VkPipelineInputAssemblyStateCreateInfo iasci{ | ||||
10096 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, | ||||
10097 | nullptr, | ||||
10098 | 0, | ||||
10099 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, | ||||
10100 | VK_FALSE}; | ||||
10101 | |||||
10102 | VkPipelineTessellationStateCreateInfo tsci{ | ||||
10103 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, | ||||
10104 | nullptr, | ||||
10105 | 0, | ||||
10106 | 3}; | ||||
10107 | |||||
10108 | VkPipelineObj pipe(m_device); | ||||
10109 | pipe.SetInputAssembly(&iasci); | ||||
10110 | pipe.SetTessellation(&tsci); | ||||
10111 | pipe.AddColorAttachment(); | ||||
10112 | pipe.AddShader(&vs); | ||||
10113 | pipe.AddShader(&tcs); | ||||
10114 | pipe.AddShader(&tes); | ||||
10115 | pipe.AddShader(&fs); | ||||
10116 | |||||
10117 | VkDescriptorSetObj descriptorSet(m_device); | ||||
10118 | descriptorSet.AppendDummy(); | ||||
10119 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
10120 | |||||
10121 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
10122 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10123 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 10124 | } |
10125 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10126 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
10127 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10128 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10129 | "Duplicate vertex input binding descriptions for binding 0"); |
10130 | |||||
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10131 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 10132 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10133 | |
10134 | /* Two binding descriptions for binding 0 */ | ||||
10135 | VkVertexInputBindingDescription input_bindings[2]; | ||||
10136 | memset(input_bindings, 0, sizeof(input_bindings)); | ||||
10137 | |||||
10138 | VkVertexInputAttributeDescription input_attrib; | ||||
10139 | memset(&input_attrib, 0, sizeof(input_attrib)); | ||||
10140 | input_attrib.format = VK_FORMAT_R32_SFLOAT; | ||||
10141 | |||||
10142 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10143 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10144 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10145 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10146 | "out gl_PerVertex {\n" |
10147 | " vec4 gl_Position;\n" | ||||
10148 | "};\n" | ||||
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10149 | "void main(){\n" |
10150 | " gl_Position = vec4(x);\n" | ||||
10151 | "}\n"; | ||||
10152 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10153 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10154 | "\n" |
10155 | "layout(location=0) out vec4 color;\n" | ||||
10156 | "void main(){\n" | ||||
10157 | " color = vec4(1);\n" | ||||
10158 | "}\n"; | ||||
10159 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10160 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
10161 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10162 | |
10163 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10164 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10165 | pipe.AddShader(&vs); |
10166 | pipe.AddShader(&fs); | ||||
10167 | |||||
10168 | pipe.AddVertexInputBindings(input_bindings, 2); | ||||
10169 | pipe.AddVertexInputAttribs(&input_attrib, 1); | ||||
10170 | |||||
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10171 | VkDescriptorSetObj descriptorSet(m_device); |
10172 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10173 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10174 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10175 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10176 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10177 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 10178 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 10179 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 10180 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
10181 | m_errorMonitor->ExpectSuccess(); | ||||
10182 | |||||
10183 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10184 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
10185 | |||||
10186 | if (!m_device->phy().features().tessellationShader) { | ||||
10187 | printf("Device does not support 64bit vertex attributes; skipped.\n"); | ||||
10188 | return; | ||||
10189 | } | ||||
10190 | |||||
10191 | VkVertexInputBindingDescription input_bindings[1]; | ||||
10192 | memset(input_bindings, 0, sizeof(input_bindings)); | ||||
10193 | |||||
10194 | VkVertexInputAttributeDescription input_attribs[4]; | ||||
10195 | memset(input_attribs, 0, sizeof(input_attribs)); | ||||
10196 | input_attribs[0].location = 0; | ||||
10197 | input_attribs[0].offset = 0; | ||||
10198 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; | ||||
10199 | input_attribs[1].location = 2; | ||||
10200 | input_attribs[1].offset = 32; | ||||
10201 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; | ||||
10202 | input_attribs[2].location = 4; | ||||
10203 | input_attribs[2].offset = 64; | ||||
10204 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; | ||||
10205 | input_attribs[3].location = 6; | ||||
10206 | input_attribs[3].offset = 96; | ||||
10207 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; | ||||
10208 | |||||
10209 | char const *vsSource = | ||||
10210 | "#version 450\n" | ||||
10211 | "\n" | ||||
10212 | "layout(location=0) in dmat4 x;\n" | ||||
10213 | "out gl_PerVertex {\n" | ||||
10214 | " vec4 gl_Position;\n" | ||||
10215 | "};\n" | ||||
10216 | "void main(){\n" | ||||
10217 | " gl_Position = vec4(x[0][0]);\n" | ||||
10218 | "}\n"; | ||||
10219 | char const *fsSource = | ||||
10220 | "#version 450\n" | ||||
10221 | "\n" | ||||
10222 | "layout(location=0) out vec4 color;\n" | ||||
10223 | "void main(){\n" | ||||
10224 | " color = vec4(1);\n" | ||||
10225 | "}\n"; | ||||
10226 | |||||
10227 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
10228 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
10229 | |||||
10230 | VkPipelineObj pipe(m_device); | ||||
10231 | pipe.AddColorAttachment(); | ||||
10232 | pipe.AddShader(&vs); | ||||
10233 | pipe.AddShader(&fs); | ||||
10234 | |||||
10235 | pipe.AddVertexInputBindings(input_bindings, 1); | ||||
10236 | pipe.AddVertexInputAttribs(input_attribs, 4); | ||||
10237 | |||||
10238 | VkDescriptorSetObj descriptorSet(m_device); | ||||
10239 | descriptorSet.AppendDummy(); | ||||
10240 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
10241 | |||||
10242 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
10243 | |||||
10244 | m_errorMonitor->VerifyNotFound(); | ||||
10245 | } | ||||
10246 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10247 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10248 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10249 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10250 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10251 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10252 | |
10253 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10254 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10255 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10256 | "out gl_PerVertex {\n" |
10257 | " vec4 gl_Position;\n" | ||||
10258 | "};\n" | ||||
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10259 | "void main(){\n" |
10260 | " gl_Position = vec4(1);\n" | ||||
10261 | "}\n"; | ||||
10262 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10263 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10264 | "\n" |
10265 | "void main(){\n" | ||||
10266 | "}\n"; | ||||
10267 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10268 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
10269 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10270 | |
10271 | VkPipelineObj pipe(m_device); | ||||
10272 | pipe.AddShader(&vs); | ||||
10273 | pipe.AddShader(&fs); | ||||
10274 | |||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10275 | /* set up CB 0, not written */ |
10276 | pipe.AddColorAttachment(); | ||||
10277 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10278 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10279 | VkDescriptorSetObj descriptorSet(m_device); |
10280 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10281 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10282 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10283 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10284 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10285 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 10286 | } |
10287 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10288 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10289 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 10290 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10291 | "FS writes to output location 1 with no matching attachment"); |
10292 | |||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10293 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10294 | |
10295 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10296 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10297 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10298 | "out gl_PerVertex {\n" |
10299 | " vec4 gl_Position;\n" | ||||
10300 | "};\n" | ||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10301 | "void main(){\n" |
10302 | " gl_Position = vec4(1);\n" | ||||
10303 | "}\n"; | ||||
10304 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10305 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10306 | "\n" |
10307 | "layout(location=0) out vec4 x;\n" | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10308 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10309 | "void main(){\n" |
10310 | " x = vec4(1);\n" | ||||
10311 | " y = vec4(1);\n" | ||||
10312 | "}\n"; | ||||
10313 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10314 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
10315 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10316 | |
10317 | VkPipelineObj pipe(m_device); | ||||
10318 | pipe.AddShader(&vs); | ||||
10319 | pipe.AddShader(&fs); | ||||
10320 | |||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10321 | /* set up CB 0, not written */ |
10322 | pipe.AddColorAttachment(); | ||||
10323 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10324 | /* FS writes CB 1, but we don't configure it */ |
10325 | |||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10326 | VkDescriptorSetObj descriptorSet(m_device); |
10327 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10328 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10329 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10330 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10331 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10332 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 10333 | } |
10334 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10335 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10336 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10337 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10338 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10339 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10340 | |
10341 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10342 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10343 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10344 | "out gl_PerVertex {\n" |
10345 | " vec4 gl_Position;\n" | ||||
10346 | "};\n" | ||||
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10347 | "void main(){\n" |
10348 | " gl_Position = vec4(1);\n" | ||||
10349 | "}\n"; | ||||
10350 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10351 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10352 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10353 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10354 | "void main(){\n" |
10355 | " x = ivec4(1);\n" | ||||
10356 | "}\n"; | ||||
10357 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10358 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
10359 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10360 | |
10361 | VkPipelineObj pipe(m_device); | ||||
10362 | pipe.AddShader(&vs); | ||||
10363 | pipe.AddShader(&fs); | ||||
10364 | |||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 10365 | /* set up CB 0; type is UNORM by default */ |
10366 | pipe.AddColorAttachment(); | ||||
10367 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10368 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10369 | VkDescriptorSetObj descriptorSet(m_device); |
10370 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10371 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10372 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 10373 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10374 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10375 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10376 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 10377 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10378 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10379 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10380 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10381 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10382 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10383 | |
10384 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10385 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10386 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 10387 | "out gl_PerVertex {\n" |
10388 | " vec4 gl_Position;\n" | ||||
10389 | "};\n" | ||||
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10390 | "void main(){\n" |
10391 | " gl_Position = vec4(1);\n" | ||||
10392 | "}\n"; | ||||
10393 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 10394 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10395 | "\n" |
10396 | "layout(location=0) out vec4 x;\n" | ||||
10397 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" | ||||
10398 | "void main(){\n" | ||||
10399 | " x = vec4(bar.y);\n" | ||||
10400 | "}\n"; | ||||
10401 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 10402 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
10403 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10404 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10405 | VkPipelineObj pipe(m_device); |
10406 | pipe.AddShader(&vs); | ||||
10407 | pipe.AddShader(&fs); | ||||
10408 | |||||
10409 | /* set up CB 0; type is UNORM by default */ | ||||
10410 | pipe.AddColorAttachment(); | ||||
10411 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
10412 | |||||
10413 | VkDescriptorSetObj descriptorSet(m_device); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10414 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10415 | |
10416 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
10417 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10418 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 10419 | } |
10420 | |||||
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10421 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
10422 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10423 | "not declared in layout"); | ||||
10424 | |||||
10425 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10426 | |||||
10427 | char const *vsSource = | ||||
10428 | "#version 450\n" | ||||
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10429 | "\n" |
10430 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" | ||||
10431 | "out gl_PerVertex {\n" | ||||
10432 | " vec4 gl_Position;\n" | ||||
10433 | "};\n" | ||||
10434 | "void main(){\n" | ||||
10435 | " gl_Position = vec4(consts.x);\n" | ||||
10436 | "}\n"; | ||||
10437 | char const *fsSource = | ||||
10438 | "#version 450\n" | ||||
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10439 | "\n" |
10440 | "layout(location=0) out vec4 x;\n" | ||||
10441 | "void main(){\n" | ||||
10442 | " x = vec4(1);\n" | ||||
10443 | "}\n"; | ||||
10444 | |||||
10445 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
10446 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
10447 | |||||
10448 | VkPipelineObj pipe(m_device); | ||||
10449 | pipe.AddShader(&vs); | ||||
10450 | pipe.AddShader(&fs); | ||||
10451 | |||||
10452 | /* set up CB 0; type is UNORM by default */ | ||||
10453 | pipe.AddColorAttachment(); | ||||
10454 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
10455 | |||||
10456 | VkDescriptorSetObj descriptorSet(m_device); | ||||
10457 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
10458 | |||||
10459 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
10460 | |||||
10461 | /* should have generated an error -- no push constant ranges provided! */ | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10462 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 10463 | } |
10464 | |||||
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 10465 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
10466 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10467 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10468 | "Shader uses descriptor slot 0.0"); | ||||
10469 | |||||
10470 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10471 | |||||
10472 | char const *csSource = | ||||
10473 | "#version 450\n" | ||||
10474 | "\n" | ||||
10475 | "layout(local_size_x=1) in;\n" | ||||
10476 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" | ||||
10477 | "void main(){\n" | ||||
10478 | " x = vec4(1);\n" | ||||
10479 | "}\n"; | ||||
10480 | |||||
10481 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); | ||||
10482 | |||||
10483 | VkDescriptorSetObj descriptorSet(m_device); | ||||
10484 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
10485 | |||||
10486 | VkComputePipelineCreateInfo cpci = { | ||||
10487 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, | ||||
10488 | nullptr, 0, { | ||||
10489 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, | ||||
10490 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, | ||||
10491 | cs.handle(), "main", nullptr | ||||
10492 | }, | ||||
10493 | descriptorSet.GetPipelineLayout(), | ||||
10494 | VK_NULL_HANDLE, -1 | ||||
10495 | }; | ||||
10496 | |||||
10497 | VkPipeline pipe; | ||||
10498 | VkResult err = vkCreateComputePipelines( | ||||
10499 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); | ||||
10500 | |||||
10501 | m_errorMonitor->VerifyFound(); | ||||
10502 | |||||
10503 | if (err == VK_SUCCESS) { | ||||
10504 | vkDestroyPipeline(m_device->device(), pipe, nullptr); | ||||
10505 | } | ||||
10506 | } | ||||
10507 | |||||
10508 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { | ||||
10509 | m_errorMonitor->ExpectSuccess(); | ||||
10510 | |||||
10511 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10512 | |||||
10513 | char const *csSource = | ||||
10514 | "#version 450\n" | ||||
10515 | "\n" | ||||
10516 | "layout(local_size_x=1) in;\n" | ||||
10517 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" | ||||
10518 | "void main(){\n" | ||||
10519 | " // x is not used.\n" | ||||
10520 | "}\n"; | ||||
10521 | |||||
10522 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); | ||||
10523 | |||||
10524 | VkDescriptorSetObj descriptorSet(m_device); | ||||
10525 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
10526 | |||||
10527 | VkComputePipelineCreateInfo cpci = { | ||||
10528 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, | ||||
10529 | nullptr, 0, { | ||||
10530 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, | ||||
10531 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, | ||||
10532 | cs.handle(), "main", nullptr | ||||
10533 | }, | ||||
10534 | descriptorSet.GetPipelineLayout(), | ||||
10535 | VK_NULL_HANDLE, -1 | ||||
10536 | }; | ||||
10537 | |||||
10538 | VkPipeline pipe; | ||||
10539 | VkResult err = vkCreateComputePipelines( | ||||
10540 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); | ||||
10541 | |||||
10542 | m_errorMonitor->VerifyNotFound(); | ||||
10543 | |||||
10544 | if (err == VK_SUCCESS) { | ||||
10545 | vkDestroyPipeline(m_device->device(), pipe, nullptr); | ||||
10546 | } | ||||
10547 | } | ||||
10548 | |||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10549 | #endif // SHADER_CHECKER_TESTS |
10550 | |||||
10551 | #if DEVICE_LIMITS_TESTS | ||||
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10552 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10553 | m_errorMonitor->SetDesiredFailureMsg( |
10554 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10555 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10556 | |
10557 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10558 | |
10559 | // Create an image | ||||
10560 | VkImage image; | ||||
10561 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10562 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
10563 | const int32_t tex_width = 32; | ||||
10564 | const int32_t tex_height = 32; | ||||
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10565 | |
10566 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10567 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
10568 | image_create_info.pNext = NULL; | ||||
10569 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
10570 | image_create_info.format = tex_format; | ||||
10571 | image_create_info.extent.width = tex_width; | ||||
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10572 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10573 | image_create_info.extent.depth = 1; |
10574 | image_create_info.mipLevels = 1; | ||||
10575 | image_create_info.arrayLayers = 1; | ||||
10576 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
10577 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
10578 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
10579 | image_create_info.flags = 0; | ||||
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10580 | |
10581 | // Introduce error by sending down a bogus width extent | ||||
10582 | image_create_info.extent.width = 65536; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10583 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10584 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10585 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 10586 | } |
10587 | |||||
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 10588 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
10589 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10590 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10591 | "CreateImage extents is 0 for at least one required dimension"); | ||||
10592 | |||||
10593 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10594 | |||||
10595 | // Create an image | ||||
10596 | VkImage image; | ||||
10597 | |||||
10598 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
10599 | const int32_t tex_width = 32; | ||||
10600 | const int32_t tex_height = 32; | ||||
10601 | |||||
10602 | VkImageCreateInfo image_create_info = {}; | ||||
10603 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
10604 | image_create_info.pNext = NULL; | ||||
10605 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
10606 | image_create_info.format = tex_format; | ||||
10607 | image_create_info.extent.width = tex_width; | ||||
10608 | image_create_info.extent.height = tex_height; | ||||
10609 | image_create_info.extent.depth = 1; | ||||
10610 | image_create_info.mipLevels = 1; | ||||
10611 | image_create_info.arrayLayers = 1; | ||||
10612 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
10613 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
10614 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
10615 | image_create_info.flags = 0; | ||||
10616 | |||||
10617 | // Introduce error by sending down a bogus width extent | ||||
10618 | image_create_info.extent.width = 0; | ||||
10619 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
10620 | |||||
10621 | m_errorMonitor->VerifyFound(); | ||||
10622 | } | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10623 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10624 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10625 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10626 | TEST_F(VkLayerTest, InvalidImageView) { |
10627 | VkResult err; | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10628 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10629 | m_errorMonitor->SetDesiredFailureMsg( |
10630 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10631 | "vkCreateImageView called with baseMipLevel 10 "); |
10632 | |||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10633 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10634 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10635 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10636 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10637 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10638 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
10639 | const int32_t tex_width = 32; | ||||
10640 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10641 | |
10642 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10643 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
10644 | image_create_info.pNext = NULL; | ||||
10645 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
10646 | image_create_info.format = tex_format; | ||||
10647 | image_create_info.extent.width = tex_width; | ||||
10648 | image_create_info.extent.height = tex_height; | ||||
10649 | image_create_info.extent.depth = 1; | ||||
10650 | image_create_info.mipLevels = 1; | ||||
10651 | image_create_info.arrayLayers = 1; | ||||
10652 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
10653 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
10654 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
10655 | image_create_info.flags = 0; | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10656 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10657 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10658 | ASSERT_VK_SUCCESS(err); |
10659 | |||||
10660 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10661 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
10662 | image_view_create_info.image = image; | ||||
10663 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
10664 | image_view_create_info.format = tex_format; | ||||
10665 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
10666 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error | ||||
10667 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
10668 | image_view_create_info.subresourceRange.aspectMask = | ||||
10669 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10670 | |
10671 | VkImageView view; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10672 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
10673 | &view); | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10674 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10675 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 10676 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10677 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10678 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10679 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10680 | TEST_DESCRIPTION( |
10681 | "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] | 10682 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10683 | "vkCreateImageView: Color image " |
10684 | "formats must have ONLY the " | ||||
10685 | "VK_IMAGE_ASPECT_COLOR_BIT set"); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10686 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10687 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10688 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10689 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10690 | VkImageObj image(m_device); |
10691 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, | ||||
10692 | VK_IMAGE_TILING_LINEAR, 0); | ||||
10693 | ASSERT_TRUE(image.initialized()); | ||||
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10694 | |
10695 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10696 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10697 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10698 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
10699 | image_view_create_info.format = tex_format; | ||||
10700 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
10701 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
10702 | // Cause an error by setting an invalid image aspect | ||||
10703 | image_view_create_info.subresourceRange.aspectMask = | ||||
10704 | VK_IMAGE_ASPECT_METADATA_BIT; | ||||
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10705 | |
10706 | VkImageView view; | ||||
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10707 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10708 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10709 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10710 | } |
10711 | |||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10712 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10713 | VkResult err; |
10714 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10715 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10716 | m_errorMonitor->SetDesiredFailureMsg( |
10717 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10718 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10719 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10720 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10721 | |
10722 | // Create two images of different types and try to copy between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10723 | VkImage srcImage; |
10724 | VkImage dstImage; | ||||
10725 | VkDeviceMemory srcMem; | ||||
10726 | VkDeviceMemory destMem; | ||||
10727 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10728 | |
10729 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10730 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
10731 | image_create_info.pNext = NULL; | ||||
10732 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
10733 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
10734 | image_create_info.extent.width = 32; | ||||
10735 | image_create_info.extent.height = 32; | ||||
10736 | image_create_info.extent.depth = 1; | ||||
10737 | image_create_info.mipLevels = 1; | ||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10738 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10739 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
10740 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
10741 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
10742 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10743 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10744 | err = |
10745 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10746 | ASSERT_VK_SUCCESS(err); |
10747 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10748 | err = |
10749 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10750 | ASSERT_VK_SUCCESS(err); |
10751 | |||||
10752 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10753 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10754 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
10755 | memAlloc.pNext = NULL; | ||||
10756 | memAlloc.allocationSize = 0; | ||||
10757 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10758 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10759 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10760 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10761 | pass = |
10762 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10763 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10764 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10765 | ASSERT_VK_SUCCESS(err); |
10766 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10767 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10768 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10769 | pass = |
10770 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10771 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10772 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10773 | ASSERT_VK_SUCCESS(err); |
10774 | |||||
10775 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
10776 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10777 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10778 | ASSERT_VK_SUCCESS(err); |
10779 | |||||
10780 | BeginCommandBuffer(); | ||||
10781 | VkImageCopy copyRegion; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10782 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10783 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10784 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10785 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10786 | copyRegion.srcOffset.x = 0; |
10787 | copyRegion.srcOffset.y = 0; | ||||
10788 | copyRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10789 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10790 | copyRegion.dstSubresource.mipLevel = 0; |
10791 | copyRegion.dstSubresource.baseArrayLayer = 0; | ||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10792 | // Introduce failure by forcing the dst layerCount to differ from src |
10793 | copyRegion.dstSubresource.layerCount = 3; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10794 | copyRegion.dstOffset.x = 0; |
10795 | copyRegion.dstOffset.y = 0; | ||||
10796 | copyRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10797 | copyRegion.extent.width = 1; |
10798 | copyRegion.extent.height = 1; | ||||
10799 | copyRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10800 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
10801 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10802 | EndCommandBuffer(); |
10803 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10804 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10805 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10806 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10807 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10808 | vkFreeMemory(m_device->device(), srcMem, NULL); |
10809 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10810 | } |
10811 | |||||
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10812 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
10813 | |||||
10814 | TEST_DESCRIPTION("Creating images with unsuported formats "); | ||||
10815 | |||||
10816 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10817 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
10818 | VkImageObj image(m_device); | ||||
10819 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
10820 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | ||||
10821 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
10822 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
10823 | ASSERT_TRUE(image.initialized()); | ||||
10824 | |||||
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10825 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
10826 | VkImageCreateInfo image_create_info; | ||||
10827 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
10828 | image_create_info.pNext = NULL; | ||||
10829 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
10830 | image_create_info.format = VK_FORMAT_UNDEFINED; | ||||
10831 | image_create_info.extent.width = 32; | ||||
10832 | image_create_info.extent.height = 32; | ||||
10833 | image_create_info.extent.depth = 1; | ||||
10834 | image_create_info.mipLevels = 1; | ||||
10835 | image_create_info.arrayLayers = 1; | ||||
10836 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
10837 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
10838 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
10839 | image_create_info.flags = 0; | ||||
10840 | |||||
10841 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10842 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10843 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); | ||||
10844 | |||||
10845 | VkImage localImage; | ||||
10846 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); | ||||
10847 | m_errorMonitor->VerifyFound(); | ||||
10848 | |||||
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10849 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10850 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10851 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
10852 | VkFormat format = static_cast<VkFormat>(f); | ||||
10853 | VkFormatProperties fProps = m_device->format_properties(format); | ||||
10854 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && | ||||
10855 | fProps.optimalTilingFeatures == 0) { | ||||
10856 | unsupported = format; | ||||
10857 | break; | ||||
10858 | } | ||||
10859 | } | ||||
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10860 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10861 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10862 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10863 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10864 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10865 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10866 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10867 | m_errorMonitor->VerifyFound(); |
10868 | } | ||||
10869 | } | ||||
10870 | |||||
10871 | TEST_F(VkLayerTest, ImageLayerViewTests) { | ||||
10872 | VkResult ret; | ||||
10873 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); | ||||
10874 | |||||
10875 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10876 | |||||
10877 | VkImageObj image(m_device); | ||||
10878 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
10879 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | ||||
10880 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
10881 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
10882 | ASSERT_TRUE(image.initialized()); | ||||
10883 | |||||
10884 | VkImageView imgView; | ||||
10885 | VkImageViewCreateInfo imgViewInfo = {}; | ||||
10886 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
10887 | imgViewInfo.image = image.handle(); | ||||
10888 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
10889 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
10890 | imgViewInfo.subresourceRange.layerCount = 1; | ||||
10891 | imgViewInfo.subresourceRange.baseMipLevel = 0; | ||||
10892 | imgViewInfo.subresourceRange.levelCount = 1; | ||||
10893 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
10894 | |||||
10895 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10896 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10897 | "vkCreateImageView called with baseMipLevel"); | ||||
10898 | // View can't have baseMipLevel >= image's mipLevels - Expect | ||||
10899 | // VIEW_CREATE_ERROR | ||||
10900 | imgViewInfo.subresourceRange.baseMipLevel = 1; | ||||
10901 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
10902 | m_errorMonitor->VerifyFound(); | ||||
10903 | imgViewInfo.subresourceRange.baseMipLevel = 0; | ||||
10904 | |||||
10905 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10906 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10907 | "vkCreateImageView called with baseArrayLayer"); | ||||
10908 | // View can't have baseArrayLayer >= image's arraySize - Expect | ||||
10909 | // VIEW_CREATE_ERROR | ||||
10910 | imgViewInfo.subresourceRange.baseArrayLayer = 1; | ||||
10911 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
10912 | m_errorMonitor->VerifyFound(); | ||||
10913 | imgViewInfo.subresourceRange.baseArrayLayer = 0; | ||||
10914 | |||||
10915 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10916 | "vkCreateImageView called with 0 in " | ||||
10917 | "pCreateInfo->subresourceRange." | ||||
10918 | "levelCount"); | ||||
10919 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR | ||||
10920 | imgViewInfo.subresourceRange.levelCount = 0; | ||||
10921 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
10922 | m_errorMonitor->VerifyFound(); | ||||
10923 | imgViewInfo.subresourceRange.levelCount = 1; | ||||
10924 | |||||
10925 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10926 | "vkCreateImageView called with 0 in " | ||||
10927 | "pCreateInfo->subresourceRange." | ||||
10928 | "layerCount"); | ||||
10929 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR | ||||
10930 | imgViewInfo.subresourceRange.layerCount = 0; | ||||
10931 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
10932 | m_errorMonitor->VerifyFound(); | ||||
10933 | imgViewInfo.subresourceRange.layerCount = 1; | ||||
10934 | |||||
10935 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10936 | "but both must be color formats"); | ||||
10937 | // Can't use depth format for view into color image - Expect INVALID_FORMAT | ||||
10938 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
10939 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
10940 | m_errorMonitor->VerifyFound(); | ||||
10941 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
10942 | |||||
10943 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10944 | "Formats MUST be IDENTICAL unless " | ||||
10945 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " | ||||
10946 | "was set on image creation."); | ||||
10947 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect | ||||
10948 | // VIEW_CREATE_ERROR | ||||
10949 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; | ||||
10950 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
10951 | m_errorMonitor->VerifyFound(); | ||||
10952 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
10953 | |||||
10954 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10955 | "can support ImageViews with " | ||||
10956 | "differing formats but they must be " | ||||
10957 | "in the same compatibility class."); | ||||
10958 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect | ||||
10959 | // VIEW_CREATE_ERROR | ||||
10960 | VkImageCreateInfo mutImgInfo = image.create_info(); | ||||
10961 | VkImage mutImage; | ||||
10962 | mutImgInfo.format = VK_FORMAT_R8_UINT; | ||||
10963 | assert( | ||||
10964 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & | ||||
10965 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); | ||||
10966 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; | ||||
10967 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
10968 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); | ||||
10969 | ASSERT_VK_SUCCESS(ret); | ||||
10970 | imgViewInfo.image = mutImage; | ||||
10971 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
10972 | m_errorMonitor->VerifyFound(); | ||||
10973 | imgViewInfo.image = image.handle(); | ||||
10974 | vkDestroyImage(m_device->handle(), mutImage, NULL); | ||||
10975 | } | ||||
10976 | |||||
10977 | TEST_F(VkLayerTest, MiscImageLayerTests) { | ||||
10978 | |||||
10979 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); | ||||
10980 | |||||
10981 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10982 | |||||
10983 | VkImageObj image(m_device); | ||||
10984 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
10985 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | ||||
10986 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
10987 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
10988 | ASSERT_TRUE(image.initialized()); | ||||
10989 | |||||
10990 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10991 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10992 | "number of layers in image subresource is zero"); | ||||
10993 | vk_testing::Buffer buffer; | ||||
10994 | VkMemoryPropertyFlags reqs = 0; | ||||
10995 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); | ||||
10996 | VkBufferImageCopy region = {}; | ||||
10997 | region.bufferRowLength = 128; | ||||
10998 | region.bufferImageHeight = 128; | ||||
10999 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
11000 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT | ||||
11001 | region.imageSubresource.layerCount = 0; | ||||
11002 | region.imageExtent.height = 4; | ||||
11003 | region.imageExtent.width = 4; | ||||
11004 | region.imageExtent.depth = 1; | ||||
11005 | m_commandBuffer->BeginCommandBuffer(); | ||||
11006 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), | ||||
11007 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
11008 | 1, ®ion); | ||||
11009 | m_errorMonitor->VerifyFound(); | ||||
11010 | region.imageSubresource.layerCount = 1; | ||||
11011 | |||||
11012 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11013 | "aspectMasks for each region must " | ||||
11014 | "specify only COLOR or DEPTH or " | ||||
11015 | "STENCIL"); | ||||
11016 | // Expect MISMATCHED_IMAGE_ASPECT | ||||
11017 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; | ||||
11018 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), | ||||
11019 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
11020 | 1, ®ion); | ||||
11021 | m_errorMonitor->VerifyFound(); | ||||
11022 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
11023 | |||||
11024 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11025 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11026 | "If the format of srcImage is a depth, stencil, depth stencil or " | ||||
11027 | "integer-based format then filter must be VK_FILTER_NEAREST"); | ||||
11028 | // Expect INVALID_FILTER | ||||
11029 | VkImageObj intImage1(m_device); | ||||
11030 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, | ||||
11031 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, | ||||
11032 | 0); | ||||
11033 | VkImageObj intImage2(m_device); | ||||
11034 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, | ||||
11035 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, | ||||
11036 | 0); | ||||
11037 | VkImageBlit blitRegion = {}; | ||||
11038 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
11039 | blitRegion.srcSubresource.baseArrayLayer = 0; | ||||
11040 | blitRegion.srcSubresource.layerCount = 1; | ||||
11041 | blitRegion.srcSubresource.mipLevel = 0; | ||||
11042 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
11043 | blitRegion.dstSubresource.baseArrayLayer = 0; | ||||
11044 | blitRegion.dstSubresource.layerCount = 1; | ||||
11045 | blitRegion.dstSubresource.mipLevel = 0; | ||||
11046 | |||||
11047 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), | ||||
11048 | intImage1.layout(), intImage2.handle(), intImage2.layout(), | ||||
11049 | 16, &blitRegion, VK_FILTER_LINEAR); | ||||
11050 | m_errorMonitor->VerifyFound(); | ||||
11051 | |||||
11052 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11053 | "called with 0 in ppMemoryBarriers"); | ||||
11054 | VkImageMemoryBarrier img_barrier; | ||||
11055 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; | ||||
11056 | img_barrier.pNext = NULL; | ||||
11057 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
11058 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
11059 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
11060 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
11061 | img_barrier.image = image.handle(); | ||||
11062 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
11063 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
11064 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
11065 | img_barrier.subresourceRange.baseArrayLayer = 0; | ||||
11066 | img_barrier.subresourceRange.baseMipLevel = 0; | ||||
11067 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE | ||||
11068 | img_barrier.subresourceRange.layerCount = 0; | ||||
11069 | img_barrier.subresourceRange.levelCount = 1; | ||||
11070 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
11071 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
11072 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
11073 | nullptr, 1, &img_barrier); | ||||
11074 | m_errorMonitor->VerifyFound(); | ||||
11075 | img_barrier.subresourceRange.layerCount = 1; | ||||
11076 | } | ||||
11077 | |||||
11078 | TEST_F(VkLayerTest, ImageFormatLimits) { | ||||
11079 | |||||
11080 | TEST_DESCRIPTION("Exceed the limits of image format "); | ||||
11081 | |||||
11082 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11083 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11084 | "CreateImage extents exceed allowable limits for format"); | ||||
11085 | VkImageCreateInfo image_create_info = {}; | ||||
11086 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
11087 | image_create_info.pNext = NULL; | ||||
11088 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
11089 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
11090 | image_create_info.extent.width = 32; | ||||
11091 | image_create_info.extent.height = 32; | ||||
11092 | image_create_info.extent.depth = 1; | ||||
11093 | image_create_info.mipLevels = 1; | ||||
11094 | image_create_info.arrayLayers = 1; | ||||
11095 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
11096 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
11097 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
11098 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; | ||||
11099 | image_create_info.flags = 0; | ||||
11100 | |||||
11101 | VkImage nullImg; | ||||
11102 | VkImageFormatProperties imgFmtProps; | ||||
11103 | vkGetPhysicalDeviceImageFormatProperties( | ||||
11104 | gpu(), image_create_info.format, image_create_info.imageType, | ||||
11105 | image_create_info.tiling, image_create_info.usage, | ||||
11106 | image_create_info.flags, &imgFmtProps); | ||||
11107 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; | ||||
11108 | // Expect INVALID_FORMAT_LIMITS_VIOLATION | ||||
11109 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
11110 | m_errorMonitor->VerifyFound(); | ||||
11111 | image_create_info.extent.depth = 1; | ||||
11112 | |||||
11113 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11114 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11115 | "exceeds allowable maximum supported by format of"); | ||||
11116 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; | ||||
11117 | // Expect INVALID_FORMAT_LIMITS_VIOLATION | ||||
11118 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
11119 | m_errorMonitor->VerifyFound(); | ||||
11120 | image_create_info.mipLevels = 1; | ||||
11121 | |||||
11122 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11123 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11124 | "exceeds allowable maximum supported by format of"); | ||||
11125 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; | ||||
11126 | // Expect INVALID_FORMAT_LIMITS_VIOLATION | ||||
11127 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
11128 | m_errorMonitor->VerifyFound(); | ||||
11129 | image_create_info.arrayLayers = 1; | ||||
11130 | |||||
11131 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11132 | "is not supported by format"); | ||||
11133 | int samples = imgFmtProps.sampleCounts >> 1; | ||||
11134 | image_create_info.samples = (VkSampleCountFlagBits)samples; | ||||
11135 | // Expect INVALID_FORMAT_LIMITS_VIOLATION | ||||
11136 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
11137 | m_errorMonitor->VerifyFound(); | ||||
11138 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
11139 | |||||
11140 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11141 | "pCreateInfo->initialLayout, must be " | ||||
11142 | "VK_IMAGE_LAYOUT_UNDEFINED or " | ||||
11143 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); | ||||
11144 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
11145 | // Expect INVALID_LAYOUT | ||||
11146 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
11147 | m_errorMonitor->VerifyFound(); | ||||
11148 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; | ||||
11149 | } | ||||
11150 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11151 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11152 | VkResult err; |
11153 | bool pass; | ||||
11154 | |||||
11155 | // Create color images with different format sizes and try to copy between them | ||||
11156 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11157 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11158 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); | ||||
11159 | |||||
11160 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
11161 | |||||
11162 | // Create two images of different types and try to copy between them | ||||
11163 | VkImage srcImage; | ||||
11164 | VkImage dstImage; | ||||
11165 | VkDeviceMemory srcMem; | ||||
11166 | VkDeviceMemory destMem; | ||||
11167 | VkMemoryRequirements memReqs; | ||||
11168 | |||||
11169 | VkImageCreateInfo image_create_info = {}; | ||||
11170 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
11171 | image_create_info.pNext = NULL; | ||||
11172 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
11173 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
11174 | image_create_info.extent.width = 32; | ||||
11175 | image_create_info.extent.height = 32; | ||||
11176 | image_create_info.extent.depth = 1; | ||||
11177 | image_create_info.mipLevels = 1; | ||||
11178 | image_create_info.arrayLayers = 1; | ||||
11179 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
11180 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
11181 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
11182 | image_create_info.flags = 0; | ||||
11183 | |||||
11184 | err = | ||||
11185 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
11186 | ASSERT_VK_SUCCESS(err); | ||||
11187 | |||||
11188 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; | ||||
11189 | // Introduce failure by creating second image with a different-sized format. | ||||
11190 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; | ||||
11191 | |||||
11192 | err = | ||||
11193 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
11194 | ASSERT_VK_SUCCESS(err); | ||||
11195 | |||||
11196 | // Allocate memory | ||||
11197 | VkMemoryAllocateInfo memAlloc = {}; | ||||
11198 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
11199 | memAlloc.pNext = NULL; | ||||
11200 | memAlloc.allocationSize = 0; | ||||
11201 | memAlloc.memoryTypeIndex = 0; | ||||
11202 | |||||
11203 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); | ||||
11204 | memAlloc.allocationSize = memReqs.size; | ||||
11205 | pass = | ||||
11206 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
11207 | ASSERT_TRUE(pass); | ||||
11208 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); | ||||
11209 | ASSERT_VK_SUCCESS(err); | ||||
11210 | |||||
11211 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); | ||||
11212 | memAlloc.allocationSize = memReqs.size; | ||||
11213 | pass = | ||||
11214 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
11215 | ASSERT_TRUE(pass); | ||||
11216 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); | ||||
11217 | ASSERT_VK_SUCCESS(err); | ||||
11218 | |||||
11219 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
11220 | ASSERT_VK_SUCCESS(err); | ||||
11221 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); | ||||
11222 | ASSERT_VK_SUCCESS(err); | ||||
11223 | |||||
11224 | BeginCommandBuffer(); | ||||
11225 | VkImageCopy copyRegion; | ||||
11226 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
11227 | copyRegion.srcSubresource.mipLevel = 0; | ||||
11228 | copyRegion.srcSubresource.baseArrayLayer = 0; | ||||
11229 | copyRegion.srcSubresource.layerCount = 0; | ||||
11230 | copyRegion.srcOffset.x = 0; | ||||
11231 | copyRegion.srcOffset.y = 0; | ||||
11232 | copyRegion.srcOffset.z = 0; | ||||
11233 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
11234 | copyRegion.dstSubresource.mipLevel = 0; | ||||
11235 | copyRegion.dstSubresource.baseArrayLayer = 0; | ||||
11236 | copyRegion.dstSubresource.layerCount = 0; | ||||
11237 | copyRegion.dstOffset.x = 0; | ||||
11238 | copyRegion.dstOffset.y = 0; | ||||
11239 | copyRegion.dstOffset.z = 0; | ||||
11240 | copyRegion.extent.width = 1; | ||||
11241 | copyRegion.extent.height = 1; | ||||
11242 | copyRegion.extent.depth = 1; | ||||
11243 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, | ||||
11244 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
11245 | EndCommandBuffer(); | ||||
11246 | |||||
11247 | m_errorMonitor->VerifyFound(); | ||||
11248 | |||||
11249 | vkDestroyImage(m_device->device(), srcImage, NULL); | ||||
11250 | vkDestroyImage(m_device->device(), dstImage, NULL); | ||||
11251 | vkFreeMemory(m_device->device(), srcMem, NULL); | ||||
11252 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11253 | } |
11254 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11255 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
11256 | VkResult err; | ||||
11257 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11258 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11259 | // 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] | 11260 | m_errorMonitor->SetDesiredFailureMsg( |
11261 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11262 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11263 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11264 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11265 | |
11266 | // Create two images of different types and try to copy between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11267 | VkImage srcImage; |
11268 | VkImage dstImage; | ||||
11269 | VkDeviceMemory srcMem; | ||||
11270 | VkDeviceMemory destMem; | ||||
11271 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11272 | |
11273 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11274 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
11275 | image_create_info.pNext = NULL; | ||||
11276 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
11277 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
11278 | image_create_info.extent.width = 32; | ||||
11279 | image_create_info.extent.height = 32; | ||||
11280 | image_create_info.extent.depth = 1; | ||||
11281 | image_create_info.mipLevels = 1; | ||||
11282 | image_create_info.arrayLayers = 1; | ||||
11283 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
11284 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
11285 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
11286 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11287 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11288 | err = |
11289 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11290 | ASSERT_VK_SUCCESS(err); |
11291 | |||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11292 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
11293 | |||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11294 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11295 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 11296 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
11297 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11298 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11299 | err = |
11300 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11301 | ASSERT_VK_SUCCESS(err); |
11302 | |||||
11303 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11304 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11305 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
11306 | memAlloc.pNext = NULL; | ||||
11307 | memAlloc.allocationSize = 0; | ||||
11308 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11309 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11310 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11311 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11312 | pass = |
11313 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11314 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11315 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11316 | ASSERT_VK_SUCCESS(err); |
11317 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11318 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11319 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11320 | pass = |
11321 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11322 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11323 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11324 | ASSERT_VK_SUCCESS(err); |
11325 | |||||
11326 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
11327 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11328 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11329 | ASSERT_VK_SUCCESS(err); |
11330 | |||||
11331 | BeginCommandBuffer(); | ||||
11332 | VkImageCopy copyRegion; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11333 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11334 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11335 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11336 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11337 | copyRegion.srcOffset.x = 0; |
11338 | copyRegion.srcOffset.y = 0; | ||||
11339 | copyRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11340 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11341 | copyRegion.dstSubresource.mipLevel = 0; |
11342 | copyRegion.dstSubresource.baseArrayLayer = 0; | ||||
11343 | copyRegion.dstSubresource.layerCount = 0; | ||||
11344 | copyRegion.dstOffset.x = 0; | ||||
11345 | copyRegion.dstOffset.y = 0; | ||||
11346 | copyRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11347 | copyRegion.extent.width = 1; |
11348 | copyRegion.extent.height = 1; | ||||
11349 | copyRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11350 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
11351 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11352 | EndCommandBuffer(); |
11353 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11354 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11355 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11356 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11357 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11358 | vkFreeMemory(m_device->device(), srcMem, NULL); |
11359 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11360 | } |
11361 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11362 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
11363 | VkResult err; | ||||
11364 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11365 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11366 | m_errorMonitor->SetDesiredFailureMsg( |
11367 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11368 | "vkCmdResolveImage called with source sample count less than 2."); |
11369 | |||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11370 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11371 | |
11372 | // 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] | 11373 | VkImage srcImage; |
11374 | VkImage dstImage; | ||||
11375 | VkDeviceMemory srcMem; | ||||
11376 | VkDeviceMemory destMem; | ||||
11377 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11378 | |
11379 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11380 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
11381 | image_create_info.pNext = NULL; | ||||
11382 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
11383 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
11384 | image_create_info.extent.width = 32; | ||||
11385 | image_create_info.extent.height = 1; | ||||
11386 | image_create_info.extent.depth = 1; | ||||
11387 | image_create_info.mipLevels = 1; | ||||
11388 | image_create_info.arrayLayers = 1; | ||||
11389 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
11390 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
11391 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
11392 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11393 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11394 | err = |
11395 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11396 | ASSERT_VK_SUCCESS(err); |
11397 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11398 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11399 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11400 | err = |
11401 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11402 | ASSERT_VK_SUCCESS(err); |
11403 | |||||
11404 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11405 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11406 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
11407 | memAlloc.pNext = NULL; | ||||
11408 | memAlloc.allocationSize = 0; | ||||
11409 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11410 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11411 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11412 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11413 | pass = |
11414 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11415 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11416 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11417 | ASSERT_VK_SUCCESS(err); |
11418 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11419 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11420 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11421 | pass = |
11422 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11423 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11424 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11425 | ASSERT_VK_SUCCESS(err); |
11426 | |||||
11427 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
11428 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11429 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11430 | ASSERT_VK_SUCCESS(err); |
11431 | |||||
11432 | BeginCommandBuffer(); | ||||
11433 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11434 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
11435 | // VK_IMAGE_LAYOUT_GENERAL = 1, | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11436 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11437 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11438 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11439 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11440 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11441 | resolveRegion.srcOffset.x = 0; |
11442 | resolveRegion.srcOffset.y = 0; | ||||
11443 | resolveRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11444 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11445 | resolveRegion.dstSubresource.mipLevel = 0; |
11446 | resolveRegion.dstSubresource.baseArrayLayer = 0; | ||||
11447 | resolveRegion.dstSubresource.layerCount = 0; | ||||
11448 | resolveRegion.dstOffset.x = 0; | ||||
11449 | resolveRegion.dstOffset.y = 0; | ||||
11450 | resolveRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11451 | resolveRegion.extent.width = 1; |
11452 | resolveRegion.extent.height = 1; | ||||
11453 | resolveRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11454 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
11455 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11456 | EndCommandBuffer(); |
11457 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11458 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11459 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11460 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11461 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11462 | vkFreeMemory(m_device->device(), srcMem, NULL); |
11463 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11464 | } |
11465 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11466 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
11467 | VkResult err; | ||||
11468 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11469 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11470 | m_errorMonitor->SetDesiredFailureMsg( |
11471 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11472 | "vkCmdResolveImage called with dest sample count greater than 1."); |
11473 | |||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11474 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11475 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11476 | // 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] | 11477 | VkImage srcImage; |
11478 | VkImage dstImage; | ||||
11479 | VkDeviceMemory srcMem; | ||||
11480 | VkDeviceMemory destMem; | ||||
11481 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11482 | |
11483 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11484 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
11485 | image_create_info.pNext = NULL; | ||||
11486 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
11487 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
11488 | image_create_info.extent.width = 32; | ||||
11489 | image_create_info.extent.height = 1; | ||||
11490 | image_create_info.extent.depth = 1; | ||||
11491 | image_create_info.mipLevels = 1; | ||||
11492 | image_create_info.arrayLayers = 1; | ||||
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 11493 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11494 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
11495 | // Note: Some implementations expect color attachment usage for any | ||||
11496 | // multisample surface | ||||
11497 | image_create_info.usage = | ||||
11498 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
11499 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11500 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11501 | err = |
11502 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11503 | ASSERT_VK_SUCCESS(err); |
11504 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11505 | // Note: Some implementations expect color attachment usage for any |
11506 | // multisample surface | ||||
11507 | image_create_info.usage = | ||||
11508 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11509 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11510 | err = |
11511 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11512 | ASSERT_VK_SUCCESS(err); |
11513 | |||||
11514 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11515 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11516 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
11517 | memAlloc.pNext = NULL; | ||||
11518 | memAlloc.allocationSize = 0; | ||||
11519 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11520 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11521 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11522 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11523 | pass = |
11524 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11525 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11526 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11527 | ASSERT_VK_SUCCESS(err); |
11528 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11529 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11530 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11531 | pass = |
11532 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11533 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11534 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11535 | ASSERT_VK_SUCCESS(err); |
11536 | |||||
11537 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
11538 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11539 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11540 | ASSERT_VK_SUCCESS(err); |
11541 | |||||
11542 | BeginCommandBuffer(); | ||||
11543 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11544 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
11545 | // VK_IMAGE_LAYOUT_GENERAL = 1, | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11546 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11547 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11548 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11549 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11550 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11551 | resolveRegion.srcOffset.x = 0; |
11552 | resolveRegion.srcOffset.y = 0; | ||||
11553 | resolveRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11554 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11555 | resolveRegion.dstSubresource.mipLevel = 0; |
11556 | resolveRegion.dstSubresource.baseArrayLayer = 0; | ||||
11557 | resolveRegion.dstSubresource.layerCount = 0; | ||||
11558 | resolveRegion.dstOffset.x = 0; | ||||
11559 | resolveRegion.dstOffset.y = 0; | ||||
11560 | resolveRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11561 | resolveRegion.extent.width = 1; |
11562 | resolveRegion.extent.height = 1; | ||||
11563 | resolveRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11564 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
11565 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11566 | EndCommandBuffer(); |
11567 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11568 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11569 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11570 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11571 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11572 | vkFreeMemory(m_device->device(), srcMem, NULL); |
11573 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11574 | } |
11575 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11576 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
11577 | VkResult err; | ||||
11578 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11579 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11580 | m_errorMonitor->SetDesiredFailureMsg( |
11581 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11582 | "vkCmdResolveImage called with unmatched source and dest formats."); |
11583 | |||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11584 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11585 | |
11586 | // Create two images of different types and try to copy between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11587 | VkImage srcImage; |
11588 | VkImage dstImage; | ||||
11589 | VkDeviceMemory srcMem; | ||||
11590 | VkDeviceMemory destMem; | ||||
11591 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11592 | |
11593 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11594 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
11595 | image_create_info.pNext = NULL; | ||||
11596 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
11597 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
11598 | image_create_info.extent.width = 32; | ||||
11599 | image_create_info.extent.height = 1; | ||||
11600 | image_create_info.extent.depth = 1; | ||||
11601 | image_create_info.mipLevels = 1; | ||||
11602 | image_create_info.arrayLayers = 1; | ||||
11603 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; | ||||
11604 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
11605 | // Note: Some implementations expect color attachment usage for any | ||||
11606 | // multisample surface | ||||
11607 | image_create_info.usage = | ||||
11608 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
11609 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11610 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11611 | err = |
11612 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11613 | ASSERT_VK_SUCCESS(err); |
11614 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11615 | // Set format to something other than source image |
11616 | image_create_info.format = VK_FORMAT_R32_SFLOAT; | ||||
11617 | // Note: Some implementations expect color attachment usage for any | ||||
11618 | // multisample surface | ||||
11619 | image_create_info.usage = | ||||
11620 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
11621 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11622 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11623 | err = |
11624 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11625 | ASSERT_VK_SUCCESS(err); |
11626 | |||||
11627 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11628 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11629 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
11630 | memAlloc.pNext = NULL; | ||||
11631 | memAlloc.allocationSize = 0; | ||||
11632 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11633 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11634 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11635 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11636 | pass = |
11637 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11638 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11639 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11640 | ASSERT_VK_SUCCESS(err); |
11641 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11642 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11643 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11644 | pass = |
11645 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11646 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11647 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11648 | ASSERT_VK_SUCCESS(err); |
11649 | |||||
11650 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
11651 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11652 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11653 | ASSERT_VK_SUCCESS(err); |
11654 | |||||
11655 | BeginCommandBuffer(); | ||||
11656 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11657 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
11658 | // VK_IMAGE_LAYOUT_GENERAL = 1, | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11659 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11660 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11661 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11662 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11663 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11664 | resolveRegion.srcOffset.x = 0; |
11665 | resolveRegion.srcOffset.y = 0; | ||||
11666 | resolveRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11667 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11668 | resolveRegion.dstSubresource.mipLevel = 0; |
11669 | resolveRegion.dstSubresource.baseArrayLayer = 0; | ||||
11670 | resolveRegion.dstSubresource.layerCount = 0; | ||||
11671 | resolveRegion.dstOffset.x = 0; | ||||
11672 | resolveRegion.dstOffset.y = 0; | ||||
11673 | resolveRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11674 | resolveRegion.extent.width = 1; |
11675 | resolveRegion.extent.height = 1; | ||||
11676 | resolveRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11677 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
11678 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11679 | EndCommandBuffer(); |
11680 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11681 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11682 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11683 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11684 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11685 | vkFreeMemory(m_device->device(), srcMem, NULL); |
11686 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11687 | } |
11688 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11689 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
11690 | VkResult err; | ||||
11691 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11692 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11693 | m_errorMonitor->SetDesiredFailureMsg( |
11694 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11695 | "vkCmdResolveImage called with unmatched source and dest image types."); |
11696 | |||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11697 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11698 | |
11699 | // Create two images of different types and try to copy between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11700 | VkImage srcImage; |
11701 | VkImage dstImage; | ||||
11702 | VkDeviceMemory srcMem; | ||||
11703 | VkDeviceMemory destMem; | ||||
11704 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11705 | |
11706 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11707 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
11708 | image_create_info.pNext = NULL; | ||||
11709 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
11710 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
11711 | image_create_info.extent.width = 32; | ||||
11712 | image_create_info.extent.height = 1; | ||||
11713 | image_create_info.extent.depth = 1; | ||||
11714 | image_create_info.mipLevels = 1; | ||||
11715 | image_create_info.arrayLayers = 1; | ||||
11716 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; | ||||
11717 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
11718 | // Note: Some implementations expect color attachment usage for any | ||||
11719 | // multisample surface | ||||
11720 | image_create_info.usage = | ||||
11721 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
11722 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11723 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11724 | err = |
11725 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11726 | ASSERT_VK_SUCCESS(err); |
11727 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11728 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
11729 | // Note: Some implementations expect color attachment usage for any | ||||
11730 | // multisample surface | ||||
11731 | image_create_info.usage = | ||||
11732 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
11733 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11734 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11735 | err = |
11736 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11737 | ASSERT_VK_SUCCESS(err); |
11738 | |||||
11739 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11740 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11741 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
11742 | memAlloc.pNext = NULL; | ||||
11743 | memAlloc.allocationSize = 0; | ||||
11744 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11745 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11746 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11747 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11748 | pass = |
11749 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11750 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11751 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11752 | ASSERT_VK_SUCCESS(err); |
11753 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11754 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11755 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11756 | pass = |
11757 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11758 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11759 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11760 | ASSERT_VK_SUCCESS(err); |
11761 | |||||
11762 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
11763 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11764 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11765 | ASSERT_VK_SUCCESS(err); |
11766 | |||||
11767 | BeginCommandBuffer(); | ||||
11768 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11769 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
11770 | // VK_IMAGE_LAYOUT_GENERAL = 1, | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11771 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11772 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11773 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11774 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11775 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11776 | resolveRegion.srcOffset.x = 0; |
11777 | resolveRegion.srcOffset.y = 0; | ||||
11778 | resolveRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11779 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11780 | resolveRegion.dstSubresource.mipLevel = 0; |
11781 | resolveRegion.dstSubresource.baseArrayLayer = 0; | ||||
11782 | resolveRegion.dstSubresource.layerCount = 0; | ||||
11783 | resolveRegion.dstOffset.x = 0; | ||||
11784 | resolveRegion.dstOffset.y = 0; | ||||
11785 | resolveRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11786 | resolveRegion.extent.width = 1; |
11787 | resolveRegion.extent.height = 1; | ||||
11788 | resolveRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11789 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
11790 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11791 | EndCommandBuffer(); |
11792 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11793 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11794 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11795 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11796 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11797 | vkFreeMemory(m_device->device(), srcMem, NULL); |
11798 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11799 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11800 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11801 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11802 | // 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] | 11803 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
11804 | // set in aspect | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11805 | // The image format check comes 2nd in validation so we trigger it first, |
11806 | // 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] | 11807 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11808 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11809 | m_errorMonitor->SetDesiredFailureMsg( |
11810 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11811 | "Combination depth/stencil image formats can have only the "); |
11812 | |||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11813 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11814 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11815 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11816 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
11817 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11818 | |
11819 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11820 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
11821 | ds_pool_ci.pNext = NULL; | ||||
11822 | ds_pool_ci.maxSets = 1; | ||||
11823 | ds_pool_ci.poolSizeCount = 1; | ||||
11824 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11825 | |
11826 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11827 | err = |
11828 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11829 | ASSERT_VK_SUCCESS(err); |
11830 | |||||
11831 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11832 | dsl_binding.binding = 0; |
11833 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
11834 | dsl_binding.descriptorCount = 1; | ||||
11835 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
11836 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11837 | |
11838 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11839 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
11840 | ds_layout_ci.pNext = NULL; | ||||
11841 | ds_layout_ci.bindingCount = 1; | ||||
11842 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11843 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11844 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
11845 | &ds_layout); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11846 | ASSERT_VK_SUCCESS(err); |
11847 | |||||
11848 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11849 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11850 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11851 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11852 | alloc_info.descriptorPool = ds_pool; |
11853 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11854 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
11855 | &descriptorSet); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11856 | ASSERT_VK_SUCCESS(err); |
11857 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11858 | VkImage image_bad; |
11859 | VkImage image_good; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11860 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 11861 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11862 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11863 | const int32_t tex_width = 32; |
11864 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11865 | |
11866 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11867 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
11868 | image_create_info.pNext = NULL; | ||||
11869 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
11870 | image_create_info.format = tex_format_bad; | ||||
11871 | image_create_info.extent.width = tex_width; | ||||
11872 | image_create_info.extent.height = tex_height; | ||||
11873 | image_create_info.extent.depth = 1; | ||||
11874 | image_create_info.mipLevels = 1; | ||||
11875 | image_create_info.arrayLayers = 1; | ||||
11876 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
11877 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
11878 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | | ||||
11879 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; | ||||
11880 | image_create_info.flags = 0; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11881 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11882 | err = |
11883 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11884 | ASSERT_VK_SUCCESS(err); |
11885 | image_create_info.format = tex_format_good; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11886 | image_create_info.usage = |
11887 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
11888 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, | ||||
11889 | &image_good); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11890 | ASSERT_VK_SUCCESS(err); |
11891 | |||||
11892 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11893 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
11894 | image_view_create_info.image = image_bad; | ||||
11895 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
11896 | image_view_create_info.format = tex_format_bad; | ||||
11897 | image_view_create_info.subresourceRange.baseArrayLayer = 0; | ||||
11898 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
11899 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
11900 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
11901 | image_view_create_info.subresourceRange.aspectMask = | ||||
11902 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11903 | |
11904 | VkImageView view; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11905 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
11906 | &view); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11907 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11908 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11909 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11910 | vkDestroyImage(m_device->device(), image_bad, NULL); |
11911 | vkDestroyImage(m_device->device(), image_good, NULL); | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11912 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
11913 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11914 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 11915 | |
11916 | TEST_F(VkLayerTest, ClearImageErrors) { | ||||
11917 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " | ||||
11918 | "ClearDepthStencilImage with a color image."); | ||||
11919 | |||||
11920 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
11921 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11922 | |||||
11923 | // Renderpass is started here so end it as Clear cmds can't be in renderpass | ||||
11924 | BeginCommandBuffer(); | ||||
11925 | m_commandBuffer->EndRenderPass(); | ||||
11926 | |||||
11927 | // Color image | ||||
11928 | VkClearColorValue clear_color; | ||||
11929 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); | ||||
11930 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
11931 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
11932 | const int32_t img_width = 32; | ||||
11933 | const int32_t img_height = 32; | ||||
11934 | VkImageCreateInfo image_create_info = {}; | ||||
11935 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
11936 | image_create_info.pNext = NULL; | ||||
11937 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
11938 | image_create_info.format = color_format; | ||||
11939 | image_create_info.extent.width = img_width; | ||||
11940 | image_create_info.extent.height = img_height; | ||||
11941 | image_create_info.extent.depth = 1; | ||||
11942 | image_create_info.mipLevels = 1; | ||||
11943 | image_create_info.arrayLayers = 1; | ||||
11944 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
11945 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
11946 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
11947 | |||||
11948 | vk_testing::Image color_image; | ||||
11949 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, | ||||
11950 | reqs); | ||||
11951 | |||||
11952 | const VkImageSubresourceRange color_range = | ||||
11953 | vk_testing::Image::subresource_range(image_create_info, | ||||
11954 | VK_IMAGE_ASPECT_COLOR_BIT); | ||||
11955 | |||||
11956 | // Depth/Stencil image | ||||
11957 | VkClearDepthStencilValue clear_value = {0}; | ||||
11958 | reqs = 0; // don't need HOST_VISIBLE DS image | ||||
11959 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); | ||||
11960 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
11961 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
11962 | ds_image_create_info.extent.width = 64; | ||||
11963 | ds_image_create_info.extent.height = 64; | ||||
11964 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
11965 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; | ||||
11966 | |||||
11967 | vk_testing::Image ds_image; | ||||
11968 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, | ||||
11969 | reqs); | ||||
11970 | |||||
11971 | const VkImageSubresourceRange ds_range = | ||||
11972 | vk_testing::Image::subresource_range(ds_image_create_info, | ||||
11973 | VK_IMAGE_ASPECT_DEPTH_BIT); | ||||
11974 | |||||
11975 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11976 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11977 | "vkCmdClearColorImage called with depth/stencil image."); | ||||
11978 | |||||
11979 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), | ||||
11980 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, | ||||
11981 | &color_range); | ||||
11982 | |||||
11983 | m_errorMonitor->VerifyFound(); | ||||
11984 | |||||
Tony Barbour | 26434b9 | 2016-06-02 09:43:50 -0600 | [diff] [blame] | 11985 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
11986 | "vkCmdClearColorImage called with " | ||||
11987 | "image created without " | ||||
11988 | "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); | ||||
11989 | |||||
11990 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), | ||||
11991 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, | ||||
11992 | &color_range); | ||||
11993 | |||||
11994 | m_errorMonitor->VerifyFound(); | ||||
11995 | |||||
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 11996 | // Call CmdClearDepthStencilImage with color image |
11997 | m_errorMonitor->SetDesiredFailureMsg( | ||||
11998 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11999 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); | ||||
12000 | |||||
12001 | vkCmdClearDepthStencilImage( | ||||
12002 | m_commandBuffer->GetBufferHandle(), color_image.handle(), | ||||
12003 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, | ||||
12004 | &ds_range); | ||||
12005 | |||||
12006 | m_errorMonitor->VerifyFound(); | ||||
12007 | } | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 12008 | #endif // IMAGE_TESTS |
12009 | |||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12010 | int main(int argc, char **argv) { |
12011 | int result; | ||||
12012 | |||||
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 12013 | #ifdef ANDROID |
12014 | int vulkanSupport = InitVulkan(); | ||||
12015 | if (vulkanSupport == 0) | ||||
12016 | return 1; | ||||
12017 | #endif | ||||
12018 | |||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12019 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 12020 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12021 | |
12022 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); | ||||
12023 | |||||
12024 | result = RUN_ALL_TESTS(); | ||||
12025 | |||||
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 12026 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 12027 | return result; |
12028 | } |