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> | ||||
Cody Northrop | 1242dfd | 2016-07-13 17:24:59 -0600 | [diff] [blame] | 20 | * Author: Cody Northrop <cnorthrop@google.com> |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 21 | */ |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 22 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 23 | #ifdef ANDROID |
24 | #include "vulkan_wrapper.h" | ||||
25 | #else | ||||
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 26 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 27 | #endif |
Cody Northrop | 1242dfd | 2016-07-13 17:24:59 -0600 | [diff] [blame] | 28 | |
29 | #if defined(ANDROID) && defined(VALIDATION_APK) | ||||
30 | #include <android/log.h> | ||||
31 | #include <android_native_app_glue.h> | ||||
32 | #endif | ||||
33 | |||||
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 34 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 35 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 36 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 37 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 38 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 39 | #define GLM_FORCE_RADIANS |
40 | #include "glm/glm.hpp" | ||||
41 | #include <glm/gtc/matrix_transform.hpp> | ||||
42 | |||||
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 43 | #define PARAMETER_VALIDATION_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 44 | #define MEM_TRACKER_TESTS 1 |
45 | #define OBJ_TRACKER_TESTS 1 | ||||
46 | #define DRAW_STATE_TESTS 1 | ||||
47 | #define THREADING_TESTS 1 | ||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 48 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 49 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 50 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 51 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 52 | //-------------------------------------------------------------------------------------- |
53 | // Mesh and VertexFormat Data | ||||
54 | //-------------------------------------------------------------------------------------- | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 55 | struct Vertex { |
56 | float posX, posY, posZ, posW; // Position data | ||||
57 | float r, g, b, a; // Color | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 58 | }; |
59 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 60 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 61 | |
62 | typedef enum _BsoFailSelect { | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 63 | BsoFailNone = 0x00000000, |
64 | BsoFailLineWidth = 0x00000001, | ||||
65 | BsoFailDepthBias = 0x00000002, | ||||
66 | BsoFailViewport = 0x00000004, | ||||
67 | BsoFailScissor = 0x00000008, | ||||
68 | BsoFailBlend = 0x00000010, | ||||
69 | BsoFailDepthBounds = 0x00000020, | ||||
70 | BsoFailStencilReadMask = 0x00000040, | ||||
71 | BsoFailStencilWriteMask = 0x00000080, | ||||
72 | BsoFailStencilReference = 0x00000100, | ||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 73 | BsoFailCmdClearAttachments = 0x00000200, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 74 | } BsoFailSelect; |
75 | |||||
76 | struct vktriangle_vs_uniform { | ||||
77 | // Must start with MVP | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 78 | float mvp[4][4]; |
79 | float position[3][4]; | ||||
80 | float color[3][4]; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 81 | }; |
82 | |||||
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 83 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 84 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 85 | "vec2 vertices[3];\n" |
86 | "out gl_PerVertex {\n" | ||||
87 | " vec4 gl_Position;\n" | ||||
88 | "};\n" | ||||
89 | "void main() {\n" | ||||
90 | " vertices[0] = vec2(-1.0, -1.0);\n" | ||||
91 | " vertices[1] = vec2( 1.0, -1.0);\n" | ||||
92 | " vertices[2] = vec2( 0.0, 1.0);\n" | ||||
93 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" | ||||
94 | "}\n"; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 95 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 96 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 97 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 98 | "\n" |
99 | "layout(location = 0) out vec4 uFragColor;\n" | ||||
100 | "void main(){\n" | ||||
101 | " uFragColor = vec4(0,1,0,1);\n" | ||||
102 | "}\n"; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 103 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 104 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
105 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, | ||||
106 | uint64_t srcObject, size_t location, int32_t msgCode, | ||||
107 | const char *pLayerPrefix, const char *pMsg, void *pUserData); | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 108 | |
Mark Lobodzinski | 7a58845 | 2016-08-03 14:04:26 -0600 | [diff] [blame] | 109 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 110 | // ******************************************************** |
111 | // ErrorMonitor Usage: | ||||
112 | // | ||||
113 | // Call SetDesiredFailureMsg with a string to be compared against all | ||||
114 | // encountered log messages. Passing NULL will match all log messages. | ||||
115 | // logMsg will return true for skipCall only if msg is matched or NULL. | ||||
116 | // | ||||
117 | // Call DesiredMsgFound to determine if the desired failure message | ||||
118 | // was encountered. | ||||
119 | |||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 120 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 121 | public: |
122 | ErrorMonitor() { | ||||
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 123 | test_platform_thread_create_mutex(&m_mutex); |
124 | test_platform_thread_lock_mutex(&m_mutex); | ||||
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 125 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 126 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 127 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 128 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 129 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 130 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
131 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 132 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 133 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 134 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 135 | m_failureMsg.clear(); |
136 | m_otherMsgs.clear(); | ||||
137 | m_desiredMsg = msgString; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 138 | m_msgFound = VK_FALSE; |
139 | m_msgFlags = msgFlags; | ||||
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 140 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 141 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 142 | |
Mark Lobodzinski | 7a58845 | 2016-08-03 14:04:26 -0600 | [diff] [blame] | 143 | VkBool32 CheckForDesiredMsg(const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 144 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 145 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 146 | if (m_bailout != NULL) { |
147 | *m_bailout = true; | ||||
148 | } | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 149 | string errorString(msgString); |
Mark Lobodzinski | 7a58845 | 2016-08-03 14:04:26 -0600 | [diff] [blame] | 150 | if (errorString.find(m_desiredMsg) != string::npos) { |
151 | if (m_msgFound) { // If multiple matches, don't lose all but the last! | ||||
152 | m_otherMsgs.push_back(m_failureMsg); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 153 | } |
Mark Lobodzinski | 7a58845 | 2016-08-03 14:04:26 -0600 | [diff] [blame] | 154 | m_failureMsg = errorString; |
155 | m_msgFound = VK_TRUE; | ||||
156 | result = VK_TRUE; | ||||
157 | } else { | ||||
158 | m_otherMsgs.push_back(errorString); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 159 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 160 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 161 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 162 | } |
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 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 165 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 166 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 167 | |
Mark Lobodzinski | 7a58845 | 2016-08-03 14:04:26 -0600 | [diff] [blame] | 168 | VkDebugReportFlagsEXT GetMessageFlags(void) { return m_msgFlags; } |
169 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 170 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 171 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 172 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 174 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 175 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
176 | cout << "Other error messages logged for this test were:" << endl; | ||||
177 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { | ||||
178 | cout << " " << *iter << endl; | ||||
179 | } | ||||
180 | } | ||||
181 | |||||
Mark Lobodzinski | 7a58845 | 2016-08-03 14:04:26 -0600 | [diff] [blame] | 182 | // Helpers |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 183 | |
Mark Lobodzinski | 7a58845 | 2016-08-03 14:04:26 -0600 | [diff] [blame] | 184 | // ExpectSuccess now takes an optional argument allowing a custom combination of debug flags |
185 | void ExpectSuccess(VkDebugReportFlagsEXT message_flag_mask = VK_DEBUG_REPORT_ERROR_BIT_EXT) { | ||||
186 | m_msgFlags = message_flag_mask; | ||||
187 | // Match ANY message matching specified type | ||||
188 | SetDesiredFailureMsg(message_flag_mask, ""); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 189 | } |
190 | |||||
191 | void VerifyFound() { | ||||
192 | // Not seeing the desired message is a failure. /Before/ throwing, dump | ||||
193 | // any other messages. | ||||
194 | if (!DesiredMsgFound()) { | ||||
195 | DumpFailureMsgs(); | ||||
196 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; | ||||
197 | } | ||||
198 | } | ||||
199 | |||||
200 | void VerifyNotFound() { | ||||
201 | // ExpectSuccess() configured us to match anything. Any error is a | ||||
202 | // failure. | ||||
203 | if (DesiredMsgFound()) { | ||||
204 | DumpFailureMsgs(); | ||||
205 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); | ||||
206 | } | ||||
207 | } | ||||
208 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 209 | private: |
210 | VkFlags m_msgFlags; | ||||
211 | string m_desiredMsg; | ||||
212 | string m_failureMsg; | ||||
213 | vector<string> m_otherMsgs; | ||||
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 214 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 215 | bool *m_bailout; |
216 | VkBool32 m_msgFound; | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 217 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 218 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 219 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
220 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, | ||||
221 | uint64_t srcObject, size_t location, int32_t msgCode, | ||||
222 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { | ||||
Mark Lobodzinski | 7a58845 | 2016-08-03 14:04:26 -0600 | [diff] [blame] | 223 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
224 | if (msgFlags & errMonitor->GetMessageFlags()) { | ||||
225 | return errMonitor->CheckForDesiredMsg(pMsg); | ||||
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 226 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 227 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 228 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 229 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 230 | class VkLayerTest : public VkRenderFramework { |
231 | public: | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 232 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
233 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 234 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
235 | BsoFailSelect failMask); | ||||
236 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, | ||||
237 | VkPipelineObj &pipelineobj, | ||||
238 | VkDescriptorSetObj &descriptorSet, | ||||
239 | BsoFailSelect failMask); | ||||
240 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, | ||||
241 | VkDescriptorSetObj &descriptorSet, | ||||
242 | BsoFailSelect failMask) { | ||||
243 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, | ||||
244 | failMask); | ||||
245 | } | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 246 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 247 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 248 | VkResult BeginCommandBuffer() { |
249 | return BeginCommandBuffer(*m_commandBuffer); | ||||
250 | } | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 251 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 252 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
253 | uint32_t firstVertex, uint32_t firstInstance) { | ||||
254 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, | ||||
255 | firstInstance); | ||||
256 | } | ||||
257 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, | ||||
258 | uint32_t firstIndex, int32_t vertexOffset, | ||||
259 | uint32_t firstInstance) { | ||||
260 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, | ||||
261 | vertexOffset, firstInstance); | ||||
262 | } | ||||
Mark Mueller | dfe3755 | 2016-07-07 14:47:42 -0600 | [diff] [blame] | 263 | void QueueCommandBuffer(bool checkSuccess = true) { |
264 | m_commandBuffer->QueueCommandBuffer(checkSuccess); } | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 265 | void QueueCommandBuffer(const VkFence &fence) { |
266 | m_commandBuffer->QueueCommandBuffer(fence); | ||||
267 | } | ||||
268 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, | ||||
269 | VkDeviceSize offset, uint32_t binding) { | ||||
270 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); | ||||
271 | } | ||||
272 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { | ||||
273 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); | ||||
274 | } | ||||
275 | |||||
276 | protected: | ||||
277 | ErrorMonitor *m_errorMonitor; | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 278 | bool m_enableWSI; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 279 | |
280 | virtual void SetUp() { | ||||
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 281 | std::vector<const char *> instance_layer_names; |
282 | std::vector<const char *> device_layer_names; | ||||
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 283 | std::vector<const char *> instance_extension_names; |
284 | std::vector<const char *> device_extension_names; | ||||
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 285 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 286 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 287 | /* |
288 | * Since CreateDbgMsgCallback is an instance level extension call | ||||
289 | * any extension / layer that utilizes that feature also needs | ||||
290 | * to be enabled at create instance time. | ||||
291 | */ | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 292 | // Use Threading layer first to protect others from |
293 | // ThreadCommandBufferCollision test | ||||
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 294 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 295 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 296 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 297 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 298 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 299 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 300 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 301 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 302 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 303 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 304 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 305 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 306 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 307 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 308 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 309 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 310 | if (m_enableWSI) { |
311 | instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME); | ||||
312 | device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); | ||||
313 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM | ||||
314 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) | ||||
315 | instance_extension_names.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); | ||||
316 | #endif // VK_USE_PLATFORM_ANDROID_KHR | ||||
317 | #if defined(VK_USE_PLATFORM_MIR_KHR) | ||||
318 | instance_extension_names.push_back(VK_KHR_MIR_SURFACE_EXTENSION_NAME); | ||||
319 | #endif // VK_USE_PLATFORM_MIR_KHR | ||||
320 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) | ||||
321 | instance_extension_names.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); | ||||
322 | #endif // VK_USE_PLATFORM_WAYLAND_KHR | ||||
323 | #if defined(VK_USE_PLATFORM_WIN32_KHR) | ||||
324 | instance_extension_names.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); | ||||
325 | #endif // VK_USE_PLATFORM_WIN32_KHR | ||||
326 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM | ||||
327 | #if defined(VK_USE_PLATFORM_XCB_KHR) | ||||
328 | instance_extension_names.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); | ||||
329 | #elif defined(VK_USE_PLATFORM_XLIB_KHR) | ||||
330 | instance_extension_names.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); | ||||
331 | #endif // VK_USE_PLATFORM_XLIB_KHR | ||||
332 | } | ||||
333 | |||||
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 334 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 335 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 336 | this->app_info.pApplicationName = "layer_tests"; |
337 | this->app_info.applicationVersion = 1; | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 338 | this->app_info.pEngineName = "unittest"; |
339 | this->app_info.engineVersion = 1; | ||||
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 340 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 341 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 342 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 343 | InitFramework(instance_layer_names, device_layer_names, |
344 | instance_extension_names, device_extension_names, | ||||
345 | myDbgFunc, m_errorMonitor); | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 346 | } |
347 | |||||
348 | virtual void TearDown() { | ||||
349 | // Clean up resources before we reset | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 350 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 351 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 352 | } |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 353 | |
354 | VkLayerTest() { | ||||
355 | m_enableWSI = false; | ||||
356 | } | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 357 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 358 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 359 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 360 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 361 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 362 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 363 | |
364 | /* | ||||
365 | * For render test all drawing happens in a single render pass | ||||
366 | * on a single command buffer. | ||||
367 | */ | ||||
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 368 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 369 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 370 | } |
371 | |||||
372 | return result; | ||||
373 | } | ||||
374 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 375 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 376 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 377 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 378 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 379 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 380 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 381 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 382 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 383 | |
384 | return result; | ||||
385 | } | ||||
386 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 387 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
388 | const char *fragShaderText, | ||||
389 | BsoFailSelect failMask) { | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 390 | // Create identity matrix |
391 | int i; | ||||
392 | struct vktriangle_vs_uniform data; | ||||
393 | |||||
394 | glm::mat4 Projection = glm::mat4(1.0f); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 395 | glm::mat4 View = glm::mat4(1.0f); |
396 | glm::mat4 Model = glm::mat4(1.0f); | ||||
397 | glm::mat4 MVP = Projection * View * Model; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 398 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 399 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 400 | |
401 | memcpy(&data.mvp, &MVP[0][0], matrixSize); | ||||
402 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 403 | static const Vertex tri_data[] = { |
404 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, | ||||
405 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, | ||||
406 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 407 | }; |
408 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 409 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 410 | data.position[i][0] = tri_data[i].posX; |
411 | data.position[i][1] = tri_data[i].posY; | ||||
412 | data.position[i][2] = tri_data[i].posZ; | ||||
413 | data.position[i][3] = tri_data[i].posW; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 414 | data.color[i][0] = tri_data[i].r; |
415 | data.color[i][1] = tri_data[i].g; | ||||
416 | data.color[i][2] = tri_data[i].b; | ||||
417 | data.color[i][3] = tri_data[i].a; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 418 | } |
419 | |||||
420 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
421 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
422 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 423 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
424 | (const void *)&data); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 425 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 426 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
427 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
428 | this); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 429 | |
430 | VkPipelineObj pipelineobj(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 431 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 432 | pipelineobj.AddShader(&vs); |
433 | pipelineobj.AddShader(&ps); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 434 | if (failMask & BsoFailLineWidth) { |
435 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 436 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
437 | ia_state.sType = | ||||
438 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
439 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; | ||||
440 | pipelineobj.SetInputAssembly(&ia_state); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 441 | } |
442 | if (failMask & BsoFailDepthBias) { | ||||
443 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 444 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
445 | rs_state.sType = | ||||
446 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
447 | rs_state.depthBiasEnable = VK_TRUE; | ||||
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 448 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 449 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 450 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 451 | // Viewport and scissors must stay in synch or other errors will occur than |
452 | // the ones we want | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 453 | if (failMask & BsoFailViewport) { |
454 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 455 | m_viewports.clear(); |
456 | m_scissors.clear(); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 457 | } |
458 | if (failMask & BsoFailScissor) { | ||||
459 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 460 | m_scissors.clear(); |
461 | m_viewports.clear(); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 462 | } |
463 | if (failMask & BsoFailBlend) { | ||||
464 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 465 | VkPipelineColorBlendAttachmentState att_state = {}; |
466 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; | ||||
467 | att_state.blendEnable = VK_TRUE; | ||||
468 | pipelineobj.AddColorAttachment(0, &att_state); | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 469 | } |
470 | if (failMask & BsoFailDepthBounds) { | ||||
471 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); | ||||
472 | } | ||||
473 | if (failMask & BsoFailStencilReadMask) { | ||||
474 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); | ||||
475 | } | ||||
476 | if (failMask & BsoFailStencilWriteMask) { | ||||
477 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); | ||||
478 | } | ||||
479 | if (failMask & BsoFailStencilReference) { | ||||
480 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); | ||||
481 | } | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 482 | |
483 | VkDescriptorSetObj descriptorSet(m_device); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 484 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
485 | constantBuffer); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 486 | |
487 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 488 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 489 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 490 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 491 | |
492 | // render triangle | ||||
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 493 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 494 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 495 | if (failMask & BsoFailCmdClearAttachments) { |
496 | VkClearAttachment color_attachment = {}; | ||||
497 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
498 | color_attachment.colorAttachment = 1; // Someone who knew what they were doing would use 0 for the index; | ||||
499 | VkClearRect clear_rect = {{{0, 0}, {static_cast<uint32_t>(m_width), static_cast<uint32_t>(m_height)}}, 0, 0}; | ||||
500 | |||||
501 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, | ||||
502 | &color_attachment, 1, &clear_rect); | ||||
503 | } | ||||
504 | |||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 505 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 506 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 507 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 508 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 509 | } |
510 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 511 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
512 | VkPipelineObj &pipelineobj, | ||||
513 | VkDescriptorSetObj &descriptorSet, | ||||
514 | BsoFailSelect failMask) { | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 515 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 516 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
517 | m_stencil_clear_color, m_depthStencil); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 518 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 519 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
520 | m_stencil_clear_color, NULL); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 521 | } |
522 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 523 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 524 | // Make sure depthWriteEnable is set so that Depth fail test will work |
525 | // correctly | ||||
526 | // Make sure stencilTestEnable is set so that Stencil fail test will work | ||||
527 | // correctly | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 528 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 529 | stencil.failOp = VK_STENCIL_OP_KEEP; |
530 | stencil.passOp = VK_STENCIL_OP_KEEP; | ||||
531 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; | ||||
532 | stencil.compareOp = VK_COMPARE_OP_NEVER; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 533 | |
534 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; | ||||
535 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; | ||||
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 536 | ds_ci.pNext = NULL; |
537 | ds_ci.depthTestEnable = VK_FALSE; | ||||
538 | ds_ci.depthWriteEnable = VK_TRUE; | ||||
539 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; | ||||
540 | ds_ci.depthBoundsTestEnable = VK_FALSE; | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 541 | if (failMask & BsoFailDepthBounds) { |
542 | ds_ci.depthBoundsTestEnable = VK_TRUE; | ||||
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 543 | ds_ci.maxDepthBounds = 0.0f; |
544 | ds_ci.minDepthBounds = 0.0f; | ||||
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 545 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 546 | ds_ci.stencilTestEnable = VK_TRUE; |
547 | ds_ci.front = stencil; | ||||
548 | ds_ci.back = stencil; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 549 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 550 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 551 | pipelineobj.SetViewport(m_viewports); |
552 | pipelineobj.SetScissor(m_scissors); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 553 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 554 | VkResult err = pipelineobj.CreateVKPipeline( |
555 | descriptorSet.GetPipelineLayout(), renderPass()); | ||||
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 556 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 557 | commandBuffer->BindPipeline(pipelineobj); |
558 | commandBuffer->BindDescriptorSet(descriptorSet); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 559 | } |
560 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 561 | class VkWsiEnabledLayerTest : public VkLayerTest { |
562 | public: | ||||
563 | protected: | ||||
564 | VkWsiEnabledLayerTest() { | ||||
565 | m_enableWSI = true; | ||||
566 | } | ||||
567 | }; | ||||
568 | |||||
Mark Mueller | dfe3755 | 2016-07-07 14:47:42 -0600 | [diff] [blame] | 569 | class VkBufferTest { |
570 | public: | ||||
571 | enum eTestEnFlags { | ||||
572 | eDoubleDelete, | ||||
573 | eInvalidDeviceOffset, | ||||
574 | eInvalidMemoryOffset, | ||||
575 | eBindNullBuffer, | ||||
576 | eFreeInvalidHandle, | ||||
577 | }; | ||||
578 | |||||
579 | enum eTestConditions { | ||||
580 | eOffsetAlignment = 1 | ||||
581 | }; | ||||
582 | |||||
583 | static bool GetTestConditionValid(VkDeviceObj *aVulkanDevice, | ||||
584 | eTestEnFlags aTestFlag, | ||||
585 | VkBufferUsageFlags aBufferUsage = 0) { | ||||
586 | if (eInvalidDeviceOffset != aTestFlag && | ||||
587 | eInvalidMemoryOffset != aTestFlag) { | ||||
588 | return true; | ||||
589 | } | ||||
590 | VkDeviceSize offset_limit = 0; | ||||
591 | if (eInvalidMemoryOffset == aTestFlag) { | ||||
592 | VkBuffer vulkanBuffer; | ||||
593 | VkBufferCreateInfo buffer_create_info = {}; | ||||
594 | buffer_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
595 | buffer_create_info.size = 32; | ||||
596 | buffer_create_info.usage = aBufferUsage; | ||||
597 | |||||
598 | vkCreateBuffer(aVulkanDevice->device(), &buffer_create_info, nullptr, | ||||
599 | &vulkanBuffer); | ||||
600 | VkMemoryRequirements memory_reqs = {0}; | ||||
601 | |||||
602 | vkGetBufferMemoryRequirements(aVulkanDevice->device(), | ||||
603 | vulkanBuffer, &memory_reqs); | ||||
604 | vkDestroyBuffer(aVulkanDevice->device(), vulkanBuffer, nullptr); | ||||
605 | offset_limit = memory_reqs.alignment; | ||||
606 | } | ||||
607 | else if ((VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | | ||||
608 | VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT) & aBufferUsage) { | ||||
609 | offset_limit = | ||||
610 | aVulkanDevice->props.limits.minTexelBufferOffsetAlignment; | ||||
611 | } else if (VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT & aBufferUsage) { | ||||
612 | offset_limit = | ||||
613 | aVulkanDevice->props.limits.minUniformBufferOffsetAlignment; | ||||
614 | } else if (VK_BUFFER_USAGE_STORAGE_BUFFER_BIT & aBufferUsage) { | ||||
615 | offset_limit = | ||||
616 | aVulkanDevice->props.limits.minStorageBufferOffsetAlignment; | ||||
617 | } | ||||
618 | if (eOffsetAlignment < offset_limit) { | ||||
619 | return true; | ||||
620 | } | ||||
621 | return false; | ||||
622 | } | ||||
623 | |||||
624 | // A constructor which performs validation tests within construction. | ||||
625 | VkBufferTest(VkDeviceObj *aVulkanDevice, | ||||
626 | VkBufferUsageFlags aBufferUsage, | ||||
627 | eTestEnFlags aTestFlag) | ||||
628 | : AllocateCurrent(false), BoundCurrent(false), | ||||
629 | CreateCurrent(false), VulkanDevice(aVulkanDevice->device()) { | ||||
630 | |||||
631 | if (eBindNullBuffer == aTestFlag) { | ||||
632 | VulkanMemory = 0; | ||||
633 | vkBindBufferMemory(VulkanDevice, VulkanBuffer, VulkanMemory, 0); | ||||
634 | } else { | ||||
635 | VkBufferCreateInfo buffer_create_info = {}; | ||||
636 | buffer_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
637 | buffer_create_info.size = 32; | ||||
638 | buffer_create_info.usage = aBufferUsage; | ||||
639 | |||||
640 | vkCreateBuffer(VulkanDevice, &buffer_create_info, nullptr, | ||||
641 | &VulkanBuffer); | ||||
642 | |||||
643 | CreateCurrent = true; | ||||
644 | |||||
645 | VkMemoryRequirements memory_requirements; | ||||
646 | vkGetBufferMemoryRequirements(VulkanDevice, VulkanBuffer, | ||||
647 | &memory_requirements); | ||||
648 | |||||
649 | VkMemoryAllocateInfo memory_allocate_info = {}; | ||||
650 | memory_allocate_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
651 | memory_allocate_info.allocationSize = memory_requirements.size; | ||||
652 | bool pass = aVulkanDevice->phy(). | ||||
653 | set_memory_type(memory_requirements.memoryTypeBits, | ||||
654 | &memory_allocate_info, | ||||
655 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
656 | if (!pass) { | ||||
657 | vkDestroyBuffer(VulkanDevice, VulkanBuffer, nullptr); | ||||
658 | return; | ||||
659 | } | ||||
660 | |||||
661 | vkAllocateMemory(VulkanDevice, &memory_allocate_info, NULL, | ||||
662 | &VulkanMemory); | ||||
663 | AllocateCurrent = true; | ||||
664 | // NB: 1 is intentionally an invalid offset value | ||||
665 | const bool offset_en = eInvalidDeviceOffset == aTestFlag || | ||||
666 | eInvalidMemoryOffset == aTestFlag; | ||||
667 | vkBindBufferMemory(VulkanDevice, VulkanBuffer, VulkanMemory, | ||||
668 | offset_en ? eOffsetAlignment : 0); | ||||
669 | BoundCurrent = true; | ||||
670 | |||||
671 | InvalidDeleteEn = (eFreeInvalidHandle == aTestFlag); | ||||
672 | } | ||||
673 | } | ||||
674 | |||||
675 | ~VkBufferTest() { | ||||
676 | if (CreateCurrent) { | ||||
677 | vkDestroyBuffer(VulkanDevice, VulkanBuffer, nullptr); | ||||
678 | } | ||||
679 | if (AllocateCurrent) { | ||||
680 | if (InvalidDeleteEn) { | ||||
681 | union { | ||||
682 | VkDeviceMemory device_memory; | ||||
683 | unsigned long long index_access; | ||||
684 | } bad_index; | ||||
685 | |||||
686 | bad_index.device_memory = VulkanMemory; | ||||
687 | bad_index.index_access++; | ||||
688 | |||||
689 | vkFreeMemory(VulkanDevice, | ||||
690 | bad_index.device_memory, | ||||
691 | nullptr); | ||||
692 | } | ||||
693 | vkFreeMemory(VulkanDevice, VulkanMemory, nullptr); | ||||
694 | } | ||||
695 | } | ||||
696 | |||||
697 | bool GetBufferCurrent() { | ||||
698 | return AllocateCurrent && BoundCurrent && CreateCurrent; | ||||
699 | } | ||||
700 | |||||
701 | const VkBuffer &GetBuffer() { | ||||
702 | return VulkanBuffer; | ||||
703 | } | ||||
704 | |||||
705 | void TestDoubleDestroy() { | ||||
706 | // Destroy the buffer but leave the flag set, which will cause | ||||
707 | // the buffer to be destroyed again in the destructor. | ||||
708 | vkDestroyBuffer(VulkanDevice, VulkanBuffer, nullptr); | ||||
709 | } | ||||
710 | |||||
711 | protected: | ||||
712 | bool AllocateCurrent; | ||||
713 | bool BoundCurrent; | ||||
714 | bool CreateCurrent; | ||||
715 | bool InvalidDeleteEn; | ||||
716 | |||||
717 | VkBuffer VulkanBuffer; | ||||
718 | VkDevice VulkanDevice; | ||||
719 | VkDeviceMemory VulkanMemory; | ||||
720 | |||||
721 | }; | ||||
722 | |||||
723 | class VkVerticesObj { | ||||
724 | public: | ||||
725 | VkVerticesObj(VkDeviceObj *aVulkanDevice, unsigned aAttributeCount, | ||||
726 | unsigned aBindingCount, unsigned aByteStride, | ||||
727 | VkDeviceSize aVertexCount, const float *aVerticies) | ||||
728 | : BoundCurrent(false), | ||||
729 | AttributeCount(aAttributeCount), | ||||
730 | BindingCount(aBindingCount), | ||||
731 | BindId(BindIdGenerator), | ||||
732 | PipelineVertexInputStateCreateInfo(), | ||||
733 | VulkanMemoryBuffer(aVulkanDevice, 1, | ||||
734 | static_cast<int>(aByteStride * aVertexCount), | ||||
735 | reinterpret_cast<const void *>(aVerticies), | ||||
736 | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT) { | ||||
737 | BindIdGenerator++; // NB: This can wrap w/misuse | ||||
738 | |||||
739 | VertexInputAttributeDescription = | ||||
740 | new VkVertexInputAttributeDescription[AttributeCount]; | ||||
741 | VertexInputBindingDescription = | ||||
742 | new VkVertexInputBindingDescription[BindingCount]; | ||||
743 | |||||
744 | PipelineVertexInputStateCreateInfo.pVertexAttributeDescriptions = | ||||
745 | VertexInputAttributeDescription; | ||||
746 | PipelineVertexInputStateCreateInfo.vertexAttributeDescriptionCount = | ||||
747 | AttributeCount; | ||||
748 | PipelineVertexInputStateCreateInfo.pVertexBindingDescriptions = | ||||
749 | VertexInputBindingDescription; | ||||
750 | PipelineVertexInputStateCreateInfo.vertexBindingDescriptionCount = | ||||
751 | BindingCount; | ||||
752 | PipelineVertexInputStateCreateInfo.sType = | ||||
753 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; | ||||
754 | |||||
755 | unsigned i = 0; | ||||
756 | do { | ||||
757 | VertexInputAttributeDescription[i].binding = BindId; | ||||
758 | VertexInputAttributeDescription[i].location = i; | ||||
759 | VertexInputAttributeDescription[i].format = | ||||
760 | VK_FORMAT_R32G32B32_SFLOAT; | ||||
761 | VertexInputAttributeDescription[i].offset = | ||||
762 | sizeof(float) * aByteStride; | ||||
763 | i++; | ||||
764 | } while (AttributeCount < i); | ||||
765 | |||||
766 | i = 0; | ||||
767 | do { | ||||
768 | VertexInputBindingDescription[i].binding = BindId; | ||||
769 | VertexInputBindingDescription[i].stride = aByteStride; | ||||
770 | VertexInputBindingDescription[i].inputRate = | ||||
771 | VK_VERTEX_INPUT_RATE_VERTEX; | ||||
772 | i++; | ||||
773 | } while (BindingCount < i); | ||||
774 | } | ||||
775 | |||||
776 | ~VkVerticesObj() { | ||||
777 | if (VertexInputAttributeDescription) { | ||||
778 | delete[] VertexInputAttributeDescription; | ||||
779 | } | ||||
780 | if (VertexInputBindingDescription) { | ||||
781 | delete[] VertexInputBindingDescription; | ||||
782 | } | ||||
783 | } | ||||
784 | |||||
785 | bool AddVertexInputToPipe(VkPipelineObj &aPipelineObj) { | ||||
786 | aPipelineObj.AddVertexInputAttribs(VertexInputAttributeDescription, | ||||
787 | AttributeCount); | ||||
788 | aPipelineObj.AddVertexInputBindings(VertexInputBindingDescription, | ||||
789 | BindingCount); | ||||
790 | return true; | ||||
791 | } | ||||
792 | |||||
793 | void BindVertexBuffers(VkCommandBuffer aCommandBuffer, | ||||
794 | unsigned aOffsetCount = 0, | ||||
795 | VkDeviceSize *aOffsetList = nullptr) { | ||||
796 | VkDeviceSize *offsetList; | ||||
797 | unsigned offsetCount; | ||||
798 | |||||
799 | if (aOffsetCount) { | ||||
800 | offsetList = aOffsetList; | ||||
801 | offsetCount = aOffsetCount; | ||||
802 | } else { | ||||
803 | offsetList = new VkDeviceSize[1](); | ||||
804 | offsetCount = 1; | ||||
805 | } | ||||
806 | |||||
807 | vkCmdBindVertexBuffers(aCommandBuffer, BindId, offsetCount, | ||||
808 | &VulkanMemoryBuffer.handle(), offsetList); | ||||
809 | BoundCurrent = true; | ||||
810 | |||||
811 | if (!aOffsetCount) { | ||||
812 | delete [] offsetList; | ||||
813 | } | ||||
814 | } | ||||
815 | |||||
816 | protected: | ||||
817 | static uint32_t BindIdGenerator; | ||||
818 | |||||
819 | bool BoundCurrent; | ||||
820 | unsigned AttributeCount; | ||||
821 | unsigned BindingCount; | ||||
822 | uint32_t BindId; | ||||
823 | |||||
824 | VkPipelineVertexInputStateCreateInfo PipelineVertexInputStateCreateInfo; | ||||
825 | VkVertexInputAttributeDescription *VertexInputAttributeDescription; | ||||
826 | VkVertexInputBindingDescription *VertexInputBindingDescription; | ||||
827 | VkConstantBufferObj VulkanMemoryBuffer; | ||||
828 | }; | ||||
829 | |||||
830 | uint32_t VkVerticesObj::BindIdGenerator; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 831 | // ******************************************************************************************************************** |
832 | // ******************************************************************************************************************** | ||||
833 | // ******************************************************************************************************************** | ||||
834 | // ******************************************************************************************************************** | ||||
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 835 | #if PARAMETER_VALIDATION_TESTS |
836 | TEST_F(VkLayerTest, RequiredParameter) { | ||||
837 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " | ||||
838 | "pointer, array, and array count parameters"); | ||||
839 | |||||
840 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
841 | |||||
842 | m_errorMonitor->SetDesiredFailureMsg( | ||||
843 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
844 | "required parameter pFeatures specified as NULL"); | ||||
845 | // Specify NULL for a pointer to a handle | ||||
846 | // Expected to trigger an error with | ||||
847 | // parameter_validation::validate_required_pointer | ||||
848 | vkGetPhysicalDeviceFeatures(gpu(), NULL); | ||||
849 | m_errorMonitor->VerifyFound(); | ||||
850 | |||||
851 | m_errorMonitor->SetDesiredFailureMsg( | ||||
852 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 853 | "required parameter pQueueFamilyPropertyCount specified as NULL"); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 854 | // Specify NULL for pointer to array count |
855 | // Expected to trigger an error with parameter_validation::validate_array | ||||
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 856 | vkGetPhysicalDeviceQueueFamilyProperties(gpu(), NULL, NULL); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 857 | m_errorMonitor->VerifyFound(); |
858 | |||||
859 | m_errorMonitor->SetDesiredFailureMsg( | ||||
860 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
861 | "parameter viewportCount must be greater than 0"); | ||||
862 | // Specify 0 for a required array count | ||||
863 | // Expected to trigger an error with parameter_validation::validate_array | ||||
864 | VkViewport view_port = {}; | ||||
865 | m_commandBuffer->SetViewport(0, 0, &view_port); | ||||
866 | m_errorMonitor->VerifyFound(); | ||||
867 | |||||
868 | m_errorMonitor->SetDesiredFailureMsg( | ||||
869 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
870 | "required parameter pViewports specified as NULL"); | ||||
871 | // Specify NULL for a required array | ||||
872 | // Expected to trigger an error with parameter_validation::validate_array | ||||
873 | m_commandBuffer->SetViewport(0, 1, NULL); | ||||
874 | m_errorMonitor->VerifyFound(); | ||||
875 | |||||
876 | m_errorMonitor->SetDesiredFailureMsg( | ||||
877 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
878 | "required parameter memory specified as VK_NULL_HANDLE"); | ||||
879 | // Specify VK_NULL_HANDLE for a required handle | ||||
880 | // Expected to trigger an error with | ||||
881 | // parameter_validation::validate_required_handle | ||||
882 | vkUnmapMemory(device(), VK_NULL_HANDLE); | ||||
883 | m_errorMonitor->VerifyFound(); | ||||
884 | |||||
885 | m_errorMonitor->SetDesiredFailureMsg( | ||||
886 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
887 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); | ||||
888 | // Specify VK_NULL_HANDLE for a required handle array entry | ||||
889 | // Expected to trigger an error with | ||||
890 | // parameter_validation::validate_required_handle_array | ||||
891 | VkFence fence = VK_NULL_HANDLE; | ||||
892 | vkResetFences(device(), 1, &fence); | ||||
893 | m_errorMonitor->VerifyFound(); | ||||
894 | |||||
895 | m_errorMonitor->SetDesiredFailureMsg( | ||||
896 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
897 | "required parameter pAllocateInfo specified as NULL"); | ||||
898 | // Specify NULL for a required struct pointer | ||||
899 | // Expected to trigger an error with | ||||
900 | // parameter_validation::validate_struct_type | ||||
901 | VkDeviceMemory memory = VK_NULL_HANDLE; | ||||
902 | vkAllocateMemory(device(), NULL, NULL, &memory); | ||||
903 | m_errorMonitor->VerifyFound(); | ||||
904 | |||||
905 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
906 | "value of faceMask must not be 0"); | ||||
907 | // Specify 0 for a required VkFlags parameter | ||||
908 | // Expected to trigger an error with parameter_validation::validate_flags | ||||
909 | m_commandBuffer->SetStencilReference(0, 0); | ||||
910 | m_errorMonitor->VerifyFound(); | ||||
911 | |||||
912 | m_errorMonitor->SetDesiredFailureMsg( | ||||
913 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
914 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); | ||||
915 | // Specify 0 for a required VkFlags array entry | ||||
916 | // Expected to trigger an error with | ||||
917 | // parameter_validation::validate_flags_array | ||||
918 | VkSemaphore semaphore = VK_NULL_HANDLE; | ||||
919 | VkPipelineStageFlags stageFlags = 0; | ||||
920 | VkSubmitInfo submitInfo = {}; | ||||
921 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
922 | submitInfo.waitSemaphoreCount = 1; | ||||
923 | submitInfo.pWaitSemaphores = &semaphore; | ||||
924 | submitInfo.pWaitDstStageMask = &stageFlags; | ||||
925 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); | ||||
926 | m_errorMonitor->VerifyFound(); | ||||
927 | } | ||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 928 | |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 929 | TEST_F(VkLayerTest, ReservedParameter) { |
930 | TEST_DESCRIPTION("Specify a non-zero value for a reserved parameter"); | ||||
931 | |||||
932 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
933 | |||||
934 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
935 | " must be 0"); | ||||
936 | // Specify 0 for a reserved VkFlags parameter | ||||
937 | // Expected to trigger an error with | ||||
938 | // parameter_validation::validate_reserved_flags | ||||
939 | VkEvent event_handle = VK_NULL_HANDLE; | ||||
940 | VkEventCreateInfo event_info = {}; | ||||
941 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
942 | event_info.flags = 1; | ||||
943 | vkCreateEvent(device(), &event_info, NULL, &event_handle); | ||||
944 | m_errorMonitor->VerifyFound(); | ||||
945 | } | ||||
946 | |||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 947 | TEST_F(VkLayerTest, InvalidStructSType) { |
948 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " | ||||
949 | "structure's sType field"); | ||||
950 | |||||
951 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
952 | |||||
953 | m_errorMonitor->SetDesiredFailureMsg( | ||||
954 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
955 | "parameter pAllocateInfo->sType must be"); | ||||
956 | // Zero struct memory, effectively setting sType to | ||||
957 | // VK_STRUCTURE_TYPE_APPLICATION_INFO | ||||
958 | // Expected to trigger an error with | ||||
959 | // parameter_validation::validate_struct_type | ||||
960 | VkMemoryAllocateInfo alloc_info = {}; | ||||
961 | VkDeviceMemory memory = VK_NULL_HANDLE; | ||||
962 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); | ||||
963 | m_errorMonitor->VerifyFound(); | ||||
964 | |||||
965 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
966 | "parameter pSubmits[0].sType must be"); | ||||
967 | // Zero struct memory, effectively setting sType to | ||||
968 | // VK_STRUCTURE_TYPE_APPLICATION_INFO | ||||
969 | // Expected to trigger an error with | ||||
970 | // parameter_validation::validate_struct_type_array | ||||
971 | VkSubmitInfo submit_info = {}; | ||||
972 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
973 | m_errorMonitor->VerifyFound(); | ||||
974 | } | ||||
975 | |||||
976 | TEST_F(VkLayerTest, InvalidStructPNext) { | ||||
977 | TEST_DESCRIPTION( | ||||
978 | "Specify an invalid value for a Vulkan structure's pNext field"); | ||||
979 | |||||
980 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
981 | |||||
982 | m_errorMonitor->SetDesiredFailureMsg( | ||||
Dustin Graves | af5c029 | 2016-07-19 13:43:53 -0600 | [diff] [blame] | 983 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 38b5099 | 2016-07-11 16:09:09 -0600 | [diff] [blame] | 984 | "value of pCreateInfo->pNext must be NULL"); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 985 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be |
Karl Schultz | 38b5099 | 2016-07-11 16:09:09 -0600 | [diff] [blame] | 986 | // NULL. |
987 | // Need to pick a function that has no allowed pNext structure types. | ||||
988 | // Expected to trigger an error with | ||||
989 | // parameter_validation::validate_struct_pnext | ||||
990 | VkEvent event = VK_NULL_HANDLE; | ||||
Karl Schultz | 70db390 | 2016-07-11 16:22:10 -0600 | [diff] [blame] | 991 | VkEventCreateInfo event_alloc_info = {}; |
Karl Schultz | 38b5099 | 2016-07-11 16:09:09 -0600 | [diff] [blame] | 992 | // Zero-initialization will provide the correct sType |
993 | VkApplicationInfo app_info = {}; | ||||
994 | event_alloc_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
995 | event_alloc_info.pNext = &app_info; | ||||
996 | vkCreateEvent(device(), &event_alloc_info, NULL, &event); | ||||
997 | m_errorMonitor->VerifyFound(); | ||||
998 | |||||
999 | m_errorMonitor->SetDesiredFailureMsg( | ||||
Dustin Graves | af5c029 | 2016-07-19 13:43:53 -0600 | [diff] [blame] | 1000 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 38b5099 | 2016-07-11 16:09:09 -0600 | [diff] [blame] | 1001 | " chain includes a structure with unexpected VkStructureType "); |
1002 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, but use | ||||
1003 | // a function that has allowed pNext structure types and specify | ||||
1004 | // a structure type that is not allowed. | ||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 1005 | // Expected to trigger an error with |
1006 | // parameter_validation::validate_struct_pnext | ||||
1007 | VkDeviceMemory memory = VK_NULL_HANDLE; | ||||
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 1008 | VkMemoryAllocateInfo memory_alloc_info = {}; |
1009 | memory_alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1010 | memory_alloc_info.pNext = &app_info; | ||||
1011 | vkAllocateMemory(device(), &memory_alloc_info, NULL, &memory); | ||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 1012 | m_errorMonitor->VerifyFound(); |
1013 | |||||
Dustin Graves | fd1c8fe | 2016-07-15 11:40:20 -0600 | [diff] [blame] | 1014 | // Positive test to check parameter_validation and unique_objects support |
1015 | // for NV_dedicated_allocation | ||||
1016 | uint32_t extension_count = 0; | ||||
1017 | bool supports_nv_dedicated_allocation = false; | ||||
Dustin Graves | e34a617 | 2016-07-20 13:41:21 -0600 | [diff] [blame] | 1018 | VkResult err = vkEnumerateDeviceExtensionProperties( |
1019 | gpu(), nullptr, &extension_count, nullptr); | ||||
Dustin Graves | fd1c8fe | 2016-07-15 11:40:20 -0600 | [diff] [blame] | 1020 | ASSERT_VK_SUCCESS(err); |
1021 | |||||
1022 | if (extension_count > 0) { | ||||
1023 | std::vector<VkExtensionProperties> available_extensions( | ||||
1024 | extension_count); | ||||
1025 | |||||
1026 | err = vkEnumerateDeviceExtensionProperties( | ||||
1027 | gpu(), nullptr, &extension_count, &available_extensions[0]); | ||||
1028 | ASSERT_VK_SUCCESS(err); | ||||
1029 | |||||
1030 | for (const auto &extension_props : available_extensions) { | ||||
1031 | if (strcmp(extension_props.extensionName, | ||||
1032 | VK_NV_DEDICATED_ALLOCATION_EXTENSION_NAME) == 0) { | ||||
1033 | supports_nv_dedicated_allocation = true; | ||||
1034 | } | ||||
1035 | } | ||||
1036 | } | ||||
1037 | |||||
1038 | if (supports_nv_dedicated_allocation) { | ||||
1039 | m_errorMonitor->ExpectSuccess(); | ||||
1040 | |||||
1041 | VkDedicatedAllocationBufferCreateInfoNV dedicated_buffer_create_info = | ||||
1042 | {}; | ||||
1043 | dedicated_buffer_create_info.sType = | ||||
1044 | VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV; | ||||
1045 | dedicated_buffer_create_info.pNext = nullptr; | ||||
1046 | dedicated_buffer_create_info.dedicatedAllocation = VK_TRUE; | ||||
1047 | |||||
1048 | uint32_t queue_family_index = 0; | ||||
1049 | VkBufferCreateInfo buffer_create_info = {}; | ||||
1050 | buffer_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
1051 | buffer_create_info.pNext = &dedicated_buffer_create_info; | ||||
1052 | buffer_create_info.size = 1024; | ||||
1053 | buffer_create_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
1054 | buffer_create_info.queueFamilyIndexCount = 1; | ||||
1055 | buffer_create_info.pQueueFamilyIndices = &queue_family_index; | ||||
1056 | |||||
1057 | VkBuffer buffer; | ||||
1058 | VkResult err = vkCreateBuffer(m_device->device(), &buffer_create_info, | ||||
1059 | NULL, &buffer); | ||||
1060 | ASSERT_VK_SUCCESS(err); | ||||
1061 | |||||
1062 | VkMemoryRequirements memory_reqs; | ||||
1063 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memory_reqs); | ||||
1064 | |||||
1065 | VkDedicatedAllocationMemoryAllocateInfoNV dedicated_memory_info = {}; | ||||
1066 | dedicated_memory_info.sType = | ||||
1067 | VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV; | ||||
1068 | dedicated_memory_info.pNext = nullptr; | ||||
1069 | dedicated_memory_info.buffer = buffer; | ||||
1070 | dedicated_memory_info.image = VK_NULL_HANDLE; | ||||
1071 | |||||
1072 | VkMemoryAllocateInfo memory_info = {}; | ||||
1073 | memory_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1074 | memory_info.pNext = &dedicated_memory_info; | ||||
1075 | memory_info.allocationSize = memory_reqs.size; | ||||
1076 | |||||
1077 | bool pass; | ||||
1078 | pass = m_device->phy().set_memory_type(memory_reqs.memoryTypeBits, | ||||
1079 | &memory_info, 0); | ||||
1080 | ASSERT_TRUE(pass); | ||||
1081 | |||||
1082 | VkDeviceMemory buffer_memory; | ||||
1083 | err = vkAllocateMemory(m_device->device(), &memory_info, NULL, | ||||
1084 | &buffer_memory); | ||||
1085 | ASSERT_VK_SUCCESS(err); | ||||
1086 | |||||
1087 | err = vkBindBufferMemory(m_device->device(), buffer, buffer_memory, 0); | ||||
1088 | ASSERT_VK_SUCCESS(err); | ||||
1089 | |||||
1090 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1091 | vkFreeMemory(m_device->device(), buffer_memory, NULL); | ||||
1092 | |||||
1093 | m_errorMonitor->VerifyNotFound(); | ||||
1094 | } | ||||
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 1095 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame] | 1096 | |
1097 | TEST_F(VkLayerTest, UnrecognizedValue) { | ||||
1098 | TEST_DESCRIPTION( | ||||
1099 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); | ||||
1100 | |||||
1101 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1102 | |||||
1103 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1104 | "does not fall within the begin..end " | ||||
1105 | "range of the core VkFormat " | ||||
1106 | "enumeration tokens"); | ||||
1107 | // Specify an invalid VkFormat value | ||||
1108 | // Expected to trigger an error with | ||||
1109 | // parameter_validation::validate_ranged_enum | ||||
1110 | VkFormatProperties format_properties; | ||||
1111 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), | ||||
1112 | &format_properties); | ||||
1113 | m_errorMonitor->VerifyFound(); | ||||
1114 | |||||
1115 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1116 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1117 | "contains flag bits that are not recognized members of"); | ||||
1118 | // Specify an invalid VkFlags bitmask value | ||||
1119 | // Expected to trigger an error with parameter_validation::validate_flags | ||||
1120 | VkImageFormatProperties image_format_properties; | ||||
1121 | vkGetPhysicalDeviceImageFormatProperties( | ||||
1122 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, | ||||
1123 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, | ||||
1124 | &image_format_properties); | ||||
1125 | m_errorMonitor->VerifyFound(); | ||||
1126 | |||||
1127 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1128 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1129 | "contains flag bits that are not recognized members of"); | ||||
1130 | // Specify an invalid VkFlags array entry | ||||
1131 | // Expected to trigger an error with | ||||
1132 | // parameter_validation::validate_flags_array | ||||
1133 | VkSemaphore semaphore = VK_NULL_HANDLE; | ||||
1134 | VkPipelineStageFlags stage_flags = | ||||
1135 | static_cast<VkPipelineStageFlags>(1 << 25); | ||||
1136 | VkSubmitInfo submit_info = {}; | ||||
1137 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
1138 | submit_info.waitSemaphoreCount = 1; | ||||
1139 | submit_info.pWaitSemaphores = &semaphore; | ||||
1140 | submit_info.pWaitDstStageMask = &stage_flags; | ||||
1141 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
1142 | m_errorMonitor->VerifyFound(); | ||||
1143 | |||||
1144 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, | ||||
1145 | "is neither VK_TRUE nor VK_FALSE"); | ||||
1146 | // Specify an invalid VkBool32 value | ||||
1147 | // Expected to trigger a warning with | ||||
1148 | // parameter_validation::validate_bool32 | ||||
1149 | VkSampler sampler = VK_NULL_HANDLE; | ||||
1150 | VkSamplerCreateInfo sampler_info = {}; | ||||
1151 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; | ||||
1152 | sampler_info.pNext = NULL; | ||||
1153 | sampler_info.magFilter = VK_FILTER_NEAREST; | ||||
1154 | sampler_info.minFilter = VK_FILTER_NEAREST; | ||||
1155 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
1156 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
1157 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
1158 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
1159 | sampler_info.mipLodBias = 1.0; | ||||
1160 | sampler_info.maxAnisotropy = 1; | ||||
1161 | sampler_info.compareEnable = VK_FALSE; | ||||
1162 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; | ||||
1163 | sampler_info.minLod = 1.0; | ||||
1164 | sampler_info.maxLod = 1.0; | ||||
1165 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
1166 | sampler_info.unnormalizedCoordinates = VK_FALSE; | ||||
1167 | // Not VK_TRUE or VK_FALSE | ||||
1168 | sampler_info.anisotropyEnable = 3; | ||||
1169 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); | ||||
1170 | m_errorMonitor->VerifyFound(); | ||||
1171 | } | ||||
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 1172 | |
1173 | TEST_F(VkLayerTest, FailedReturnValue) { | ||||
1174 | TEST_DESCRIPTION("Check for a message describing a VkResult failure code"); | ||||
1175 | |||||
1176 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1177 | |||||
Dustin Graves | 13c1e2b | 2016-05-16 15:31:02 -0600 | [diff] [blame] | 1178 | // Find an unsupported image format |
1179 | VkFormat unsupported = VK_FORMAT_UNDEFINED; | ||||
1180 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { | ||||
1181 | VkFormat format = static_cast<VkFormat>(f); | ||||
1182 | VkFormatProperties fProps = m_device->format_properties(format); | ||||
1183 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && | ||||
1184 | fProps.optimalTilingFeatures == 0) { | ||||
1185 | unsupported = format; | ||||
1186 | break; | ||||
1187 | } | ||||
1188 | } | ||||
1189 | |||||
1190 | if (unsupported != VK_FORMAT_UNDEFINED) { | ||||
1191 | m_errorMonitor->SetDesiredFailureMsg( | ||||
1192 | VK_DEBUG_REPORT_WARNING_BIT_EXT, | ||||
1193 | "the requested format is not supported on this device"); | ||||
1194 | // Specify an unsupported VkFormat value to generate a | ||||
1195 | // VK_ERROR_FORMAT_NOT_SUPPORTED return code | ||||
1196 | // Expected to trigger a warning from | ||||
1197 | // parameter_validation::validate_result | ||||
1198 | VkImageFormatProperties image_format_properties; | ||||
1199 | VkResult err = vkGetPhysicalDeviceImageFormatProperties( | ||||
1200 | gpu(), unsupported, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, | ||||
1201 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &image_format_properties); | ||||
1202 | ASSERT_TRUE(err == VK_ERROR_FORMAT_NOT_SUPPORTED); | ||||
1203 | m_errorMonitor->VerifyFound(); | ||||
1204 | } | ||||
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 1205 | } |
Mark Lobodzinski | e090fef | 2016-06-09 17:04:56 -0600 | [diff] [blame] | 1206 | |
1207 | TEST_F(VkLayerTest, UpdateBufferAlignment) { | ||||
1208 | TEST_DESCRIPTION("Check alignment parameters for vkCmdUpdateBuffer"); | ||||
1209 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; | ||||
1210 | |||||
1211 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1212 | |||||
1213 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
1214 | vk_testing::Buffer buffer; | ||||
1215 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); | ||||
1216 | |||||
1217 | BeginCommandBuffer(); | ||||
1218 | // Introduce failure by using dstOffset that is not multiple of 4 | ||||
1219 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1220 | " is not a multiple of 4"); | ||||
1221 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); | ||||
1222 | m_errorMonitor->VerifyFound(); | ||||
1223 | |||||
1224 | // Introduce failure by using dataSize that is not multiple of 4 | ||||
1225 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1226 | " is not a multiple of 4"); | ||||
1227 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); | ||||
1228 | m_errorMonitor->VerifyFound(); | ||||
1229 | |||||
1230 | // Introduce failure by using dataSize that is < 0 | ||||
1231 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1232 | "must be greater than zero and less than or equal to 65536"); | ||||
1233 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, -44, updateData); | ||||
1234 | m_errorMonitor->VerifyFound(); | ||||
1235 | |||||
1236 | // Introduce failure by using dataSize that is > 65536 | ||||
1237 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1238 | "must be greater than zero and less than or equal to 65536"); | ||||
1239 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 80000, updateData); | ||||
1240 | m_errorMonitor->VerifyFound(); | ||||
1241 | |||||
1242 | EndCommandBuffer(); | ||||
1243 | } | ||||
1244 | |||||
1245 | TEST_F(VkLayerTest, FillBufferAlignment) { | ||||
1246 | TEST_DESCRIPTION("Check alignment parameters for vkCmdFillBuffer"); | ||||
1247 | |||||
1248 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1249 | |||||
1250 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
1251 | vk_testing::Buffer buffer; | ||||
1252 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); | ||||
1253 | |||||
1254 | BeginCommandBuffer(); | ||||
1255 | |||||
1256 | // Introduce failure by using dstOffset that is not multiple of 4 | ||||
1257 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1258 | " is not a multiple of 4"); | ||||
1259 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); | ||||
1260 | m_errorMonitor->VerifyFound(); | ||||
1261 | |||||
1262 | // Introduce failure by using size that is not multiple of 4 | ||||
1263 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1264 | " is not a multiple of 4"); | ||||
1265 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); | ||||
1266 | m_errorMonitor->VerifyFound(); | ||||
1267 | |||||
1268 | // Introduce failure by using size that is zero | ||||
1269 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1270 | "must be greater than zero"); | ||||
1271 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 0, 0x11111111); | ||||
1272 | m_errorMonitor->VerifyFound(); | ||||
1273 | |||||
1274 | EndCommandBuffer(); | ||||
1275 | } | ||||
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1276 | |
1277 | // This is a positive test. No failures are expected. | ||||
1278 | TEST_F(VkLayerTest, IgnoreUnrelatedDescriptor) { | ||||
1279 | TEST_DESCRIPTION("Ensure that the vkUpdateDescriptorSet validation code " | ||||
1280 | "is ignoring VkWriteDescriptorSet members that are not " | ||||
1281 | "related to the descriptor type specified by " | ||||
1282 | "VkWriteDescriptorSet::descriptorType. Correct " | ||||
1283 | "validation behavior will result in the test running to " | ||||
1284 | "completion without validation errors."); | ||||
1285 | |||||
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1286 | const uintptr_t invalid_ptr = 0xcdcdcdcd; |
1287 | |||||
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1288 | ASSERT_NO_FATAL_FAILURE(InitState()); |
1289 | |||||
1290 | // Image Case | ||||
1291 | { | ||||
1292 | m_errorMonitor->ExpectSuccess(); | ||||
1293 | |||||
1294 | VkImage image; | ||||
1295 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
1296 | const int32_t tex_width = 32; | ||||
1297 | const int32_t tex_height = 32; | ||||
1298 | VkImageCreateInfo image_create_info = {}; | ||||
1299 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
1300 | image_create_info.pNext = NULL; | ||||
1301 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
1302 | image_create_info.format = tex_format; | ||||
1303 | image_create_info.extent.width = tex_width; | ||||
1304 | image_create_info.extent.height = tex_height; | ||||
1305 | image_create_info.extent.depth = 1; | ||||
1306 | image_create_info.mipLevels = 1; | ||||
1307 | image_create_info.arrayLayers = 1; | ||||
1308 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
Tobin Ehlis | 51cde41 | 2016-07-11 16:08:30 -0600 | [diff] [blame] | 1309 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1310 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
1311 | image_create_info.flags = 0; | ||||
1312 | VkResult err = | ||||
1313 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
1314 | ASSERT_VK_SUCCESS(err); | ||||
1315 | |||||
1316 | VkMemoryRequirements memory_reqs; | ||||
1317 | VkDeviceMemory image_memory; | ||||
1318 | bool pass; | ||||
1319 | VkMemoryAllocateInfo memory_info = {}; | ||||
1320 | memory_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1321 | memory_info.pNext = NULL; | ||||
1322 | memory_info.allocationSize = 0; | ||||
1323 | memory_info.memoryTypeIndex = 0; | ||||
1324 | vkGetImageMemoryRequirements(m_device->device(), image, &memory_reqs); | ||||
1325 | memory_info.allocationSize = memory_reqs.size; | ||||
1326 | pass = m_device->phy().set_memory_type(memory_reqs.memoryTypeBits, | ||||
1327 | &memory_info, 0); | ||||
1328 | ASSERT_TRUE(pass); | ||||
1329 | err = vkAllocateMemory(m_device->device(), &memory_info, NULL, | ||||
1330 | &image_memory); | ||||
1331 | ASSERT_VK_SUCCESS(err); | ||||
1332 | err = vkBindImageMemory(m_device->device(), image, image_memory, 0); | ||||
1333 | ASSERT_VK_SUCCESS(err); | ||||
1334 | |||||
1335 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
1336 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
1337 | image_view_create_info.image = image; | ||||
1338 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
1339 | image_view_create_info.format = tex_format; | ||||
1340 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
1341 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
1342 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
1343 | image_view_create_info.subresourceRange.aspectMask = | ||||
1344 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
1345 | |||||
1346 | VkImageView view; | ||||
1347 | err = vkCreateImageView(m_device->device(), &image_view_create_info, | ||||
1348 | NULL, &view); | ||||
1349 | ASSERT_VK_SUCCESS(err); | ||||
1350 | |||||
1351 | VkDescriptorPoolSize ds_type_count = {}; | ||||
1352 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
1353 | ds_type_count.descriptorCount = 1; | ||||
1354 | |||||
1355 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
1356 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
1357 | ds_pool_ci.pNext = NULL; | ||||
1358 | ds_pool_ci.maxSets = 1; | ||||
1359 | ds_pool_ci.poolSizeCount = 1; | ||||
1360 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
1361 | |||||
1362 | VkDescriptorPool ds_pool; | ||||
1363 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, | ||||
1364 | &ds_pool); | ||||
1365 | ASSERT_VK_SUCCESS(err); | ||||
1366 | |||||
1367 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
1368 | dsl_binding.binding = 0; | ||||
1369 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
1370 | dsl_binding.descriptorCount = 1; | ||||
1371 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
1372 | dsl_binding.pImmutableSamplers = NULL; | ||||
1373 | |||||
1374 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
1375 | ds_layout_ci.sType = | ||||
1376 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
1377 | ds_layout_ci.pNext = NULL; | ||||
1378 | ds_layout_ci.bindingCount = 1; | ||||
1379 | ds_layout_ci.pBindings = &dsl_binding; | ||||
1380 | VkDescriptorSetLayout ds_layout; | ||||
1381 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, | ||||
1382 | NULL, &ds_layout); | ||||
1383 | ASSERT_VK_SUCCESS(err); | ||||
1384 | |||||
1385 | VkDescriptorSet descriptor_set; | ||||
1386 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
1387 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
1388 | alloc_info.descriptorSetCount = 1; | ||||
1389 | alloc_info.descriptorPool = ds_pool; | ||||
1390 | alloc_info.pSetLayouts = &ds_layout; | ||||
1391 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
1392 | &descriptor_set); | ||||
1393 | ASSERT_VK_SUCCESS(err); | ||||
1394 | |||||
1395 | VkDescriptorImageInfo image_info = {}; | ||||
1396 | image_info.imageView = view; | ||||
1397 | image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
1398 | |||||
1399 | VkWriteDescriptorSet descriptor_write; | ||||
1400 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
1401 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
1402 | descriptor_write.dstSet = descriptor_set; | ||||
1403 | descriptor_write.dstBinding = 0; | ||||
1404 | descriptor_write.descriptorCount = 1; | ||||
1405 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
1406 | descriptor_write.pImageInfo = &image_info; | ||||
1407 | |||||
1408 | // Set pBufferInfo and pTexelBufferView to invalid values, which should | ||||
1409 | // be | ||||
1410 | // ignored for descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE. | ||||
1411 | // This will most likely produce a crash if the parameter_validation | ||||
1412 | // layer | ||||
1413 | // does not correctly ignore pBufferInfo. | ||||
1414 | descriptor_write.pBufferInfo = | ||||
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1415 | reinterpret_cast<const VkDescriptorBufferInfo *>(invalid_ptr); |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1416 | descriptor_write.pTexelBufferView = |
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1417 | reinterpret_cast<const VkBufferView *>(invalid_ptr); |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1418 | |
1419 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, | ||||
1420 | NULL); | ||||
1421 | |||||
1422 | m_errorMonitor->VerifyNotFound(); | ||||
1423 | |||||
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1424 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
1425 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
1426 | vkDestroyImageView(m_device->device(), view, NULL); | ||||
1427 | vkDestroyImage(m_device->device(), image, NULL); | ||||
1428 | vkFreeMemory(m_device->device(), image_memory, NULL); | ||||
1429 | } | ||||
1430 | |||||
1431 | // Buffer Case | ||||
1432 | { | ||||
1433 | m_errorMonitor->ExpectSuccess(); | ||||
1434 | |||||
1435 | VkBuffer buffer; | ||||
1436 | uint32_t queue_family_index = 0; | ||||
1437 | VkBufferCreateInfo buffer_create_info = {}; | ||||
1438 | buffer_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
1439 | buffer_create_info.size = 1024; | ||||
1440 | buffer_create_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
1441 | buffer_create_info.queueFamilyIndexCount = 1; | ||||
1442 | buffer_create_info.pQueueFamilyIndices = &queue_family_index; | ||||
1443 | |||||
1444 | VkResult err = vkCreateBuffer(m_device->device(), &buffer_create_info, | ||||
1445 | NULL, &buffer); | ||||
1446 | ASSERT_VK_SUCCESS(err); | ||||
1447 | |||||
1448 | VkMemoryRequirements memory_reqs; | ||||
1449 | VkDeviceMemory buffer_memory; | ||||
1450 | bool pass; | ||||
1451 | VkMemoryAllocateInfo memory_info = {}; | ||||
1452 | memory_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1453 | memory_info.pNext = NULL; | ||||
1454 | memory_info.allocationSize = 0; | ||||
1455 | memory_info.memoryTypeIndex = 0; | ||||
1456 | |||||
1457 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memory_reqs); | ||||
1458 | memory_info.allocationSize = memory_reqs.size; | ||||
1459 | pass = m_device->phy().set_memory_type(memory_reqs.memoryTypeBits, | ||||
1460 | &memory_info, 0); | ||||
1461 | ASSERT_TRUE(pass); | ||||
1462 | |||||
1463 | err = vkAllocateMemory(m_device->device(), &memory_info, NULL, | ||||
1464 | &buffer_memory); | ||||
1465 | ASSERT_VK_SUCCESS(err); | ||||
1466 | err = vkBindBufferMemory(m_device->device(), buffer, buffer_memory, 0); | ||||
1467 | ASSERT_VK_SUCCESS(err); | ||||
1468 | |||||
1469 | VkDescriptorPoolSize ds_type_count = {}; | ||||
1470 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
1471 | ds_type_count.descriptorCount = 1; | ||||
1472 | |||||
1473 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
1474 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
1475 | ds_pool_ci.pNext = NULL; | ||||
1476 | ds_pool_ci.maxSets = 1; | ||||
1477 | ds_pool_ci.poolSizeCount = 1; | ||||
1478 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
1479 | |||||
1480 | VkDescriptorPool ds_pool; | ||||
1481 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, | ||||
1482 | &ds_pool); | ||||
1483 | ASSERT_VK_SUCCESS(err); | ||||
1484 | |||||
1485 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
1486 | dsl_binding.binding = 0; | ||||
1487 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
1488 | dsl_binding.descriptorCount = 1; | ||||
1489 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
1490 | dsl_binding.pImmutableSamplers = NULL; | ||||
1491 | |||||
1492 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
1493 | ds_layout_ci.sType = | ||||
1494 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
1495 | ds_layout_ci.pNext = NULL; | ||||
1496 | ds_layout_ci.bindingCount = 1; | ||||
1497 | ds_layout_ci.pBindings = &dsl_binding; | ||||
1498 | VkDescriptorSetLayout ds_layout; | ||||
1499 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, | ||||
1500 | NULL, &ds_layout); | ||||
1501 | ASSERT_VK_SUCCESS(err); | ||||
1502 | |||||
1503 | VkDescriptorSet descriptor_set; | ||||
1504 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
1505 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
1506 | alloc_info.descriptorSetCount = 1; | ||||
1507 | alloc_info.descriptorPool = ds_pool; | ||||
1508 | alloc_info.pSetLayouts = &ds_layout; | ||||
1509 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
1510 | &descriptor_set); | ||||
1511 | ASSERT_VK_SUCCESS(err); | ||||
1512 | |||||
1513 | VkDescriptorBufferInfo buffer_info = {}; | ||||
1514 | buffer_info.buffer = buffer; | ||||
1515 | buffer_info.offset = 0; | ||||
1516 | buffer_info.range = 1024; | ||||
1517 | |||||
1518 | VkWriteDescriptorSet descriptor_write; | ||||
1519 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
1520 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
1521 | descriptor_write.dstSet = descriptor_set; | ||||
1522 | descriptor_write.dstBinding = 0; | ||||
1523 | descriptor_write.descriptorCount = 1; | ||||
1524 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
1525 | descriptor_write.pBufferInfo = &buffer_info; | ||||
1526 | |||||
1527 | // Set pImageInfo and pTexelBufferView to invalid values, which should | ||||
1528 | // be | ||||
1529 | // ignored for descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER. | ||||
1530 | // This will most likely produce a crash if the parameter_validation | ||||
1531 | // layer | ||||
1532 | // does not correctly ignore pImageInfo. | ||||
1533 | descriptor_write.pImageInfo = | ||||
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1534 | reinterpret_cast<const VkDescriptorImageInfo *>(invalid_ptr); |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1535 | descriptor_write.pTexelBufferView = |
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1536 | reinterpret_cast<const VkBufferView *>(invalid_ptr); |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1537 | |
1538 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, | ||||
1539 | NULL); | ||||
1540 | |||||
1541 | m_errorMonitor->VerifyNotFound(); | ||||
1542 | |||||
1543 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set); | ||||
1544 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
1545 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
1546 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1547 | vkFreeMemory(m_device->device(), buffer_memory, NULL); | ||||
1548 | } | ||||
1549 | |||||
1550 | // Texel Buffer Case | ||||
1551 | { | ||||
1552 | m_errorMonitor->ExpectSuccess(); | ||||
1553 | |||||
1554 | VkBuffer buffer; | ||||
1555 | uint32_t queue_family_index = 0; | ||||
1556 | VkBufferCreateInfo buffer_create_info = {}; | ||||
1557 | buffer_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
1558 | buffer_create_info.size = 1024; | ||||
1559 | buffer_create_info.usage = VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; | ||||
1560 | buffer_create_info.queueFamilyIndexCount = 1; | ||||
1561 | buffer_create_info.pQueueFamilyIndices = &queue_family_index; | ||||
1562 | |||||
1563 | VkResult err = vkCreateBuffer(m_device->device(), &buffer_create_info, | ||||
1564 | NULL, &buffer); | ||||
1565 | ASSERT_VK_SUCCESS(err); | ||||
1566 | |||||
1567 | VkMemoryRequirements memory_reqs; | ||||
1568 | VkDeviceMemory buffer_memory; | ||||
1569 | bool pass; | ||||
1570 | VkMemoryAllocateInfo memory_info = {}; | ||||
1571 | memory_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1572 | memory_info.pNext = NULL; | ||||
1573 | memory_info.allocationSize = 0; | ||||
1574 | memory_info.memoryTypeIndex = 0; | ||||
1575 | |||||
1576 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memory_reqs); | ||||
1577 | memory_info.allocationSize = memory_reqs.size; | ||||
1578 | pass = m_device->phy().set_memory_type(memory_reqs.memoryTypeBits, | ||||
1579 | &memory_info, 0); | ||||
1580 | ASSERT_TRUE(pass); | ||||
1581 | |||||
1582 | err = vkAllocateMemory(m_device->device(), &memory_info, NULL, | ||||
1583 | &buffer_memory); | ||||
1584 | ASSERT_VK_SUCCESS(err); | ||||
1585 | err = vkBindBufferMemory(m_device->device(), buffer, buffer_memory, 0); | ||||
1586 | ASSERT_VK_SUCCESS(err); | ||||
1587 | |||||
1588 | VkBufferViewCreateInfo buff_view_ci = {}; | ||||
1589 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; | ||||
1590 | buff_view_ci.buffer = buffer; | ||||
1591 | buff_view_ci.format = VK_FORMAT_R8_UNORM; | ||||
1592 | buff_view_ci.range = VK_WHOLE_SIZE; | ||||
1593 | VkBufferView buffer_view; | ||||
1594 | err = vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, | ||||
1595 | &buffer_view); | ||||
1596 | |||||
1597 | VkDescriptorPoolSize ds_type_count = {}; | ||||
1598 | ds_type_count.type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; | ||||
1599 | ds_type_count.descriptorCount = 1; | ||||
1600 | |||||
1601 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
1602 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
1603 | ds_pool_ci.pNext = NULL; | ||||
1604 | ds_pool_ci.maxSets = 1; | ||||
1605 | ds_pool_ci.poolSizeCount = 1; | ||||
1606 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
1607 | |||||
1608 | VkDescriptorPool ds_pool; | ||||
1609 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, | ||||
1610 | &ds_pool); | ||||
1611 | ASSERT_VK_SUCCESS(err); | ||||
1612 | |||||
1613 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
1614 | dsl_binding.binding = 0; | ||||
1615 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; | ||||
1616 | dsl_binding.descriptorCount = 1; | ||||
1617 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
1618 | dsl_binding.pImmutableSamplers = NULL; | ||||
1619 | |||||
1620 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
1621 | ds_layout_ci.sType = | ||||
1622 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
1623 | ds_layout_ci.pNext = NULL; | ||||
1624 | ds_layout_ci.bindingCount = 1; | ||||
1625 | ds_layout_ci.pBindings = &dsl_binding; | ||||
1626 | VkDescriptorSetLayout ds_layout; | ||||
1627 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, | ||||
1628 | NULL, &ds_layout); | ||||
1629 | ASSERT_VK_SUCCESS(err); | ||||
1630 | |||||
1631 | VkDescriptorSet descriptor_set; | ||||
1632 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
1633 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
1634 | alloc_info.descriptorSetCount = 1; | ||||
1635 | alloc_info.descriptorPool = ds_pool; | ||||
1636 | alloc_info.pSetLayouts = &ds_layout; | ||||
1637 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
1638 | &descriptor_set); | ||||
1639 | ASSERT_VK_SUCCESS(err); | ||||
1640 | |||||
1641 | VkWriteDescriptorSet descriptor_write; | ||||
1642 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
1643 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
1644 | descriptor_write.dstSet = descriptor_set; | ||||
1645 | descriptor_write.dstBinding = 0; | ||||
1646 | descriptor_write.descriptorCount = 1; | ||||
1647 | descriptor_write.descriptorType = | ||||
1648 | VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; | ||||
1649 | descriptor_write.pTexelBufferView = &buffer_view; | ||||
1650 | |||||
1651 | // Set pImageInfo and pBufferInfo to invalid values, which should be | ||||
1652 | // ignored for descriptorType == | ||||
1653 | // VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER. | ||||
1654 | // This will most likely produce a crash if the parameter_validation | ||||
1655 | // layer | ||||
1656 | // does not correctly ignore pImageInfo and pBufferInfo. | ||||
1657 | descriptor_write.pImageInfo = | ||||
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1658 | reinterpret_cast<const VkDescriptorImageInfo *>(invalid_ptr); |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1659 | descriptor_write.pBufferInfo = |
Dustin Graves | 5e2d8fc | 2016-07-07 16:18:49 -0600 | [diff] [blame] | 1660 | reinterpret_cast<const VkDescriptorBufferInfo *>(invalid_ptr); |
Dustin Graves | 40f3582 | 2016-06-23 11:12:53 -0600 | [diff] [blame] | 1661 | |
1662 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, | ||||
1663 | NULL); | ||||
1664 | |||||
1665 | m_errorMonitor->VerifyNotFound(); | ||||
1666 | |||||
1667 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set); | ||||
1668 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
1669 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
1670 | vkDestroyBufferView(m_device->device(), buffer_view, NULL); | ||||
1671 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1672 | vkFreeMemory(m_device->device(), buffer_memory, NULL); | ||||
1673 | } | ||||
1674 | } | ||||
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 1675 | #endif // PARAMETER_VALIDATION_TESTS |
1676 | |||||
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1677 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1678 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1679 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1680 | { |
1681 | vk_testing::Fence testFence; | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1682 | VkFenceCreateInfo fenceInfo = {}; |
1683 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
1684 | fenceInfo.pNext = NULL; | ||||
1685 | fenceInfo.flags = 0; | ||||
1686 | |||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1687 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1688 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1689 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 1690 | |
1691 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
1692 | vk_testing::Buffer buffer; | ||||
1693 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1694 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1695 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1696 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1697 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1698 | |
1699 | testFence.init(*m_device, fenceInfo); | ||||
1700 | |||||
1701 | // Bypass framework since it does the waits automatically | ||||
1702 | VkResult err = VK_SUCCESS; | ||||
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1703 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1704 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
1705 | submit_info.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1706 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1707 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1708 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1709 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1710 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1711 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1712 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1713 | |
1714 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1715 | ASSERT_VK_SUCCESS( err ); |
1716 | |||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1717 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1718 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1719 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1720 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1721 | } |
1722 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1723 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1724 | { |
1725 | vk_testing::Fence testFence; | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1726 | VkFenceCreateInfo fenceInfo = {}; |
1727 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
1728 | fenceInfo.pNext = NULL; | ||||
1729 | fenceInfo.flags = 0; | ||||
1730 | |||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1731 | 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] | 1732 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1733 | ASSERT_NO_FATAL_FAILURE(InitState()); |
1734 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
1735 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
1736 | |||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1737 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1738 | 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] | 1739 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1740 | |
1741 | testFence.init(*m_device, fenceInfo); | ||||
1742 | |||||
1743 | // Bypass framework since it does the waits automatically | ||||
1744 | VkResult err = VK_SUCCESS; | ||||
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1745 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1746 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
1747 | submit_info.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1748 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1749 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1750 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1751 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1752 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1753 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1754 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1755 | |
1756 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); | ||||
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1757 | ASSERT_VK_SUCCESS( err ); |
1758 | |||||
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1759 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1760 | VkCommandBufferBeginInfo info = {}; |
1761 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; | ||||
1762 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1763 | info.renderPass = VK_NULL_HANDLE; |
1764 | info.subpass = 0; | ||||
1765 | info.framebuffer = VK_NULL_HANDLE; | ||||
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 1766 | info.occlusionQueryEnable = VK_FALSE; |
1767 | info.queryFlags = 0; | ||||
1768 | info.pipelineStatistics = 0; | ||||
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1769 | |
1770 | // Introduce failure by calling BCB again before checking fence | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1771 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1772 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1773 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1774 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1775 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1776 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1777 | // This is a positive test. No failures are expected. |
1778 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { | ||||
1779 | VkResult err; | ||||
1780 | bool pass; | ||||
1781 | |||||
1782 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " | ||||
1783 | "the buffer, create an image, and bind the same memory to " | ||||
1784 | "it"); | ||||
1785 | |||||
1786 | m_errorMonitor->ExpectSuccess(); | ||||
1787 | |||||
1788 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1789 | |||||
1790 | VkBuffer buffer; | ||||
1791 | VkImage image; | ||||
1792 | VkDeviceMemory mem; | ||||
1793 | VkMemoryRequirements mem_reqs; | ||||
1794 | |||||
1795 | VkBufferCreateInfo buf_info = {}; | ||||
1796 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
1797 | buf_info.pNext = NULL; | ||||
1798 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
1799 | buf_info.size = 256; | ||||
1800 | buf_info.queueFamilyIndexCount = 0; | ||||
1801 | buf_info.pQueueFamilyIndices = NULL; | ||||
1802 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1803 | buf_info.flags = 0; | ||||
1804 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); | ||||
1805 | ASSERT_VK_SUCCESS(err); | ||||
1806 | |||||
1807 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); | ||||
1808 | |||||
1809 | VkMemoryAllocateInfo alloc_info = {}; | ||||
1810 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1811 | alloc_info.pNext = NULL; | ||||
1812 | alloc_info.memoryTypeIndex = 0; | ||||
1813 | |||||
1814 | // Ensure memory is big enough for both bindings | ||||
1815 | alloc_info.allocationSize = 0x10000; | ||||
1816 | |||||
1817 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, | ||||
1818 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
1819 | if (!pass) { | ||||
1820 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1821 | return; | ||||
1822 | } | ||||
1823 | |||||
1824 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); | ||||
1825 | ASSERT_VK_SUCCESS(err); | ||||
1826 | |||||
1827 | uint8_t *pData; | ||||
1828 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, | ||||
1829 | (void **)&pData); | ||||
1830 | ASSERT_VK_SUCCESS(err); | ||||
1831 | |||||
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 1832 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1833 | |
1834 | vkUnmapMemory(m_device->device(), mem); | ||||
1835 | |||||
1836 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
1837 | ASSERT_VK_SUCCESS(err); | ||||
1838 | |||||
1839 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this | ||||
1840 | // memory. In fact, it was never used by the GPU. | ||||
1841 | // Just be be sure, wait for idle. | ||||
1842 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
1843 | vkDeviceWaitIdle(m_device->device()); | ||||
1844 | |||||
1845 | VkImageCreateInfo image_create_info = {}; | ||||
1846 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
1847 | image_create_info.pNext = NULL; | ||||
1848 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
1849 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
1850 | image_create_info.extent.width = 64; | ||||
1851 | image_create_info.extent.height = 64; | ||||
1852 | image_create_info.extent.depth = 1; | ||||
1853 | image_create_info.mipLevels = 1; | ||||
1854 | image_create_info.arrayLayers = 1; | ||||
1855 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
1856 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
1857 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | ||||
1858 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
1859 | image_create_info.queueFamilyIndexCount = 0; | ||||
1860 | image_create_info.pQueueFamilyIndices = NULL; | ||||
1861 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1862 | image_create_info.flags = 0; | ||||
1863 | |||||
1864 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
1865 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1866 | mem_alloc.pNext = NULL; | ||||
1867 | mem_alloc.allocationSize = 0; | ||||
1868 | mem_alloc.memoryTypeIndex = 0; | ||||
1869 | |||||
1870 | /* Create a mappable image. It will be the texture if linear images are ok | ||||
1871 | * to be textures or it will be the staging image if they are not. | ||||
1872 | */ | ||||
1873 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
1874 | ASSERT_VK_SUCCESS(err); | ||||
1875 | |||||
1876 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
1877 | |||||
1878 | mem_alloc.allocationSize = mem_reqs.size; | ||||
1879 | |||||
1880 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, | ||||
1881 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
1882 | if (!pass) { | ||||
1883 | vkDestroyImage(m_device->device(), image, NULL); | ||||
1884 | return; | ||||
1885 | } | ||||
1886 | |||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1887 | // VALIDATION FAILURE: |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1888 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
1889 | ASSERT_VK_SUCCESS(err); | ||||
1890 | |||||
1891 | m_errorMonitor->VerifyNotFound(); | ||||
1892 | |||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 1893 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1894 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
1895 | vkDestroyImage(m_device->device(), image, NULL); | ||||
1896 | } | ||||
1897 | |||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1898 | TEST_F(VkLayerTest, InvalidMemoryAliasing) { |
1899 | TEST_DESCRIPTION("Create a buffer and image, allocate memory, and bind the " | ||||
1900 | "buffer and image to memory such that they will alias."); | ||||
1901 | VkResult err; | ||||
1902 | bool pass; | ||||
1903 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1904 | |||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1905 | VkBuffer buffer, buffer2; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1906 | VkImage image; |
1907 | VkDeviceMemory mem; // buffer will be bound first | ||||
1908 | VkDeviceMemory mem_img; // image bound first | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1909 | VkMemoryRequirements buff_mem_reqs, img_mem_reqs; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1910 | |
1911 | VkBufferCreateInfo buf_info = {}; | ||||
1912 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
1913 | buf_info.pNext = NULL; | ||||
1914 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
1915 | buf_info.size = 256; | ||||
1916 | buf_info.queueFamilyIndexCount = 0; | ||||
1917 | buf_info.pQueueFamilyIndices = NULL; | ||||
1918 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1919 | buf_info.flags = 0; | ||||
1920 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); | ||||
1921 | ASSERT_VK_SUCCESS(err); | ||||
1922 | |||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1923 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &buff_mem_reqs); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1924 | |
1925 | VkImageCreateInfo image_create_info = {}; | ||||
1926 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
1927 | image_create_info.pNext = NULL; | ||||
1928 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
1929 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
1930 | image_create_info.extent.width = 64; | ||||
1931 | image_create_info.extent.height = 64; | ||||
1932 | image_create_info.extent.depth = 1; | ||||
1933 | image_create_info.mipLevels = 1; | ||||
1934 | image_create_info.arrayLayers = 1; | ||||
1935 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
1936 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
1937 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | ||||
1938 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
1939 | image_create_info.queueFamilyIndexCount = 0; | ||||
1940 | image_create_info.pQueueFamilyIndices = NULL; | ||||
1941 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
1942 | image_create_info.flags = 0; | ||||
1943 | |||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1944 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
1945 | ASSERT_VK_SUCCESS(err); | ||||
1946 | |||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1947 | vkGetImageMemoryRequirements(m_device->device(), image, &img_mem_reqs); |
1948 | |||||
1949 | VkMemoryAllocateInfo alloc_info = {}; | ||||
1950 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
1951 | alloc_info.pNext = NULL; | ||||
1952 | alloc_info.memoryTypeIndex = 0; | ||||
1953 | // Ensure memory is big enough for both bindings | ||||
1954 | alloc_info.allocationSize = buff_mem_reqs.size + img_mem_reqs.size; | ||||
1955 | pass = m_device->phy().set_memory_type( | ||||
1956 | buff_mem_reqs.memoryTypeBits | img_mem_reqs.memoryTypeBits, &alloc_info, | ||||
1957 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1958 | if (!pass) { |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1959 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1960 | vkDestroyImage(m_device->device(), image, NULL); |
1961 | return; | ||||
1962 | } | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1963 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
1964 | ASSERT_VK_SUCCESS(err); | ||||
1965 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
1966 | ASSERT_VK_SUCCESS(err); | ||||
1967 | |||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1968 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
1969 | " is aliased with buffer 0x"); | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1970 | // VALIDATION FAILURE due to image mapping overlapping buffer mapping |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1971 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
1972 | m_errorMonitor->VerifyFound(); | ||||
1973 | |||||
1974 | // Now correctly bind image to second mem allocation before incorrectly | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1975 | // aliasing buffer2 |
1976 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer2); | ||||
1977 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1978 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem_img); |
1979 | ASSERT_VK_SUCCESS(err); | ||||
1980 | err = vkBindImageMemory(m_device->device(), image, mem_img, 0); | ||||
1981 | ASSERT_VK_SUCCESS(err); | ||||
1982 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
1983 | " is aliased with image 0x"); | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1984 | err = vkBindBufferMemory(m_device->device(), buffer2, mem_img, 0); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1985 | m_errorMonitor->VerifyFound(); |
1986 | |||||
1987 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1988 | vkDestroyBuffer(m_device->device(), buffer2, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1989 | vkDestroyImage(m_device->device(), image, NULL); |
1990 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
1991 | vkFreeMemory(m_device->device(), mem_img, NULL); | ||||
1992 | } | ||||
1993 | |||||
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 1994 | TEST_F(VkLayerTest, InvalidMemoryMapping) { |
1995 | TEST_DESCRIPTION("Attempt to map memory in a number of incorrect ways"); | ||||
1996 | VkResult err; | ||||
1997 | bool pass; | ||||
1998 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
1999 | |||||
2000 | VkBuffer buffer; | ||||
2001 | VkDeviceMemory mem; | ||||
2002 | VkMemoryRequirements mem_reqs; | ||||
2003 | |||||
2004 | VkBufferCreateInfo buf_info = {}; | ||||
2005 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
2006 | buf_info.pNext = NULL; | ||||
2007 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
2008 | buf_info.size = 256; | ||||
2009 | buf_info.queueFamilyIndexCount = 0; | ||||
2010 | buf_info.pQueueFamilyIndices = NULL; | ||||
2011 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
2012 | buf_info.flags = 0; | ||||
2013 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); | ||||
2014 | ASSERT_VK_SUCCESS(err); | ||||
2015 | |||||
2016 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); | ||||
2017 | VkMemoryAllocateInfo alloc_info = {}; | ||||
2018 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
2019 | alloc_info.pNext = NULL; | ||||
2020 | alloc_info.memoryTypeIndex = 0; | ||||
2021 | |||||
2022 | // Ensure memory is big enough for both bindings | ||||
2023 | static const VkDeviceSize allocation_size = 0x10000; | ||||
2024 | alloc_info.allocationSize = allocation_size; | ||||
2025 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, | ||||
2026 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
2027 | if (!pass) { | ||||
2028 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
2029 | return; | ||||
2030 | } | ||||
2031 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); | ||||
2032 | ASSERT_VK_SUCCESS(err); | ||||
2033 | |||||
2034 | uint8_t *pData; | ||||
2035 | // Attempt to map memory size 0 is invalid | ||||
2036 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2037 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2038 | "VkMapMemory: Attempting to map memory range of size zero"); | ||||
2039 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, (void **)&pData); | ||||
2040 | m_errorMonitor->VerifyFound(); | ||||
2041 | // Map memory twice | ||||
2042 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, | ||||
2043 | (void **)&pData); | ||||
2044 | ASSERT_VK_SUCCESS(err); | ||||
2045 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2046 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2047 | "VkMapMemory: Attempting to map memory on an already-mapped object "); | ||||
2048 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, | ||||
2049 | (void **)&pData); | ||||
2050 | m_errorMonitor->VerifyFound(); | ||||
2051 | |||||
2052 | // Unmap the memory to avoid re-map error | ||||
2053 | vkUnmapMemory(m_device->device(), mem); | ||||
2054 | // overstep allocation with VK_WHOLE_SIZE | ||||
2055 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2056 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2057 | " with size of VK_WHOLE_SIZE oversteps total array size 0x"); | ||||
2058 | err = vkMapMemory(m_device->device(), mem, allocation_size + 1, | ||||
2059 | VK_WHOLE_SIZE, 0, (void **)&pData); | ||||
2060 | m_errorMonitor->VerifyFound(); | ||||
2061 | // overstep allocation w/o VK_WHOLE_SIZE | ||||
2062 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2063 | " oversteps total array size 0x"); | ||||
2064 | err = vkMapMemory(m_device->device(), mem, 1, allocation_size, 0, | ||||
2065 | (void **)&pData); | ||||
2066 | m_errorMonitor->VerifyFound(); | ||||
2067 | // Now error due to unmapping memory that's not mapped | ||||
2068 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2069 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2070 | "Unmapping Memory without memory being mapped: "); | ||||
2071 | vkUnmapMemory(m_device->device(), mem); | ||||
2072 | m_errorMonitor->VerifyFound(); | ||||
2073 | // Now map memory and cause errors due to flushing invalid ranges | ||||
2074 | err = vkMapMemory(m_device->device(), mem, 16, VK_WHOLE_SIZE, 0, | ||||
2075 | (void **)&pData); | ||||
2076 | ASSERT_VK_SUCCESS(err); | ||||
2077 | VkMappedMemoryRange mmr = {}; | ||||
Chris Forbes | 3aec089 | 2016-06-13 10:29:26 +1200 | [diff] [blame] | 2078 | mmr.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; |
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 2079 | mmr.memory = mem; |
2080 | mmr.offset = 15; // Error b/c offset less than offset of mapped mem | ||||
2081 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2082 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2083 | ") is less than Memory Object's offset ("); | ||||
2084 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); | ||||
2085 | m_errorMonitor->VerifyFound(); | ||||
2086 | // Now flush range that oversteps mapped range | ||||
2087 | vkUnmapMemory(m_device->device(), mem); | ||||
2088 | err = vkMapMemory(m_device->device(), mem, 0, 256, 0, (void **)&pData); | ||||
2089 | ASSERT_VK_SUCCESS(err); | ||||
2090 | mmr.offset = 16; | ||||
2091 | mmr.size = 256; // flushing bounds (272) exceed mapped bounds (256) | ||||
2092 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2093 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2094 | ") exceeds the Memory Object's upper-bound ("); | ||||
2095 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); | ||||
2096 | m_errorMonitor->VerifyFound(); | ||||
2097 | |||||
2098 | pass = | ||||
2099 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, | ||||
2100 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, | ||||
2101 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); | ||||
2102 | if (!pass) { | ||||
2103 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
2104 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
2105 | return; | ||||
2106 | } | ||||
2107 | // TODO : If we can get HOST_VISIBLE w/o HOST_COHERENT we can test cases of | ||||
2108 | // MEMTRACK_INVALID_MAP in validateAndCopyNoncoherentMemoryToDriver() | ||||
2109 | |||||
2110 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
2111 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
2112 | } | ||||
2113 | |||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2114 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
2115 | VkResult err; | ||||
2116 | bool pass; | ||||
2117 | |||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2118 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
2119 | // following declaration (which is temporarily being moved below): | ||||
2120 | // VkSurfaceKHR surface = VK_NULL_HANDLE; | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2121 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
2122 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; | ||||
2123 | uint32_t swapchain_image_count = 0; | ||||
2124 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; | ||||
2125 | uint32_t image_index = 0; | ||||
2126 | // VkPresentInfoKHR present_info = {}; | ||||
2127 | |||||
2128 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
2129 | |||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2130 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
2131 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) | ||||
2132 | // Use the functions from the VK_KHR_android_surface extension without | ||||
2133 | // enabling that extension: | ||||
2134 | |||||
2135 | // Create a surface: | ||||
2136 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2137 | m_errorMonitor->SetDesiredFailureMsg( |
2138 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2139 | "extension was not enabled for this"); | ||||
2140 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, | ||||
2141 | &surface); | ||||
2142 | pass = (err != VK_SUCCESS); | ||||
2143 | ASSERT_TRUE(pass); | ||||
2144 | m_errorMonitor->VerifyFound(); | ||||
2145 | #endif // VK_USE_PLATFORM_ANDROID_KHR | ||||
2146 | |||||
2147 | |||||
2148 | #if defined(VK_USE_PLATFORM_MIR_KHR) | ||||
2149 | // Use the functions from the VK_KHR_mir_surface extension without enabling | ||||
2150 | // that extension: | ||||
2151 | |||||
2152 | // Create a surface: | ||||
2153 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2154 | m_errorMonitor->SetDesiredFailureMsg( |
2155 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2156 | "extension was not enabled for this"); | ||||
2157 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); | ||||
2158 | pass = (err != VK_SUCCESS); | ||||
2159 | ASSERT_TRUE(pass); | ||||
2160 | m_errorMonitor->VerifyFound(); | ||||
2161 | |||||
2162 | // Tell whether an mir_connection supports presentation: | ||||
2163 | MirConnection *mir_connection = NULL; | ||||
2164 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2165 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2166 | "extension was not enabled for this"); | ||||
2167 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, | ||||
2168 | visual_id); | ||||
2169 | m_errorMonitor->VerifyFound(); | ||||
2170 | #endif // VK_USE_PLATFORM_MIR_KHR | ||||
2171 | |||||
2172 | |||||
2173 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) | ||||
2174 | // Use the functions from the VK_KHR_wayland_surface extension without | ||||
2175 | // enabling that extension: | ||||
2176 | |||||
2177 | // Create a surface: | ||||
2178 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2179 | m_errorMonitor->SetDesiredFailureMsg( |
2180 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2181 | "extension was not enabled for this"); | ||||
2182 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, | ||||
2183 | &surface); | ||||
2184 | pass = (err != VK_SUCCESS); | ||||
2185 | ASSERT_TRUE(pass); | ||||
2186 | m_errorMonitor->VerifyFound(); | ||||
2187 | |||||
2188 | // Tell whether an wayland_display supports presentation: | ||||
2189 | struct wl_display wayland_display = {}; | ||||
2190 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2191 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2192 | "extension was not enabled for this"); | ||||
2193 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, | ||||
2194 | &wayland_display); | ||||
2195 | m_errorMonitor->VerifyFound(); | ||||
2196 | #endif // VK_USE_PLATFORM_WAYLAND_KHR | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2197 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2198 | |
2199 | |||||
2200 | #if defined(VK_USE_PLATFORM_WIN32_KHR) | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2201 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
2202 | // TO NON-LINUX PLATFORMS: | ||||
2203 | VkSurfaceKHR surface = VK_NULL_HANDLE; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2204 | // Use the functions from the VK_KHR_win32_surface extension without |
2205 | // enabling that extension: | ||||
2206 | |||||
2207 | // Create a surface: | ||||
2208 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2209 | m_errorMonitor->SetDesiredFailureMsg( |
2210 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2211 | "extension was not enabled for this"); | ||||
2212 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, | ||||
2213 | &surface); | ||||
2214 | pass = (err != VK_SUCCESS); | ||||
2215 | ASSERT_TRUE(pass); | ||||
2216 | m_errorMonitor->VerifyFound(); | ||||
2217 | |||||
2218 | // Tell whether win32 supports presentation: | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2219 | m_errorMonitor->SetDesiredFailureMsg( |
2220 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2221 | "extension was not enabled for this"); | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2222 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2223 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2224 | // Set this (for now, until all platforms are supported and tested): |
2225 | #define NEED_TO_TEST_THIS_ON_PLATFORM | ||||
2226 | #endif // VK_USE_PLATFORM_WIN32_KHR | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2227 | |
2228 | |||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2229 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2230 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
2231 | // TO NON-LINUX PLATFORMS: | ||||
2232 | VkSurfaceKHR surface = VK_NULL_HANDLE; | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2233 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
2234 | // that extension: | ||||
2235 | |||||
2236 | // Create a surface: | ||||
2237 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2238 | m_errorMonitor->SetDesiredFailureMsg( |
2239 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2240 | "extension was not enabled for this"); | ||||
2241 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); | ||||
2242 | pass = (err != VK_SUCCESS); | ||||
2243 | ASSERT_TRUE(pass); | ||||
2244 | m_errorMonitor->VerifyFound(); | ||||
2245 | |||||
2246 | // Tell whether an xcb_visualid_t supports presentation: | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2247 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2248 | xcb_visualid_t visual_id = 0; |
2249 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2250 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2251 | "extension was not enabled for this"); | ||||
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 2252 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2253 | visual_id); |
2254 | m_errorMonitor->VerifyFound(); | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2255 | // Set this (for now, until all platforms are supported and tested): |
2256 | #define NEED_TO_TEST_THIS_ON_PLATFORM | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2257 | #endif // VK_USE_PLATFORM_XCB_KHR |
2258 | |||||
2259 | |||||
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 2260 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
2261 | // Use the functions from the VK_KHR_xlib_surface extension without enabling | ||||
2262 | // that extension: | ||||
2263 | |||||
2264 | // Create a surface: | ||||
2265 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; | ||||
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 2266 | m_errorMonitor->SetDesiredFailureMsg( |
2267 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2268 | "extension was not enabled for this"); | ||||
2269 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); | ||||
2270 | pass = (err != VK_SUCCESS); | ||||
2271 | ASSERT_TRUE(pass); | ||||
2272 | m_errorMonitor->VerifyFound(); | ||||
2273 | |||||
2274 | // Tell whether an Xlib VisualID supports presentation: | ||||
2275 | Display *dpy = NULL; | ||||
2276 | VisualID visual = 0; | ||||
2277 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2278 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2279 | "extension was not enabled for this"); | ||||
2280 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); | ||||
2281 | m_errorMonitor->VerifyFound(); | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2282 | // Set this (for now, until all platforms are supported and tested): |
2283 | #define NEED_TO_TEST_THIS_ON_PLATFORM | ||||
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 2284 | #endif // VK_USE_PLATFORM_XLIB_KHR |
2285 | |||||
2286 | |||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2287 | // Use the functions from the VK_KHR_surface extension without enabling |
2288 | // that extension: | ||||
2289 | |||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2290 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2291 | // Destroy a surface: |
2292 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2293 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2294 | "extension was not enabled for this"); | ||||
2295 | vkDestroySurfaceKHR(instance(), surface, NULL); | ||||
2296 | m_errorMonitor->VerifyFound(); | ||||
2297 | |||||
2298 | // Check if surface supports presentation: | ||||
2299 | VkBool32 supported = false; | ||||
2300 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2301 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2302 | "extension was not enabled for this"); | ||||
2303 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); | ||||
2304 | pass = (err != VK_SUCCESS); | ||||
2305 | ASSERT_TRUE(pass); | ||||
2306 | m_errorMonitor->VerifyFound(); | ||||
2307 | |||||
2308 | // Check surface capabilities: | ||||
2309 | VkSurfaceCapabilitiesKHR capabilities = {}; | ||||
2310 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2311 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2312 | "extension was not enabled for this"); | ||||
2313 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, | ||||
2314 | &capabilities); | ||||
2315 | pass = (err != VK_SUCCESS); | ||||
2316 | ASSERT_TRUE(pass); | ||||
2317 | m_errorMonitor->VerifyFound(); | ||||
2318 | |||||
2319 | // Check surface formats: | ||||
2320 | uint32_t format_count = 0; | ||||
2321 | VkSurfaceFormatKHR *formats = NULL; | ||||
2322 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2323 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2324 | "extension was not enabled for this"); | ||||
2325 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, | ||||
2326 | &format_count, formats); | ||||
2327 | pass = (err != VK_SUCCESS); | ||||
2328 | ASSERT_TRUE(pass); | ||||
2329 | m_errorMonitor->VerifyFound(); | ||||
2330 | |||||
2331 | // Check surface present modes: | ||||
2332 | uint32_t present_mode_count = 0; | ||||
2333 | VkSurfaceFormatKHR *present_modes = NULL; | ||||
2334 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2335 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2336 | "extension was not enabled for this"); | ||||
2337 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, | ||||
2338 | &present_mode_count, present_modes); | ||||
2339 | pass = (err != VK_SUCCESS); | ||||
2340 | ASSERT_TRUE(pass); | ||||
2341 | m_errorMonitor->VerifyFound(); | ||||
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 2342 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2343 | |
2344 | |||||
2345 | // Use the functions from the VK_KHR_swapchain extension without enabling | ||||
2346 | // that extension: | ||||
2347 | |||||
2348 | // Create a swapchain: | ||||
2349 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2350 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2351 | "extension was not enabled for this"); | ||||
2352 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; | ||||
2353 | swapchain_create_info.pNext = NULL; | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2354 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
2355 | NULL, &swapchain); | ||||
2356 | pass = (err != VK_SUCCESS); | ||||
2357 | ASSERT_TRUE(pass); | ||||
2358 | m_errorMonitor->VerifyFound(); | ||||
2359 | |||||
2360 | // Get the images from the swapchain: | ||||
2361 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2362 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2363 | "extension was not enabled for this"); | ||||
2364 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, | ||||
2365 | &swapchain_image_count, NULL); | ||||
2366 | pass = (err != VK_SUCCESS); | ||||
2367 | ASSERT_TRUE(pass); | ||||
2368 | m_errorMonitor->VerifyFound(); | ||||
2369 | |||||
2370 | // Try to acquire an image: | ||||
2371 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2372 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2373 | "extension was not enabled for this"); | ||||
2374 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, | ||||
2375 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); | ||||
2376 | pass = (err != VK_SUCCESS); | ||||
2377 | ASSERT_TRUE(pass); | ||||
2378 | m_errorMonitor->VerifyFound(); | ||||
2379 | |||||
2380 | // Try to present an image: | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2381 | // |
2382 | // NOTE: Currently can't test this because a real swapchain is needed (as | ||||
2383 | // opposed to the fake one we created) in order for the layer to lookup the | ||||
2384 | // VkDevice used to enable the extension: | ||||
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 2385 | |
2386 | // Destroy the swapchain: | ||||
2387 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2388 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2389 | "extension was not enabled for this"); | ||||
2390 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); | ||||
2391 | m_errorMonitor->VerifyFound(); | ||||
2392 | } | ||||
2393 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2394 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2395 | |
Dustin Graves | 6c6d898 | 2016-05-17 10:09:21 -0600 | [diff] [blame] | 2396 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2397 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2398 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2399 | VkResult err; |
2400 | bool pass; | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2401 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
2402 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2403 | // uint32_t swapchain_image_count = 0; |
2404 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; | ||||
2405 | // uint32_t image_index = 0; | ||||
2406 | // VkPresentInfoKHR present_info = {}; | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2407 | |
2408 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
2409 | |||||
2410 | // Use the create function from one of the VK_KHR_*_surface extension in | ||||
2411 | // order to create a surface, testing all known errors in the process, | ||||
2412 | // before successfully creating a surface: | ||||
2413 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2414 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2415 | "called with NULL pointer"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2416 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
2417 | pass = (err != VK_SUCCESS); | ||||
2418 | ASSERT_TRUE(pass); | ||||
2419 | m_errorMonitor->VerifyFound(); | ||||
2420 | |||||
2421 | // Next, try to create a surface with the wrong | ||||
2422 | // VkXcbSurfaceCreateInfoKHR::sType: | ||||
2423 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; | ||||
2424 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2425 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2426 | "called with the wrong value for"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2427 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
2428 | pass = (err != VK_SUCCESS); | ||||
2429 | ASSERT_TRUE(pass); | ||||
2430 | m_errorMonitor->VerifyFound(); | ||||
2431 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2432 | // Create a native window, and then correctly create a surface: |
2433 | xcb_connection_t *connection; | ||||
2434 | xcb_screen_t *screen; | ||||
2435 | xcb_window_t xcb_window; | ||||
2436 | xcb_intern_atom_reply_t *atom_wm_delete_window; | ||||
2437 | |||||
2438 | const xcb_setup_t *setup; | ||||
2439 | xcb_screen_iterator_t iter; | ||||
2440 | int scr; | ||||
2441 | uint32_t value_mask, value_list[32]; | ||||
2442 | int width = 1; | ||||
2443 | int height = 1; | ||||
2444 | |||||
2445 | connection = xcb_connect(NULL, &scr); | ||||
2446 | ASSERT_TRUE(connection != NULL); | ||||
2447 | setup = xcb_get_setup(connection); | ||||
2448 | iter = xcb_setup_roots_iterator(setup); | ||||
2449 | while (scr-- > 0) | ||||
2450 | xcb_screen_next(&iter); | ||||
2451 | screen = iter.data; | ||||
2452 | |||||
2453 | xcb_window = xcb_generate_id(connection); | ||||
2454 | |||||
2455 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; | ||||
2456 | value_list[0] = screen->black_pixel; | ||||
2457 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | | ||||
2458 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; | ||||
2459 | |||||
2460 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, | ||||
2461 | screen->root, 0, 0, width, height, 0, | ||||
2462 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, | ||||
2463 | value_mask, value_list); | ||||
2464 | |||||
2465 | /* Magic code that will send notification when window is destroyed */ | ||||
2466 | xcb_intern_atom_cookie_t cookie = | ||||
2467 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); | ||||
2468 | xcb_intern_atom_reply_t *reply = | ||||
2469 | xcb_intern_atom_reply(connection, cookie, 0); | ||||
2470 | |||||
2471 | xcb_intern_atom_cookie_t cookie2 = | ||||
2472 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2473 | atom_wm_delete_window = xcb_intern_atom_reply(connection, cookie2, 0); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2474 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
2475 | (*reply).atom, 4, 32, 1, | ||||
2476 | &(*atom_wm_delete_window).atom); | ||||
2477 | free(reply); | ||||
2478 | |||||
2479 | xcb_map_window(connection, xcb_window); | ||||
2480 | |||||
2481 | // Force the x/y coordinates to 100,100 results are identical in consecutive | ||||
2482 | // runs | ||||
2483 | const uint32_t coords[] = {100, 100}; | ||||
2484 | xcb_configure_window(connection, xcb_window, | ||||
2485 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); | ||||
2486 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2487 | // Finally, try to correctly create a surface: |
2488 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; | ||||
2489 | xcb_create_info.pNext = NULL; | ||||
2490 | xcb_create_info.flags = 0; | ||||
2491 | xcb_create_info.connection = connection; | ||||
2492 | xcb_create_info.window = xcb_window; | ||||
2493 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); | ||||
2494 | pass = (err == VK_SUCCESS); | ||||
2495 | ASSERT_TRUE(pass); | ||||
2496 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2497 | // Check if surface supports presentation: |
2498 | |||||
2499 | // 1st, do so without having queried the queue families: | ||||
2500 | VkBool32 supported = false; | ||||
2501 | // TODO: Get the following error to come out: | ||||
2502 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2503 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2504 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " | ||||
2505 | "function"); | ||||
2506 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); | ||||
2507 | pass = (err != VK_SUCCESS); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2508 | // ASSERT_TRUE(pass); |
2509 | // m_errorMonitor->VerifyFound(); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2510 | |
2511 | // Next, query a queue family index that's too large: | ||||
2512 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2513 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2514 | "called with a queueFamilyIndex that is too large"); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2515 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, |
2516 | &supported); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2517 | pass = (err != VK_SUCCESS); |
2518 | ASSERT_TRUE(pass); | ||||
2519 | m_errorMonitor->VerifyFound(); | ||||
2520 | |||||
2521 | // Finally, do so correctly: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2522 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
2523 | // SUPPORTED | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2524 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
2525 | pass = (err == VK_SUCCESS); | ||||
2526 | ASSERT_TRUE(pass); | ||||
2527 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2528 | // Before proceeding, try to create a swapchain without having called |
2529 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): | ||||
2530 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; | ||||
2531 | swapchain_create_info.pNext = NULL; | ||||
2532 | swapchain_create_info.flags = 0; | ||||
2533 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2534 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2535 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2536 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
2537 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2538 | pass = (err != VK_SUCCESS); |
2539 | ASSERT_TRUE(pass); | ||||
2540 | m_errorMonitor->VerifyFound(); | ||||
2541 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2542 | // Get the surface capabilities: |
2543 | VkSurfaceCapabilitiesKHR surface_capabilities; | ||||
2544 | |||||
2545 | // Do so correctly (only error logged by this entrypoint is if the | ||||
2546 | // extension isn't enabled): | ||||
2547 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, | ||||
2548 | &surface_capabilities); | ||||
2549 | pass = (err == VK_SUCCESS); | ||||
2550 | ASSERT_TRUE(pass); | ||||
2551 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2552 | // Get the surface formats: |
2553 | uint32_t surface_format_count; | ||||
2554 | |||||
2555 | // First, try without a pointer to surface_format_count: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2556 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2557 | "called with NULL pointer"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2558 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
2559 | pass = (err == VK_SUCCESS); | ||||
2560 | ASSERT_TRUE(pass); | ||||
2561 | m_errorMonitor->VerifyFound(); | ||||
2562 | |||||
2563 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't | ||||
2564 | // correctly done a 1st try (to get the count): | ||||
2565 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2566 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2567 | "but no prior positive value has been seen for"); | ||||
2568 | surface_format_count = 0; | ||||
2569 | vkGetPhysicalDeviceSurfaceFormatsKHR( | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2570 | gpu(), surface, &surface_format_count, |
2571 | (VkSurfaceFormatKHR *)&surface_format_count); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2572 | pass = (err == VK_SUCCESS); |
2573 | ASSERT_TRUE(pass); | ||||
2574 | m_errorMonitor->VerifyFound(); | ||||
2575 | |||||
2576 | // 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] | 2577 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
2578 | NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2579 | pass = (err == VK_SUCCESS); |
2580 | ASSERT_TRUE(pass); | ||||
2581 | |||||
2582 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2583 | VkSurfaceFormatKHR *surface_formats = (VkSurfaceFormatKHR *)malloc( |
2584 | surface_format_count * sizeof(VkSurfaceFormatKHR)); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2585 | |
2586 | // Next, do a 2nd try with surface_format_count being set too high: | ||||
2587 | surface_format_count += 5; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2588 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2589 | "that is greater than the value"); | ||||
2590 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2591 | surface_formats); |
2592 | pass = (err == VK_SUCCESS); | ||||
2593 | ASSERT_TRUE(pass); | ||||
2594 | m_errorMonitor->VerifyFound(); | ||||
2595 | |||||
2596 | // Finally, do a correct 1st and 2nd try: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2597 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
2598 | NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2599 | pass = (err == VK_SUCCESS); |
2600 | ASSERT_TRUE(pass); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2601 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2602 | surface_formats); |
2603 | pass = (err == VK_SUCCESS); | ||||
2604 | ASSERT_TRUE(pass); | ||||
2605 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2606 | // Get the surface present modes: |
2607 | uint32_t surface_present_mode_count; | ||||
2608 | |||||
2609 | // First, try without a pointer to surface_format_count: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2610 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2611 | "called with NULL pointer"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2612 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
2613 | pass = (err == VK_SUCCESS); | ||||
2614 | ASSERT_TRUE(pass); | ||||
2615 | m_errorMonitor->VerifyFound(); | ||||
2616 | |||||
2617 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't | ||||
2618 | // correctly done a 1st try (to get the count): | ||||
2619 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2620 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2621 | "but no prior positive value has been seen for"); | ||||
2622 | surface_present_mode_count = 0; | ||||
2623 | vkGetPhysicalDeviceSurfacePresentModesKHR( | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2624 | gpu(), surface, &surface_present_mode_count, |
2625 | (VkPresentModeKHR *)&surface_present_mode_count); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2626 | pass = (err == VK_SUCCESS); |
2627 | ASSERT_TRUE(pass); | ||||
2628 | m_errorMonitor->VerifyFound(); | ||||
2629 | |||||
2630 | // 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] | 2631 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
2632 | gpu(), surface, &surface_present_mode_count, NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2633 | pass = (err == VK_SUCCESS); |
2634 | ASSERT_TRUE(pass); | ||||
2635 | |||||
2636 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2637 | VkPresentModeKHR *surface_present_modes = (VkPresentModeKHR *)malloc( |
2638 | surface_present_mode_count * sizeof(VkPresentModeKHR)); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2639 | |
2640 | // Next, do a 2nd try with surface_format_count being set too high: | ||||
2641 | surface_present_mode_count += 5; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2642 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2643 | "that is greater than the value"); | ||||
2644 | vkGetPhysicalDeviceSurfacePresentModesKHR( | ||||
2645 | gpu(), surface, &surface_present_mode_count, surface_present_modes); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2646 | pass = (err == VK_SUCCESS); |
2647 | ASSERT_TRUE(pass); | ||||
2648 | m_errorMonitor->VerifyFound(); | ||||
2649 | |||||
2650 | // Finally, do a correct 1st and 2nd try: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2651 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
2652 | gpu(), surface, &surface_present_mode_count, NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2653 | pass = (err == VK_SUCCESS); |
2654 | ASSERT_TRUE(pass); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2655 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
2656 | gpu(), surface, &surface_present_mode_count, surface_present_modes); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2657 | pass = (err == VK_SUCCESS); |
2658 | ASSERT_TRUE(pass); | ||||
2659 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2660 | // Create a swapchain: |
2661 | |||||
2662 | // First, try without a pointer to swapchain_create_info: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2663 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2664 | "called with NULL pointer"); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2665 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
2666 | pass = (err != VK_SUCCESS); | ||||
2667 | ASSERT_TRUE(pass); | ||||
2668 | m_errorMonitor->VerifyFound(); | ||||
2669 | |||||
2670 | // Next, call with a non-NULL swapchain_create_info, that has the wrong | ||||
2671 | // sType: | ||||
2672 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2673 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2674 | "called with the wrong value for"); | ||||
2675 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, | ||||
2676 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2677 | pass = (err != VK_SUCCESS); |
2678 | ASSERT_TRUE(pass); | ||||
2679 | m_errorMonitor->VerifyFound(); | ||||
2680 | |||||
2681 | // Next, call with a NULL swapchain pointer: | ||||
2682 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; | ||||
2683 | swapchain_create_info.pNext = NULL; | ||||
2684 | swapchain_create_info.flags = 0; | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2685 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
2686 | "called with NULL pointer"); | ||||
2687 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, | ||||
2688 | NULL); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2689 | pass = (err != VK_SUCCESS); |
2690 | ASSERT_TRUE(pass); | ||||
2691 | m_errorMonitor->VerifyFound(); | ||||
2692 | |||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2693 | // TODO: Enhance swapchain layer so that |
2694 | // swapchain_create_info.queueFamilyIndexCount is checked against something? | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2695 | |
2696 | // Next, call with a queue family index that's too large: | ||||
2697 | uint32_t queueFamilyIndex[2] = {100000, 0}; | ||||
2698 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; | ||||
2699 | swapchain_create_info.queueFamilyIndexCount = 2; | ||||
2700 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; | ||||
2701 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2702 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2703 | "called with a queueFamilyIndex that is too large"); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2704 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
2705 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2706 | pass = (err != VK_SUCCESS); |
2707 | ASSERT_TRUE(pass); | ||||
2708 | m_errorMonitor->VerifyFound(); | ||||
2709 | |||||
2710 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: | ||||
2711 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; | ||||
2712 | swapchain_create_info.queueFamilyIndexCount = 1; | ||||
2713 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2714 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2715 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " | ||||
2716 | "pCreateInfo->pQueueFamilyIndices)."); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2717 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
2718 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2719 | pass = (err != VK_SUCCESS); |
2720 | ASSERT_TRUE(pass); | ||||
2721 | m_errorMonitor->VerifyFound(); | ||||
2722 | |||||
2723 | // Next, call with an invalid imageSharingMode: | ||||
2724 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; | ||||
2725 | swapchain_create_info.queueFamilyIndexCount = 1; | ||||
2726 | m_errorMonitor->SetDesiredFailureMsg( | ||||
2727 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
2728 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2729 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
2730 | &swapchain); | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2731 | pass = (err != VK_SUCCESS); |
2732 | ASSERT_TRUE(pass); | ||||
2733 | m_errorMonitor->VerifyFound(); | ||||
2734 | // Fix for the future: | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2735 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
2736 | // SUPPORTED | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2737 | swapchain_create_info.queueFamilyIndexCount = 0; |
2738 | queueFamilyIndex[0] = 0; | ||||
2739 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
2740 | |||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2741 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2742 | // Get the images from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2743 | // Acquire an image from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2744 | // Present an image to a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2745 | // Destroy the swapchain: |
2746 | |||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2747 | // TODOs: |
2748 | // | ||||
2749 | // - Try destroying the device without first destroying the swapchain | ||||
2750 | // | ||||
2751 | // - Try destroying the device without first destroying the surface | ||||
2752 | // | ||||
2753 | // - Try destroying the surface without first destroying the swapchain | ||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2754 | |
2755 | // Destroy the surface: | ||||
2756 | vkDestroySurfaceKHR(instance(), surface, NULL); | ||||
2757 | |||||
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2758 | // Tear down the window: |
2759 | xcb_destroy_window(connection, xcb_window); | ||||
2760 | xcb_disconnect(connection); | ||||
2761 | |||||
2762 | #else // VK_USE_PLATFORM_XCB_KHR | ||||
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2763 | return; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2764 | #endif // VK_USE_PLATFORM_XCB_KHR |
2765 | } | ||||
2766 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2767 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
2768 | VkResult err; | ||||
2769 | bool pass; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2770 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2771 | m_errorMonitor->SetDesiredFailureMsg( |
2772 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2773 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
2774 | |||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2775 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2776 | |
2777 | // 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] | 2778 | VkImage image; |
2779 | VkDeviceMemory mem; | ||||
2780 | VkMemoryRequirements mem_reqs; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2781 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2782 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
2783 | const int32_t tex_width = 32; | ||||
2784 | const int32_t tex_height = 32; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2785 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2786 | VkImageCreateInfo image_create_info = {}; |
2787 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2788 | image_create_info.pNext = NULL; |
2789 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
2790 | image_create_info.format = tex_format; | ||||
2791 | image_create_info.extent.width = tex_width; | ||||
2792 | image_create_info.extent.height = tex_height; | ||||
2793 | image_create_info.extent.depth = 1; | ||||
2794 | image_create_info.mipLevels = 1; | ||||
2795 | image_create_info.arrayLayers = 1; | ||||
2796 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
2797 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
2798 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
2799 | image_create_info.flags = 0; | ||||
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2800 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2801 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2802 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2803 | mem_alloc.pNext = NULL; |
2804 | mem_alloc.allocationSize = 0; | ||||
2805 | // Introduce failure, do NOT set memProps to | ||||
2806 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | ||||
2807 | mem_alloc.memoryTypeIndex = 1; | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2808 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2809 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2810 | ASSERT_VK_SUCCESS(err); |
2811 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2812 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2813 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2814 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2815 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2816 | pass = |
2817 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, | ||||
2818 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
2819 | if (!pass) { // If we can't find any unmappable memory this test doesn't | ||||
2820 | // make sense | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2821 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2822 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2823 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2824 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2825 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2826 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2827 | ASSERT_VK_SUCCESS(err); |
2828 | |||||
2829 | // Try to bind free memory that has been freed | ||||
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2830 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2831 | ASSERT_VK_SUCCESS(err); |
2832 | |||||
2833 | // Map memory as if to initialize the image | ||||
2834 | void *mappedAddress = NULL; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2835 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
2836 | &mappedAddress); | ||||
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2837 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2838 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2839 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2840 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 2841 | vkFreeMemory(m_device->device(), mem, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2842 | } |
2843 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2844 | TEST_F(VkLayerTest, RebindMemory) { |
2845 | VkResult err; | ||||
2846 | bool pass; | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2847 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2848 | m_errorMonitor->SetDesiredFailureMsg( |
2849 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2850 | "which has already been bound to mem object"); |
2851 | |||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2852 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2853 | |
2854 | // 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] | 2855 | VkImage image; |
2856 | VkDeviceMemory mem1; | ||||
2857 | VkDeviceMemory mem2; | ||||
2858 | VkMemoryRequirements mem_reqs; | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2859 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2860 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
2861 | const int32_t tex_width = 32; | ||||
2862 | const int32_t tex_height = 32; | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2863 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2864 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2865 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
2866 | image_create_info.pNext = NULL; | ||||
2867 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
2868 | image_create_info.format = tex_format; | ||||
2869 | image_create_info.extent.width = tex_width; | ||||
2870 | image_create_info.extent.height = tex_height; | ||||
2871 | image_create_info.extent.depth = 1; | ||||
2872 | image_create_info.mipLevels = 1; | ||||
2873 | image_create_info.arrayLayers = 1; | ||||
2874 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
2875 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
2876 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
2877 | image_create_info.flags = 0; | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2878 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2879 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2880 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
2881 | mem_alloc.pNext = NULL; | ||||
2882 | mem_alloc.allocationSize = 0; | ||||
2883 | mem_alloc.memoryTypeIndex = 0; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2884 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2885 | // Introduce failure, do NOT set memProps to |
2886 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2887 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2888 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2889 | ASSERT_VK_SUCCESS(err); |
2890 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2891 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2892 | |
2893 | mem_alloc.allocationSize = mem_reqs.size; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2894 | pass = |
2895 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2896 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2897 | |
2898 | // allocate 2 memory objects | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2899 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2900 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2901 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2902 | ASSERT_VK_SUCCESS(err); |
2903 | |||||
2904 | // Bind first memory object to Image object | ||||
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2905 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2906 | ASSERT_VK_SUCCESS(err); |
2907 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2908 | // Introduce validation failure, try to bind a different memory object to |
2909 | // the same image object | ||||
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2910 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2911 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2912 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2913 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2914 | vkDestroyImage(m_device->device(), image, NULL); |
2915 | vkFreeMemory(m_device->device(), mem1, NULL); | ||||
2916 | vkFreeMemory(m_device->device(), mem2, NULL); | ||||
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2917 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2918 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2919 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2920 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2921 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2922 | m_errorMonitor->SetDesiredFailureMsg( |
2923 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " | ||||
2924 | "must be reset before being submitted"); | ||||
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2925 | |
2926 | VkFenceCreateInfo fenceInfo = {}; | ||||
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2927 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
2928 | fenceInfo.pNext = NULL; | ||||
2929 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2930 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2931 | ASSERT_NO_FATAL_FAILURE(InitState()); |
2932 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
2933 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
2934 | |||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2935 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2936 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
2937 | m_stencil_clear_color, NULL); | ||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2938 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2939 | |
2940 | testFence.init(*m_device, fenceInfo); | ||||
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2941 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2942 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2943 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
2944 | submit_info.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2945 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2946 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2947 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2948 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2949 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2950 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2951 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2952 | |
2953 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2954 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2955 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2956 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2957 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2958 | // This is a positive test. We used to expect error in this case but spec now |
2959 | // allows it | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2960 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2961 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2962 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2963 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2964 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
2965 | fenceInfo.pNext = NULL; | ||||
2966 | |||||
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2967 | ASSERT_NO_FATAL_FAILURE(InitState()); |
2968 | testFence.init(*m_device, fenceInfo); | ||||
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2969 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2970 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
2971 | ASSERT_VK_SUCCESS(result); | ||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2972 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2973 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2974 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2975 | |
Chris Forbes | e70b7d3 | 2016-06-15 15:49:12 +1200 | [diff] [blame] | 2976 | #if 0 |
2977 | TEST_F(VkLayerTest, LongFenceChain) | ||||
2978 | { | ||||
2979 | m_errorMonitor->ExpectSuccess(); | ||||
2980 | |||||
2981 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
2982 | VkResult err; | ||||
2983 | |||||
2984 | std::vector<VkFence> fences; | ||||
2985 | |||||
2986 | const int chainLength = 32768; | ||||
2987 | |||||
2988 | for (int i = 0; i < chainLength; i++) { | ||||
2989 | VkFenceCreateInfo fci = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, 0 }; | ||||
2990 | VkFence fence; | ||||
2991 | err = vkCreateFence(m_device->device(), &fci, nullptr, &fence); | ||||
2992 | ASSERT_VK_SUCCESS(err); | ||||
2993 | |||||
2994 | fences.push_back(fence); | ||||
2995 | |||||
2996 | VkSubmitInfo si = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, 0, nullptr, nullptr, | ||||
2997 | 0, nullptr, 0, nullptr }; | ||||
2998 | err = vkQueueSubmit(m_device->m_queue, 1, &si, fence); | ||||
2999 | ASSERT_VK_SUCCESS(err); | ||||
3000 | |||||
3001 | } | ||||
3002 | |||||
3003 | // BOOM, stack overflow. | ||||
3004 | vkWaitForFences(m_device->device(), 1, &fences.back(), VK_TRUE, UINT64_MAX); | ||||
3005 | |||||
3006 | for (auto fence : fences) | ||||
3007 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
3008 | |||||
3009 | m_errorMonitor->VerifyNotFound(); | ||||
3010 | } | ||||
3011 | #endif | ||||
3012 | |||||
Chris Forbes | 18127d1 | 2016-06-08 16:52:28 +1200 | [diff] [blame] | 3013 | TEST_F(VkLayerTest, CommandBufferSimultaneousUseSync) |
3014 | { | ||||
3015 | m_errorMonitor->ExpectSuccess(); | ||||
3016 | |||||
3017 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3018 | VkResult err; | ||||
3019 | |||||
3020 | // Record (empty!) command buffer that can be submitted multiple times | ||||
3021 | // simultaneously. | ||||
3022 | VkCommandBufferBeginInfo cbbi = { | ||||
3023 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, | ||||
3024 | VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT, nullptr | ||||
3025 | }; | ||||
3026 | m_commandBuffer->BeginCommandBuffer(&cbbi); | ||||
3027 | m_commandBuffer->EndCommandBuffer(); | ||||
3028 | |||||
3029 | VkFenceCreateInfo fci = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, 0 }; | ||||
3030 | VkFence fence; | ||||
3031 | err = vkCreateFence(m_device->device(), &fci, nullptr, &fence); | ||||
3032 | ASSERT_VK_SUCCESS(err); | ||||
3033 | |||||
3034 | VkSemaphoreCreateInfo sci = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, nullptr, 0 }; | ||||
3035 | VkSemaphore s1, s2; | ||||
3036 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s1); | ||||
3037 | ASSERT_VK_SUCCESS(err); | ||||
3038 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s2); | ||||
3039 | ASSERT_VK_SUCCESS(err); | ||||
3040 | |||||
3041 | // Submit CB once signaling s1, with fence so we can roll forward to its retirement. | ||||
3042 | VkSubmitInfo si = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, 0, nullptr, nullptr, | ||||
3043 | 1, &m_commandBuffer->handle(), 1, &s1 }; | ||||
3044 | err = vkQueueSubmit(m_device->m_queue, 1, &si, fence); | ||||
3045 | ASSERT_VK_SUCCESS(err); | ||||
3046 | |||||
3047 | // Submit CB again, signaling s2. | ||||
3048 | si.pSignalSemaphores = &s2; | ||||
3049 | err = vkQueueSubmit(m_device->m_queue, 1, &si, VK_NULL_HANDLE); | ||||
3050 | ASSERT_VK_SUCCESS(err); | ||||
3051 | |||||
3052 | // Wait for fence. | ||||
3053 | err = vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
3054 | ASSERT_VK_SUCCESS(err); | ||||
3055 | |||||
3056 | // CB is still in flight from second submission, but semaphore s1 is no | ||||
3057 | // longer in flight. delete it. | ||||
3058 | vkDestroySemaphore(m_device->device(), s1, nullptr); | ||||
3059 | |||||
3060 | m_errorMonitor->VerifyNotFound(); | ||||
3061 | |||||
3062 | // Force device idle and clean up remaining objects | ||||
3063 | vkDeviceWaitIdle(m_device->device()); | ||||
3064 | vkDestroySemaphore(m_device->device(), s2, nullptr); | ||||
3065 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
3066 | } | ||||
3067 | |||||
Chris Forbes | 4e44c91 | 2016-06-16 10:20:00 +1200 | [diff] [blame] | 3068 | TEST_F(VkLayerTest, FenceCreateSignaledWaitHandling) |
3069 | { | ||||
3070 | m_errorMonitor->ExpectSuccess(); | ||||
3071 | |||||
3072 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3073 | VkResult err; | ||||
3074 | |||||
3075 | // A fence created signaled | ||||
3076 | VkFenceCreateInfo fci1 = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, VK_FENCE_CREATE_SIGNALED_BIT }; | ||||
3077 | VkFence f1; | ||||
3078 | err = vkCreateFence(m_device->device(), &fci1, nullptr, &f1); | ||||
3079 | ASSERT_VK_SUCCESS(err); | ||||
3080 | |||||
3081 | // A fence created not | ||||
3082 | VkFenceCreateInfo fci2 = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, nullptr, 0 }; | ||||
3083 | VkFence f2; | ||||
3084 | err = vkCreateFence(m_device->device(), &fci2, nullptr, &f2); | ||||
3085 | ASSERT_VK_SUCCESS(err); | ||||
3086 | |||||
3087 | // Submit the unsignaled fence | ||||
3088 | VkSubmitInfo si = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, 0, nullptr, nullptr, | ||||
3089 | 0, nullptr, 0, nullptr }; | ||||
3090 | err = vkQueueSubmit(m_device->m_queue, 1, &si, f2); | ||||
3091 | |||||
3092 | // Wait on both fences, with signaled first. | ||||
3093 | VkFence fences[] = { f1, f2 }; | ||||
3094 | vkWaitForFences(m_device->device(), 2, fences, VK_TRUE, UINT64_MAX); | ||||
3095 | |||||
3096 | // Should have both retired! | ||||
3097 | vkDestroyFence(m_device->device(), f1, nullptr); | ||||
3098 | vkDestroyFence(m_device->device(), f2, nullptr); | ||||
3099 | |||||
3100 | m_errorMonitor->VerifyNotFound(); | ||||
3101 | } | ||||
3102 | |||||
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 3103 | TEST_F(VkLayerTest, InvalidUsageBits) |
3104 | { | ||||
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 3105 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 3106 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 3107 | "Initialize buffer with wrong usage then perform copy expecting errors " |
3108 | "from both the image and the buffer (2 calls)"); | ||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3109 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3110 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 3111 | |
3112 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 3113 | VkImageObj image(m_device); |
3114 | // Initialize image with USAGE_INPUT_ATTACHMENT | ||||
Tobin Ehlis | 8b313c0 | 2016-05-25 15:01:52 -0600 | [diff] [blame] | 3115 | image.init(128, 128, VK_FORMAT_D24_UNORM_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 3116 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
3117 | ASSERT_TRUE(image.initialized()); | ||||
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 3118 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 3119 | VkImageView dsv; |
3120 | VkImageViewCreateInfo dsvci = {}; | ||||
3121 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
3122 | dsvci.image = image.handle(); | ||||
3123 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
3124 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; | ||||
3125 | dsvci.subresourceRange.layerCount = 1; | ||||
3126 | dsvci.subresourceRange.baseMipLevel = 0; | ||||
3127 | dsvci.subresourceRange.levelCount = 1; | ||||
3128 | dsvci.subresourceRange.aspectMask = | ||||
3129 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; | ||||
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 3130 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 3131 | // Create a view with depth / stencil aspect for image with different usage |
3132 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3133 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3134 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 3135 | |
3136 | // Initialize buffer with TRANSFER_DST usage | ||||
3137 | vk_testing::Buffer buffer; | ||||
3138 | VkMemoryPropertyFlags reqs = 0; | ||||
3139 | buffer.init_as_dst(*m_device, 128 * 128, reqs); | ||||
3140 | VkBufferImageCopy region = {}; | ||||
3141 | region.bufferRowLength = 128; | ||||
3142 | region.bufferImageHeight = 128; | ||||
3143 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
3144 | region.imageSubresource.layerCount = 1; | ||||
3145 | region.imageExtent.height = 16; | ||||
3146 | region.imageExtent.width = 16; | ||||
3147 | region.imageExtent.depth = 1; | ||||
3148 | |||||
3149 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
3150 | "Invalid usage flag for buffer "); | ||||
3151 | // Buffer usage not set to TRANSFER_SRC and image usage not set to | ||||
3152 | // TRANSFER_DST | ||||
3153 | BeginCommandBuffer(); | ||||
3154 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), | ||||
3155 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
3156 | 1, ®ion); | ||||
3157 | m_errorMonitor->VerifyFound(); | ||||
3158 | |||||
3159 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
3160 | "Invalid usage flag for image "); | ||||
3161 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), | ||||
3162 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
3163 | 1, ®ion); | ||||
3164 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 3165 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3166 | #endif // MEM_TRACKER_TESTS |
3167 | |||||
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 3168 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 3169 | |
3170 | TEST_F(VkLayerTest, LeakAnObject) { | ||||
3171 | VkResult err; | ||||
3172 | |||||
3173 | TEST_DESCRIPTION( | ||||
3174 | "Create a fence and destroy its device without first destroying the fence."); | ||||
3175 | |||||
3176 | // Note that we have to create a new device since destroying the | ||||
3177 | // framework's device causes Teardown() to fail and just calling Teardown | ||||
3178 | // will destroy the errorMonitor. | ||||
3179 | |||||
3180 | m_errorMonitor->SetDesiredFailureMsg( | ||||
3181 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 01714f5 | 2016-07-06 09:35:04 -0600 | [diff] [blame] | 3182 | "has not been destroyed."); |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 3183 | |
3184 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3185 | |||||
3186 | const std::vector<VkQueueFamilyProperties> queue_props = | ||||
3187 | m_device->queue_props; | ||||
3188 | std::vector<VkDeviceQueueCreateInfo> queue_info; | ||||
3189 | queue_info.reserve(queue_props.size()); | ||||
3190 | std::vector<std::vector<float>> queue_priorities; | ||||
3191 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { | ||||
3192 | VkDeviceQueueCreateInfo qi = {}; | ||||
3193 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; | ||||
3194 | qi.pNext = NULL; | ||||
3195 | qi.queueFamilyIndex = i; | ||||
3196 | qi.queueCount = queue_props[i].queueCount; | ||||
3197 | queue_priorities.emplace_back(qi.queueCount, 0.0f); | ||||
3198 | qi.pQueuePriorities = queue_priorities[i].data(); | ||||
3199 | queue_info.push_back(qi); | ||||
3200 | } | ||||
3201 | |||||
3202 | std::vector<const char *> device_layer_names; | ||||
3203 | std::vector<const char *> device_extension_names; | ||||
3204 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); | ||||
3205 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); | ||||
3206 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); | ||||
3207 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); | ||||
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 3208 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
3209 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); | ||||
3210 | |||||
3211 | // The sacrificial device object | ||||
3212 | VkDevice testDevice; | ||||
3213 | VkDeviceCreateInfo device_create_info = {}; | ||||
3214 | auto features = m_device->phy().features(); | ||||
3215 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; | ||||
3216 | device_create_info.pNext = NULL; | ||||
3217 | device_create_info.queueCreateInfoCount = queue_info.size(); | ||||
3218 | device_create_info.pQueueCreateInfos = queue_info.data(); | ||||
3219 | device_create_info.enabledLayerCount = device_layer_names.size(); | ||||
3220 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); | ||||
3221 | device_create_info.pEnabledFeatures = &features; | ||||
3222 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); | ||||
3223 | ASSERT_VK_SUCCESS(err); | ||||
3224 | |||||
3225 | VkFence fence; | ||||
3226 | VkFenceCreateInfo fence_create_info = {}; | ||||
3227 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
3228 | fence_create_info.pNext = NULL; | ||||
3229 | fence_create_info.flags = 0; | ||||
3230 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); | ||||
3231 | ASSERT_VK_SUCCESS(err); | ||||
3232 | |||||
3233 | // Induce failure by not calling vkDestroyFence | ||||
3234 | vkDestroyDevice(testDevice, NULL); | ||||
3235 | m_errorMonitor->VerifyFound(); | ||||
3236 | } | ||||
3237 | |||||
3238 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { | ||||
3239 | |||||
3240 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " | ||||
3241 | "attempt to delete them from another."); | ||||
3242 | |||||
3243 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
3244 | "FreeCommandBuffers is attempting to free Command Buffer"); | ||||
3245 | |||||
3246 | VkCommandPool command_pool_one; | ||||
3247 | VkCommandPool command_pool_two; | ||||
3248 | |||||
3249 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
3250 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3251 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3252 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3253 | |||||
3254 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3255 | &command_pool_one); | ||||
3256 | |||||
3257 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3258 | &command_pool_two); | ||||
3259 | |||||
3260 | VkCommandBuffer command_buffer[9]; | ||||
3261 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
3262 | command_buffer_allocate_info.sType = | ||||
3263 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3264 | command_buffer_allocate_info.commandPool = command_pool_one; | ||||
3265 | command_buffer_allocate_info.commandBufferCount = 9; | ||||
3266 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3267 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
3268 | command_buffer); | ||||
3269 | |||||
3270 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, | ||||
3271 | &command_buffer[3]); | ||||
3272 | |||||
3273 | m_errorMonitor->VerifyFound(); | ||||
3274 | |||||
3275 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); | ||||
3276 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); | ||||
3277 | } | ||||
3278 | |||||
3279 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { | ||||
3280 | VkResult err; | ||||
3281 | |||||
3282 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " | ||||
3283 | "attempt to delete them from another."); | ||||
3284 | |||||
3285 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
3286 | "FreeDescriptorSets is attempting to free descriptorSet"); | ||||
3287 | |||||
3288 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3289 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
3290 | |||||
3291 | VkDescriptorPoolSize ds_type_count = {}; | ||||
3292 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
3293 | ds_type_count.descriptorCount = 1; | ||||
3294 | |||||
3295 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
3296 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
3297 | ds_pool_ci.pNext = NULL; | ||||
3298 | ds_pool_ci.flags = 0; | ||||
3299 | ds_pool_ci.maxSets = 1; | ||||
3300 | ds_pool_ci.poolSizeCount = 1; | ||||
3301 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
3302 | |||||
3303 | VkDescriptorPool ds_pool_one; | ||||
3304 | err = | ||||
3305 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); | ||||
3306 | ASSERT_VK_SUCCESS(err); | ||||
3307 | |||||
3308 | // Create a second descriptor pool | ||||
3309 | VkDescriptorPool ds_pool_two; | ||||
3310 | err = | ||||
3311 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); | ||||
3312 | ASSERT_VK_SUCCESS(err); | ||||
3313 | |||||
3314 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
3315 | dsl_binding.binding = 0; | ||||
3316 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
3317 | dsl_binding.descriptorCount = 1; | ||||
3318 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
3319 | dsl_binding.pImmutableSamplers = NULL; | ||||
3320 | |||||
3321 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
3322 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
3323 | ds_layout_ci.pNext = NULL; | ||||
3324 | ds_layout_ci.bindingCount = 1; | ||||
3325 | ds_layout_ci.pBindings = &dsl_binding; | ||||
3326 | |||||
3327 | VkDescriptorSetLayout ds_layout; | ||||
3328 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
3329 | &ds_layout); | ||||
3330 | ASSERT_VK_SUCCESS(err); | ||||
3331 | |||||
3332 | VkDescriptorSet descriptorSet; | ||||
3333 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
3334 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
3335 | alloc_info.descriptorSetCount = 1; | ||||
3336 | alloc_info.descriptorPool = ds_pool_one; | ||||
3337 | alloc_info.pSetLayouts = &ds_layout; | ||||
3338 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
3339 | &descriptorSet); | ||||
3340 | ASSERT_VK_SUCCESS(err); | ||||
3341 | |||||
3342 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); | ||||
3343 | |||||
3344 | m_errorMonitor->VerifyFound(); | ||||
3345 | |||||
3346 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
3347 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); | ||||
3348 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); | ||||
3349 | } | ||||
3350 | |||||
3351 | TEST_F(VkLayerTest, CreateUnknownObject) { | ||||
3352 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 01714f5 | 2016-07-06 09:35:04 -0600 | [diff] [blame] | 3353 | "Invalid Image Object "); |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 3354 | |
3355 | TEST_DESCRIPTION( | ||||
3356 | "Pass an invalid image object handle into a Vulkan API call."); | ||||
3357 | |||||
3358 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3359 | |||||
3360 | // Pass bogus handle into GetImageMemoryRequirements | ||||
3361 | VkMemoryRequirements mem_reqs; | ||||
3362 | uint64_t fakeImageHandle = 0xCADECADE; | ||||
3363 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); | ||||
3364 | |||||
3365 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); | ||||
3366 | |||||
3367 | m_errorMonitor->VerifyFound(); | ||||
3368 | } | ||||
3369 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3370 | TEST_F(VkLayerTest, PipelineNotBound) { |
3371 | VkResult err; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3372 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 3373 | TEST_DESCRIPTION( |
3374 | "Pass in an invalid pipeline object handle into a Vulkan API call."); | ||||
3375 | |||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3376 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 01714f5 | 2016-07-06 09:35:04 -0600 | [diff] [blame] | 3377 | "Invalid Pipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3378 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3379 | ASSERT_NO_FATAL_FAILURE(InitState()); |
3380 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3381 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3382 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3383 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
3384 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3385 | |
3386 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3387 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
3388 | ds_pool_ci.pNext = NULL; | ||||
3389 | ds_pool_ci.maxSets = 1; | ||||
3390 | ds_pool_ci.poolSizeCount = 1; | ||||
3391 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3392 | |
3393 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3394 | err = |
3395 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3396 | ASSERT_VK_SUCCESS(err); |
3397 | |||||
3398 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3399 | dsl_binding.binding = 0; |
3400 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
3401 | dsl_binding.descriptorCount = 1; | ||||
3402 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
3403 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3404 | |
3405 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3406 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
3407 | ds_layout_ci.pNext = NULL; | ||||
3408 | ds_layout_ci.bindingCount = 1; | ||||
3409 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3410 | |
3411 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3412 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
3413 | &ds_layout); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3414 | ASSERT_VK_SUCCESS(err); |
3415 | |||||
3416 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3417 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3418 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3419 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3420 | alloc_info.descriptorPool = ds_pool; |
3421 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3422 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
3423 | &descriptorSet); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3424 | ASSERT_VK_SUCCESS(err); |
3425 | |||||
3426 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3427 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
3428 | pipeline_layout_ci.pNext = NULL; | ||||
3429 | pipeline_layout_ci.setLayoutCount = 1; | ||||
3430 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3431 | |
3432 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3433 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
3434 | &pipeline_layout); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3435 | ASSERT_VK_SUCCESS(err); |
3436 | |||||
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 3437 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3438 | |
3439 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3440 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
3441 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); | ||||
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3442 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3443 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3444 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3445 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
3446 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
3447 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3448 | } |
Mike Stroyan | 80fc6c3 | 2016-06-20 15:42:29 -0600 | [diff] [blame] | 3449 | |
Mark Lobodzinski | bc18576 | 2016-06-15 16:28:53 -0600 | [diff] [blame] | 3450 | TEST_F(VkLayerTest, BindImageInvalidMemoryType) { |
3451 | VkResult err; | ||||
3452 | |||||
3453 | TEST_DESCRIPTION("Test validation check for an invalid memory type index " | ||||
3454 | "during bind[Buffer|Image]Memory time"); | ||||
3455 | |||||
Mark Lobodzinski | bc18576 | 2016-06-15 16:28:53 -0600 | [diff] [blame] | 3456 | ASSERT_NO_FATAL_FAILURE(InitState()); |
3457 | |||||
3458 | // Create an image, allocate memory, set a bad typeIndex and then try to | ||||
3459 | // bind it | ||||
3460 | VkImage image; | ||||
3461 | VkDeviceMemory mem; | ||||
3462 | VkMemoryRequirements mem_reqs; | ||||
3463 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
3464 | const int32_t tex_width = 32; | ||||
3465 | const int32_t tex_height = 32; | ||||
3466 | |||||
3467 | VkImageCreateInfo image_create_info = {}; | ||||
3468 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
3469 | image_create_info.pNext = NULL; | ||||
3470 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
3471 | image_create_info.format = tex_format; | ||||
3472 | image_create_info.extent.width = tex_width; | ||||
3473 | image_create_info.extent.height = tex_height; | ||||
3474 | image_create_info.extent.depth = 1; | ||||
3475 | image_create_info.mipLevels = 1; | ||||
3476 | image_create_info.arrayLayers = 1; | ||||
3477 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
3478 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
3479 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
3480 | image_create_info.flags = 0; | ||||
3481 | |||||
3482 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
3483 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
3484 | mem_alloc.pNext = NULL; | ||||
3485 | mem_alloc.allocationSize = 0; | ||||
3486 | mem_alloc.memoryTypeIndex = 0; | ||||
3487 | |||||
3488 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
3489 | ASSERT_VK_SUCCESS(err); | ||||
3490 | |||||
3491 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
3492 | mem_alloc.allocationSize = mem_reqs.size; | ||||
Mike Stroyan | 80fc6c3 | 2016-06-20 15:42:29 -0600 | [diff] [blame] | 3493 | |
3494 | // Introduce Failure, select invalid TypeIndex | ||||
3495 | VkPhysicalDeviceMemoryProperties memory_info; | ||||
3496 | |||||
3497 | vkGetPhysicalDeviceMemoryProperties(gpu(), &memory_info); | ||||
3498 | unsigned int i; | ||||
3499 | for (i = 0; i < memory_info.memoryTypeCount; i++) { | ||||
3500 | if ((mem_reqs.memoryTypeBits & (1 << i)) == 0) { | ||||
3501 | mem_alloc.memoryTypeIndex = i; | ||||
3502 | break; | ||||
3503 | } | ||||
3504 | } | ||||
3505 | if (i >= memory_info.memoryTypeCount) { | ||||
3506 | printf("No invalid memory type index could be found; skipped.\n"); | ||||
3507 | vkDestroyImage(m_device->device(), image, NULL); | ||||
3508 | return; | ||||
3509 | } | ||||
3510 | |||||
3511 | m_errorMonitor->SetDesiredFailureMsg( | ||||
3512 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
3513 | "for this object type are not compatible with the memory"); | ||||
Mark Lobodzinski | bc18576 | 2016-06-15 16:28:53 -0600 | [diff] [blame] | 3514 | |
3515 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); | ||||
3516 | ASSERT_VK_SUCCESS(err); | ||||
3517 | |||||
3518 | err = vkBindImageMemory(m_device->device(), image, mem, 0); | ||||
3519 | (void)err; | ||||
3520 | |||||
3521 | m_errorMonitor->VerifyFound(); | ||||
3522 | |||||
3523 | vkDestroyImage(m_device->device(), image, NULL); | ||||
3524 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
3525 | } | ||||
Mike Stroyan | 80fc6c3 | 2016-06-20 15:42:29 -0600 | [diff] [blame] | 3526 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3527 | TEST_F(VkLayerTest, BindInvalidMemory) { |
3528 | VkResult err; | ||||
3529 | bool pass; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3530 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3531 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 01714f5 | 2016-07-06 09:35:04 -0600 | [diff] [blame] | 3532 | "Invalid Device Memory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3533 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3534 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3535 | |
3536 | // 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] | 3537 | VkImage image; |
3538 | VkDeviceMemory mem; | ||||
3539 | VkMemoryRequirements mem_reqs; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3540 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3541 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
3542 | const int32_t tex_width = 32; | ||||
3543 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3544 | |
3545 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3546 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
3547 | image_create_info.pNext = NULL; | ||||
3548 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
3549 | image_create_info.format = tex_format; | ||||
3550 | image_create_info.extent.width = tex_width; | ||||
3551 | image_create_info.extent.height = tex_height; | ||||
3552 | image_create_info.extent.depth = 1; | ||||
3553 | image_create_info.mipLevels = 1; | ||||
3554 | image_create_info.arrayLayers = 1; | ||||
3555 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
3556 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
3557 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
3558 | image_create_info.flags = 0; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3559 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3560 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3561 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
3562 | mem_alloc.pNext = NULL; | ||||
3563 | mem_alloc.allocationSize = 0; | ||||
3564 | mem_alloc.memoryTypeIndex = 0; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3565 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3566 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3567 | ASSERT_VK_SUCCESS(err); |
3568 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3569 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3570 | |
3571 | mem_alloc.allocationSize = mem_reqs.size; | ||||
3572 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3573 | pass = |
3574 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 3575 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3576 | |
3577 | // allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3578 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3579 | ASSERT_VK_SUCCESS(err); |
3580 | |||||
3581 | // Introduce validation failure, free memory before binding | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3582 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3583 | |
3584 | // Try to bind free memory that has been freed | ||||
3585 | err = vkBindImageMemory(m_device->device(), image, mem, 0); | ||||
3586 | // This may very well return an error. | ||||
3587 | (void)err; | ||||
3588 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3589 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3590 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3591 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3592 | } |
3593 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3594 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
3595 | VkResult err; | ||||
3596 | bool pass; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3597 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3598 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 01714f5 | 2016-07-06 09:35:04 -0600 | [diff] [blame] | 3599 | "Invalid Image Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3600 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3601 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3602 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3603 | // Create an image object, allocate memory, destroy the object and then try |
3604 | // to bind it | ||||
3605 | VkImage image; | ||||
3606 | VkDeviceMemory mem; | ||||
3607 | VkMemoryRequirements mem_reqs; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3608 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3609 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
3610 | const int32_t tex_width = 32; | ||||
3611 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3612 | |
3613 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3614 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
3615 | image_create_info.pNext = NULL; | ||||
3616 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
3617 | image_create_info.format = tex_format; | ||||
3618 | image_create_info.extent.width = tex_width; | ||||
3619 | image_create_info.extent.height = tex_height; | ||||
3620 | image_create_info.extent.depth = 1; | ||||
3621 | image_create_info.mipLevels = 1; | ||||
3622 | image_create_info.arrayLayers = 1; | ||||
3623 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
3624 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
3625 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
3626 | image_create_info.flags = 0; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3627 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3628 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3629 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
3630 | mem_alloc.pNext = NULL; | ||||
3631 | mem_alloc.allocationSize = 0; | ||||
3632 | mem_alloc.memoryTypeIndex = 0; | ||||
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3633 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3634 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3635 | ASSERT_VK_SUCCESS(err); |
3636 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3637 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3638 | |
3639 | mem_alloc.allocationSize = mem_reqs.size; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3640 | pass = |
3641 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 3642 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3643 | |
3644 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3645 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3646 | ASSERT_VK_SUCCESS(err); |
3647 | |||||
3648 | // Introduce validation failure, destroy Image object before binding | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3649 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3650 | ASSERT_VK_SUCCESS(err); |
3651 | |||||
3652 | // Now Try to bind memory to this destroyed object | ||||
3653 | err = vkBindImageMemory(m_device->device(), image, mem, 0); | ||||
3654 | // This may very well return an error. | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3655 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 3656 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3657 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3658 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3659 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3660 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3661 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3662 | #endif // OBJ_TRACKER_TESTS |
3663 | |||||
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 3664 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3665 | |
Chris Forbes | 48a5390 | 2016-06-30 11:46:27 +1200 | [diff] [blame] | 3666 | TEST_F(VkLayerTest, RenderPassInitialLayoutUndefined) { |
3667 | TEST_DESCRIPTION("Ensure that CmdBeginRenderPass with an attachment's " | ||||
3668 | "initialLayout of VK_IMAGE_LAYOUT_UNDEFINED works when " | ||||
3669 | "the command buffer has prior knowledge of that " | ||||
3670 | "attachment's layout."); | ||||
3671 | |||||
3672 | m_errorMonitor->ExpectSuccess(); | ||||
3673 | |||||
3674 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3675 | |||||
3676 | // A renderpass with one color attachment. | ||||
3677 | VkAttachmentDescription attachment = { | ||||
3678 | 0, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, | ||||
3679 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_STORE, | ||||
3680 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
3681 | VK_IMAGE_LAYOUT_UNDEFINED, | ||||
3682 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
3683 | }; | ||||
3684 | |||||
3685 | VkAttachmentReference att_ref = { | ||||
3686 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
3687 | }; | ||||
3688 | |||||
3689 | VkSubpassDescription subpass = { | ||||
3690 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, | ||||
3691 | 1, &att_ref, nullptr, nullptr, 0, nullptr | ||||
3692 | }; | ||||
3693 | |||||
3694 | VkRenderPassCreateInfo rpci = { | ||||
3695 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
3696 | 0, 1, &attachment, 1, &subpass, 0, nullptr | ||||
3697 | }; | ||||
3698 | |||||
3699 | VkRenderPass rp; | ||||
3700 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
3701 | ASSERT_VK_SUCCESS(err); | ||||
3702 | |||||
3703 | // A compatible framebuffer. | ||||
3704 | VkImageObj image(m_device); | ||||
3705 | image.init(32, 32, VK_FORMAT_R8G8B8A8_UNORM, | ||||
3706 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, | ||||
3707 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
3708 | ASSERT_TRUE(image.initialized()); | ||||
3709 | |||||
3710 | VkImageViewCreateInfo ivci = { | ||||
3711 | VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, nullptr, | ||||
3712 | 0, image.handle(), VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM, | ||||
3713 | { | ||||
3714 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3715 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3716 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3717 | VK_COMPONENT_SWIZZLE_IDENTITY | ||||
3718 | }, | ||||
3719 | { | ||||
3720 | VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 | ||||
3721 | }, | ||||
3722 | }; | ||||
3723 | VkImageView view; | ||||
3724 | err = vkCreateImageView(m_device->device(), &ivci, nullptr, &view); | ||||
3725 | ASSERT_VK_SUCCESS(err); | ||||
3726 | |||||
3727 | VkFramebufferCreateInfo fci = { | ||||
3728 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, | ||||
3729 | 0, rp, 1, &view, | ||||
3730 | 32, 32, 1 | ||||
3731 | }; | ||||
3732 | VkFramebuffer fb; | ||||
3733 | err = vkCreateFramebuffer(m_device->device(), &fci, nullptr, &fb); | ||||
3734 | ASSERT_VK_SUCCESS(err); | ||||
3735 | |||||
3736 | // Record a single command buffer which uses this renderpass twice. The | ||||
3737 | // bug is triggered at the beginning of the second renderpass, when the | ||||
3738 | // command buffer already has a layout recorded for the attachment. | ||||
3739 | VkRenderPassBeginInfo rpbi = { | ||||
3740 | VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, | ||||
Tobin Ehlis | 0f9aa40 | 2016-07-01 08:47:12 -0600 | [diff] [blame] | 3741 | rp, fb, { { 0, 0 } , { 32, 32 } }, |
Chris Forbes | 48a5390 | 2016-06-30 11:46:27 +1200 | [diff] [blame] | 3742 | 0, nullptr |
3743 | }; | ||||
3744 | BeginCommandBuffer(); | ||||
3745 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, | ||||
3746 | VK_SUBPASS_CONTENTS_INLINE); | ||||
3747 | vkCmdEndRenderPass(m_commandBuffer->handle()); | ||||
3748 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, | ||||
3749 | VK_SUBPASS_CONTENTS_INLINE); | ||||
3750 | |||||
3751 | m_errorMonitor->VerifyNotFound(); | ||||
3752 | |||||
3753 | vkCmdEndRenderPass(m_commandBuffer->handle()); | ||||
3754 | EndCommandBuffer(); | ||||
3755 | |||||
3756 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); | ||||
3757 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
3758 | vkDestroyImageView(m_device->device(), view, nullptr); | ||||
3759 | } | ||||
3760 | |||||
Tobin Ehlis | 75ac37b | 2016-07-29 10:55:41 -0600 | [diff] [blame] | 3761 | TEST_F(VkLayerTest, FramebufferBindingDestroyCommandPool) { |
3762 | TEST_DESCRIPTION("This test should pass. Create a Framebuffer and " | ||||
3763 | "command buffer, bind them together, then destroy " | ||||
3764 | "command pool and framebuffer and verify there are no " | ||||
3765 | "errors."); | ||||
3766 | |||||
3767 | m_errorMonitor->ExpectSuccess(); | ||||
3768 | |||||
3769 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3770 | |||||
3771 | // A renderpass with one color attachment. | ||||
3772 | VkAttachmentDescription attachment = { | ||||
3773 | 0, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, | ||||
3774 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_STORE, | ||||
3775 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
3776 | VK_IMAGE_LAYOUT_UNDEFINED, | ||||
3777 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
3778 | }; | ||||
3779 | |||||
3780 | VkAttachmentReference att_ref = { | ||||
3781 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
3782 | }; | ||||
3783 | |||||
3784 | VkSubpassDescription subpass = { | ||||
3785 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, | ||||
3786 | 1, &att_ref, nullptr, nullptr, 0, nullptr | ||||
3787 | }; | ||||
3788 | |||||
3789 | VkRenderPassCreateInfo rpci = { | ||||
3790 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
3791 | 0, 1, &attachment, 1, &subpass, 0, nullptr | ||||
3792 | }; | ||||
3793 | |||||
3794 | VkRenderPass rp; | ||||
3795 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
3796 | ASSERT_VK_SUCCESS(err); | ||||
3797 | |||||
3798 | // A compatible framebuffer. | ||||
3799 | VkImageObj image(m_device); | ||||
3800 | image.init(32, 32, VK_FORMAT_R8G8B8A8_UNORM, | ||||
3801 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, | ||||
3802 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
3803 | ASSERT_TRUE(image.initialized()); | ||||
3804 | |||||
3805 | VkImageViewCreateInfo ivci = { | ||||
3806 | VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, nullptr, | ||||
3807 | 0, image.handle(), VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM, | ||||
3808 | { | ||||
3809 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3810 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3811 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3812 | VK_COMPONENT_SWIZZLE_IDENTITY | ||||
3813 | }, | ||||
3814 | { | ||||
3815 | VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 | ||||
3816 | }, | ||||
3817 | }; | ||||
3818 | VkImageView view; | ||||
3819 | err = vkCreateImageView(m_device->device(), &ivci, nullptr, &view); | ||||
3820 | ASSERT_VK_SUCCESS(err); | ||||
3821 | |||||
3822 | VkFramebufferCreateInfo fci = { | ||||
3823 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, | ||||
3824 | 0, rp, 1, &view, | ||||
3825 | 32, 32, 1 | ||||
3826 | }; | ||||
3827 | VkFramebuffer fb; | ||||
3828 | err = vkCreateFramebuffer(m_device->device(), &fci, nullptr, &fb); | ||||
3829 | ASSERT_VK_SUCCESS(err); | ||||
3830 | |||||
3831 | // Explicitly create a command buffer to bind the FB to so that we can then | ||||
3832 | // destroy the command pool in order to implicitly free command buffer | ||||
3833 | VkCommandPool command_pool; | ||||
3834 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
3835 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
3836 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
3837 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
3838 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
3839 | &command_pool); | ||||
3840 | |||||
3841 | VkCommandBuffer command_buffer; | ||||
3842 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
3843 | command_buffer_allocate_info.sType = | ||||
3844 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
3845 | command_buffer_allocate_info.commandPool = command_pool; | ||||
3846 | command_buffer_allocate_info.commandBufferCount = 1; | ||||
3847 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
3848 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
3849 | &command_buffer); | ||||
3850 | |||||
3851 | // Begin our cmd buffer with renderpass using our framebuffer | ||||
3852 | VkRenderPassBeginInfo rpbi = { | ||||
3853 | VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, | ||||
3854 | rp, fb, { { 0, 0 } , { 32, 32 } }, | ||||
3855 | 0, nullptr | ||||
3856 | }; | ||||
3857 | VkCommandBufferBeginInfo begin_info{}; | ||||
3858 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
3859 | vkBeginCommandBuffer(command_buffer, &begin_info); | ||||
3860 | |||||
3861 | vkCmdBeginRenderPass(command_buffer, &rpbi, VK_SUBPASS_CONTENTS_INLINE); | ||||
3862 | vkCmdEndRenderPass(command_buffer); | ||||
3863 | vkEndCommandBuffer(command_buffer); | ||||
Mark Lobodzinski | 7d10a82 | 2016-08-03 14:08:40 -0600 | [diff] [blame] | 3864 | vkDestroyImageView(m_device->device(), view, nullptr); |
Tobin Ehlis | 75ac37b | 2016-07-29 10:55:41 -0600 | [diff] [blame] | 3865 | // Destroy command pool to implicitly free command buffer |
3866 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
3867 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); | ||||
3868 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
3869 | m_errorMonitor->VerifyNotFound(); | ||||
3870 | } | ||||
3871 | |||||
Chris Forbes | 51bf7c9 | 2016-06-30 15:22:08 +1200 | [diff] [blame] | 3872 | TEST_F(VkLayerTest, RenderPassSubpassZeroTransitionsApplied) { |
3873 | TEST_DESCRIPTION("Ensure that CmdBeginRenderPass applies the layout " | ||||
3874 | "transitions for the first subpass"); | ||||
3875 | |||||
3876 | m_errorMonitor->ExpectSuccess(); | ||||
3877 | |||||
3878 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
3879 | |||||
3880 | // A renderpass with one color attachment. | ||||
3881 | VkAttachmentDescription attachment = { | ||||
3882 | 0, VK_FORMAT_R8G8B8A8_UNORM, VK_SAMPLE_COUNT_1_BIT, | ||||
3883 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_STORE, | ||||
3884 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
3885 | VK_IMAGE_LAYOUT_UNDEFINED, | ||||
3886 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
3887 | }; | ||||
3888 | |||||
3889 | VkAttachmentReference att_ref = { | ||||
3890 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
3891 | }; | ||||
3892 | |||||
3893 | VkSubpassDescription subpass = { | ||||
3894 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, | ||||
3895 | 1, &att_ref, nullptr, nullptr, 0, nullptr | ||||
3896 | }; | ||||
3897 | |||||
3898 | VkSubpassDependency dep = { | ||||
Chris Forbes | cb4c7ad | 2016-07-06 10:28:18 +1200 | [diff] [blame] | 3899 | 0, 0, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, |
3900 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, | ||||
Chris Forbes | 51bf7c9 | 2016-06-30 15:22:08 +1200 | [diff] [blame] | 3901 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, |
3902 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, | ||||
3903 | VK_DEPENDENCY_BY_REGION_BIT | ||||
3904 | }; | ||||
3905 | |||||
3906 | VkRenderPassCreateInfo rpci = { | ||||
3907 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
3908 | 0, 1, &attachment, 1, &subpass, 1, &dep | ||||
3909 | }; | ||||
3910 | |||||
3911 | VkResult err; | ||||
3912 | VkRenderPass rp; | ||||
3913 | err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
3914 | ASSERT_VK_SUCCESS(err); | ||||
3915 | |||||
3916 | // A compatible framebuffer. | ||||
3917 | VkImageObj image(m_device); | ||||
3918 | image.init(32, 32, VK_FORMAT_R8G8B8A8_UNORM, | ||||
3919 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, | ||||
3920 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
3921 | ASSERT_TRUE(image.initialized()); | ||||
3922 | |||||
3923 | VkImageViewCreateInfo ivci = { | ||||
3924 | VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, nullptr, | ||||
3925 | 0, image.handle(), VK_IMAGE_VIEW_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM, | ||||
3926 | { | ||||
3927 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3928 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3929 | VK_COMPONENT_SWIZZLE_IDENTITY, | ||||
3930 | VK_COMPONENT_SWIZZLE_IDENTITY | ||||
3931 | }, | ||||
3932 | { | ||||
3933 | VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 | ||||
3934 | }, | ||||
3935 | }; | ||||
3936 | VkImageView view; | ||||
3937 | err = vkCreateImageView(m_device->device(), &ivci, nullptr, &view); | ||||
3938 | ASSERT_VK_SUCCESS(err); | ||||
3939 | |||||
3940 | VkFramebufferCreateInfo fci = { | ||||
3941 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, | ||||
3942 | 0, rp, 1, &view, | ||||
3943 | 32, 32, 1 | ||||
3944 | }; | ||||
3945 | VkFramebuffer fb; | ||||
3946 | err = vkCreateFramebuffer(m_device->device(), &fci, nullptr, &fb); | ||||
3947 | ASSERT_VK_SUCCESS(err); | ||||
3948 | |||||
3949 | // Record a single command buffer which issues a pipeline barrier w/ | ||||
3950 | // image memory barrier for the attachment. This detects the previously | ||||
3951 | // missing tracking of the subpass layout by throwing a validation error | ||||
3952 | // if it doesn't occur. | ||||
3953 | VkRenderPassBeginInfo rpbi = { | ||||
3954 | VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, | ||||
Tobin Ehlis | 0f9aa40 | 2016-07-01 08:47:12 -0600 | [diff] [blame] | 3955 | rp, fb, { { 0, 0 }, { 32, 32 } }, |
Chris Forbes | 51bf7c9 | 2016-06-30 15:22:08 +1200 | [diff] [blame] | 3956 | 0, nullptr |
3957 | }; | ||||
3958 | BeginCommandBuffer(); | ||||
3959 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, | ||||
3960 | VK_SUBPASS_CONTENTS_INLINE); | ||||
3961 | |||||
3962 | VkImageMemoryBarrier imb = { | ||||
3963 | VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, nullptr, | ||||
3964 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, | ||||
3965 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, | ||||
3966 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
3967 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
3968 | VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, | ||||
3969 | image.handle(), | ||||
3970 | { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 } | ||||
3971 | }; | ||||
3972 | vkCmdPipelineBarrier(m_commandBuffer->handle(), | ||||
Chris Forbes | cb4c7ad | 2016-07-06 10:28:18 +1200 | [diff] [blame] | 3973 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, |
3974 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, | ||||
Chris Forbes | 51bf7c9 | 2016-06-30 15:22:08 +1200 | [diff] [blame] | 3975 | VK_DEPENDENCY_BY_REGION_BIT, |
3976 | 0, nullptr, 0, nullptr, 1, &imb); | ||||
3977 | |||||
3978 | vkCmdEndRenderPass(m_commandBuffer->handle()); | ||||
3979 | m_errorMonitor->VerifyNotFound(); | ||||
3980 | EndCommandBuffer(); | ||||
3981 | |||||
3982 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); | ||||
3983 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
3984 | vkDestroyImageView(m_device->device(), view, nullptr); | ||||
3985 | } | ||||
3986 | |||||
Mark Lobodzinski | 77a5d6f | 2016-08-05 09:38:18 -0600 | [diff] [blame] | 3987 | TEST_F(VkLayerTest, DepthStencilLayoutTransitionForDepthOnlyImageview) { |
3988 | TEST_DESCRIPTION("Validate that when an imageView of a depth/stencil image " | ||||
3989 | "is used as a depth/stencil framebuffer attachment, the " | ||||
3990 | "aspectMask is ignored and both depth and stencil image " | ||||
3991 | "subresources are used."); | ||||
3992 | |||||
3993 | VkFormatProperties format_properties; | ||||
3994 | vkGetPhysicalDeviceFormatProperties(gpu(), VK_FORMAT_D32_SFLOAT_S8_UINT, | ||||
3995 | &format_properties); | ||||
3996 | if (!(format_properties.optimalTilingFeatures & | ||||
3997 | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) { | ||||
3998 | return; | ||||
3999 | } | ||||
4000 | |||||
4001 | m_errorMonitor->ExpectSuccess(); | ||||
4002 | |||||
4003 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4004 | |||||
4005 | VkAttachmentDescription attachment = { | ||||
4006 | 0, | ||||
4007 | VK_FORMAT_D32_SFLOAT_S8_UINT, | ||||
4008 | VK_SAMPLE_COUNT_1_BIT, | ||||
4009 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, | ||||
4010 | VK_ATTACHMENT_STORE_OP_STORE, | ||||
4011 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, | ||||
4012 | VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4013 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, | ||||
4014 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL}; | ||||
4015 | |||||
4016 | VkAttachmentReference att_ref = { | ||||
4017 | 0, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL}; | ||||
4018 | |||||
4019 | VkSubpassDescription subpass = {0, VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
4020 | 0, nullptr, | ||||
4021 | 0, nullptr, | ||||
4022 | nullptr, &att_ref, | ||||
4023 | 0, nullptr}; | ||||
4024 | |||||
4025 | VkSubpassDependency dep = {0, | ||||
4026 | 0, | ||||
4027 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, | ||||
4028 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, | ||||
4029 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, | ||||
4030 | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, | ||||
4031 | VK_DEPENDENCY_BY_REGION_BIT}; | ||||
4032 | |||||
4033 | VkRenderPassCreateInfo rpci = {VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, | ||||
4034 | nullptr, | ||||
4035 | 0, | ||||
4036 | 1, | ||||
4037 | &attachment, | ||||
4038 | 1, | ||||
4039 | &subpass, | ||||
4040 | 1, | ||||
4041 | &dep}; | ||||
4042 | |||||
4043 | VkResult err; | ||||
4044 | VkRenderPass rp; | ||||
4045 | err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
4046 | ASSERT_VK_SUCCESS(err); | ||||
4047 | |||||
4048 | VkImageObj image(m_device); | ||||
4049 | image.init_no_layout(32, 32, VK_FORMAT_D32_SFLOAT_S8_UINT, | ||||
4050 | 0x26, // usage | ||||
4051 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
4052 | ASSERT_TRUE(image.initialized()); | ||||
4053 | image.SetLayout(0x6, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); | ||||
4054 | |||||
4055 | VkImageViewCreateInfo ivci = { | ||||
4056 | VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, | ||||
4057 | nullptr, | ||||
4058 | 0, | ||||
4059 | image.handle(), | ||||
4060 | VK_IMAGE_VIEW_TYPE_2D, | ||||
4061 | VK_FORMAT_D32_SFLOAT_S8_UINT, | ||||
4062 | {VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, | ||||
4063 | VK_COMPONENT_SWIZZLE_A}, | ||||
4064 | {0x2, 0, 1, 0, 1}, | ||||
4065 | }; | ||||
4066 | VkImageView view; | ||||
4067 | err = vkCreateImageView(m_device->device(), &ivci, nullptr, &view); | ||||
4068 | ASSERT_VK_SUCCESS(err); | ||||
4069 | |||||
4070 | VkFramebufferCreateInfo fci = {VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, | ||||
4071 | nullptr, | ||||
4072 | 0, | ||||
4073 | rp, | ||||
4074 | 1, | ||||
4075 | &view, | ||||
4076 | 32, | ||||
4077 | 32, | ||||
4078 | 1}; | ||||
4079 | VkFramebuffer fb; | ||||
4080 | err = vkCreateFramebuffer(m_device->device(), &fci, nullptr, &fb); | ||||
4081 | ASSERT_VK_SUCCESS(err); | ||||
4082 | |||||
4083 | VkRenderPassBeginInfo rpbi = {VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, | ||||
4084 | nullptr, | ||||
4085 | rp, | ||||
4086 | fb, | ||||
4087 | {{0, 0}, {32, 32}}, | ||||
4088 | 0, | ||||
4089 | nullptr}; | ||||
4090 | BeginCommandBuffer(); | ||||
4091 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, | ||||
4092 | VK_SUBPASS_CONTENTS_INLINE); | ||||
4093 | |||||
4094 | VkImageMemoryBarrier imb = {}; | ||||
4095 | imb.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; | ||||
4096 | imb.pNext = nullptr; | ||||
4097 | imb.srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; | ||||
4098 | imb.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
4099 | imb.oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
4100 | imb.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
4101 | imb.srcQueueFamilyIndex = 0; | ||||
4102 | imb.dstQueueFamilyIndex = 0; | ||||
4103 | imb.image = image.handle(); | ||||
4104 | imb.subresourceRange.aspectMask = 0x6; | ||||
4105 | imb.subresourceRange.baseMipLevel = 0; | ||||
4106 | imb.subresourceRange.levelCount = 0x1; | ||||
4107 | imb.subresourceRange.baseArrayLayer = 0; | ||||
4108 | imb.subresourceRange.layerCount = 0x1; | ||||
4109 | |||||
4110 | vkCmdPipelineBarrier(m_commandBuffer->handle(), | ||||
4111 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, | ||||
4112 | VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, | ||||
4113 | VK_DEPENDENCY_BY_REGION_BIT, 0, nullptr, 0, nullptr, 1, | ||||
4114 | &imb); | ||||
4115 | |||||
4116 | vkCmdEndRenderPass(m_commandBuffer->handle()); | ||||
4117 | EndCommandBuffer(); | ||||
4118 | QueueCommandBuffer(false); | ||||
4119 | m_errorMonitor->VerifyNotFound(); | ||||
4120 | |||||
4121 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); | ||||
4122 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
4123 | vkDestroyImageView(m_device->device(), view, nullptr); | ||||
4124 | } | ||||
Tony Barbour | d5f7b82 | 2016-08-02 15:39:33 -0600 | [diff] [blame] | 4125 | |
Chris Forbes | 6b3d3f4 | 2016-06-30 16:09:47 +1200 | [diff] [blame] | 4126 | TEST_F(VkLayerTest, RenderPassTransitionsAttachmentUnused) { |
4127 | TEST_DESCRIPTION("Ensure that layout transitions work correctly without " | ||||
4128 | "errors, when an attachment reference is " | ||||
4129 | "VK_ATTACHMENT_UNUSED"); | ||||
4130 | |||||
4131 | m_errorMonitor->ExpectSuccess(); | ||||
4132 | |||||
4133 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4134 | |||||
4135 | // A renderpass with no attachments | ||||
4136 | VkAttachmentReference att_ref = { | ||||
4137 | VK_ATTACHMENT_UNUSED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4138 | }; | ||||
4139 | |||||
4140 | VkSubpassDescription subpass = { | ||||
4141 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, 0, nullptr, | ||||
4142 | 1, &att_ref, nullptr, nullptr, 0, nullptr | ||||
4143 | }; | ||||
4144 | |||||
4145 | VkRenderPassCreateInfo rpci = { | ||||
4146 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
4147 | 0, 0, nullptr, 1, &subpass, 0, nullptr | ||||
4148 | }; | ||||
4149 | |||||
4150 | VkRenderPass rp; | ||||
4151 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
4152 | ASSERT_VK_SUCCESS(err); | ||||
4153 | |||||
4154 | // A compatible framebuffer. | ||||
4155 | VkFramebufferCreateInfo fci = { | ||||
4156 | VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, nullptr, | ||||
4157 | 0, rp, 0, nullptr, | ||||
4158 | 32, 32, 1 | ||||
4159 | }; | ||||
4160 | VkFramebuffer fb; | ||||
4161 | err = vkCreateFramebuffer(m_device->device(), &fci, nullptr, &fb); | ||||
4162 | ASSERT_VK_SUCCESS(err); | ||||
4163 | |||||
4164 | // Record a command buffer which just begins and ends the renderpass. The | ||||
4165 | // bug manifests in BeginRenderPass. | ||||
4166 | VkRenderPassBeginInfo rpbi = { | ||||
4167 | VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, nullptr, | ||||
Tobin Ehlis | 0f9aa40 | 2016-07-01 08:47:12 -0600 | [diff] [blame] | 4168 | rp, fb, { { 0, 0 }, { 32, 32 } }, |
Chris Forbes | 6b3d3f4 | 2016-06-30 16:09:47 +1200 | [diff] [blame] | 4169 | 0, nullptr |
4170 | }; | ||||
4171 | BeginCommandBuffer(); | ||||
4172 | vkCmdBeginRenderPass(m_commandBuffer->handle(), &rpbi, | ||||
4173 | VK_SUBPASS_CONTENTS_INLINE); | ||||
4174 | vkCmdEndRenderPass(m_commandBuffer->handle()); | ||||
4175 | m_errorMonitor->VerifyNotFound(); | ||||
4176 | EndCommandBuffer(); | ||||
4177 | |||||
4178 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); | ||||
4179 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
4180 | } | ||||
4181 | |||||
Mark Lobodzinski | ce7eee7 | 2016-06-14 16:33:29 -0600 | [diff] [blame] | 4182 | // This is a positive test. No errors are expected. |
4183 | TEST_F(VkLayerTest, StencilLoadOp) { | ||||
4184 | TEST_DESCRIPTION("Create a stencil-only attachment with a LOAD_OP set to " | ||||
4185 | "CLEAR. stencil[Load|Store]Op used to be ignored."); | ||||
4186 | VkResult result = VK_SUCCESS; | ||||
4187 | VkImageFormatProperties formatProps; | ||||
4188 | vkGetPhysicalDeviceImageFormatProperties( | ||||
4189 | gpu(), VK_FORMAT_D24_UNORM_S8_UINT, VK_IMAGE_TYPE_2D, | ||||
4190 | VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | | ||||
4191 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, | ||||
4192 | 0, &formatProps); | ||||
4193 | if (formatProps.maxExtent.width < 100 || formatProps.maxExtent.height < 100) { | ||||
4194 | return; | ||||
4195 | } | ||||
4196 | |||||
4197 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4198 | VkFormat depth_stencil_fmt = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
4199 | m_depthStencil->Init(m_device, 100, 100, depth_stencil_fmt, | ||||
4200 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | | ||||
4201 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT); | ||||
4202 | VkAttachmentDescription att = {}; | ||||
4203 | VkAttachmentReference ref = {}; | ||||
4204 | att.format = depth_stencil_fmt; | ||||
4205 | att.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; | ||||
4206 | att.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; | ||||
4207 | att.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; | ||||
4208 | att.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; | ||||
4209 | att.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
4210 | att.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
4211 | |||||
4212 | VkClearValue clear; | ||||
4213 | clear.depthStencil.depth = 1.0; | ||||
4214 | clear.depthStencil.stencil = 0; | ||||
4215 | ref.attachment = 0; | ||||
4216 | ref.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
4217 | |||||
4218 | VkSubpassDescription subpass = {}; | ||||
4219 | subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; | ||||
4220 | subpass.flags = 0; | ||||
4221 | subpass.inputAttachmentCount = 0; | ||||
4222 | subpass.pInputAttachments = NULL; | ||||
4223 | subpass.colorAttachmentCount = 0; | ||||
4224 | subpass.pColorAttachments = NULL; | ||||
4225 | subpass.pResolveAttachments = NULL; | ||||
4226 | subpass.pDepthStencilAttachment = &ref; | ||||
4227 | subpass.preserveAttachmentCount = 0; | ||||
4228 | subpass.pPreserveAttachments = NULL; | ||||
4229 | |||||
4230 | VkRenderPass rp; | ||||
4231 | VkRenderPassCreateInfo rp_info = {}; | ||||
4232 | rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; | ||||
4233 | rp_info.attachmentCount = 1; | ||||
4234 | rp_info.pAttachments = &att; | ||||
4235 | rp_info.subpassCount = 1; | ||||
4236 | rp_info.pSubpasses = &subpass; | ||||
4237 | result = vkCreateRenderPass(device(), &rp_info, NULL, &rp); | ||||
4238 | ASSERT_VK_SUCCESS(result); | ||||
4239 | |||||
4240 | VkImageView *depthView = m_depthStencil->BindInfo(); | ||||
4241 | VkFramebufferCreateInfo fb_info = {}; | ||||
4242 | fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; | ||||
4243 | fb_info.pNext = NULL; | ||||
4244 | fb_info.renderPass = rp; | ||||
4245 | fb_info.attachmentCount = 1; | ||||
4246 | fb_info.pAttachments = depthView; | ||||
4247 | fb_info.width = 100; | ||||
4248 | fb_info.height = 100; | ||||
4249 | fb_info.layers = 1; | ||||
4250 | VkFramebuffer fb; | ||||
4251 | result = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4252 | ASSERT_VK_SUCCESS(result); | ||||
4253 | |||||
4254 | |||||
4255 | VkRenderPassBeginInfo rpbinfo = {}; | ||||
4256 | rpbinfo.clearValueCount = 1; | ||||
4257 | rpbinfo.pClearValues = &clear; | ||||
4258 | rpbinfo.pNext = NULL; | ||||
4259 | rpbinfo.renderPass = rp; | ||||
4260 | rpbinfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; | ||||
4261 | rpbinfo.renderArea.extent.width = 100; | ||||
4262 | rpbinfo.renderArea.extent.height = 100; | ||||
4263 | rpbinfo.renderArea.offset.x = 0; | ||||
4264 | rpbinfo.renderArea.offset.y = 0; | ||||
4265 | rpbinfo.framebuffer = fb; | ||||
4266 | |||||
4267 | VkFence fence = {}; | ||||
4268 | VkFenceCreateInfo fence_ci = {}; | ||||
4269 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
4270 | fence_ci.pNext = nullptr; | ||||
4271 | fence_ci.flags = 0; | ||||
4272 | result = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fence); | ||||
4273 | ASSERT_VK_SUCCESS(result); | ||||
4274 | |||||
4275 | |||||
4276 | m_commandBuffer->BeginCommandBuffer(); | ||||
4277 | m_commandBuffer->BeginRenderPass(rpbinfo); | ||||
4278 | m_commandBuffer->EndRenderPass(); | ||||
4279 | m_commandBuffer->EndCommandBuffer(); | ||||
4280 | m_commandBuffer->QueueCommandBuffer(fence); | ||||
4281 | |||||
4282 | VkImageObj destImage(m_device); | ||||
4283 | destImage.init(100, 100, depth_stencil_fmt, | ||||
4284 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | | ||||
4285 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
4286 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
4287 | VkImageMemoryBarrier barrier = {}; | ||||
4288 | VkImageSubresourceRange range; | ||||
4289 | barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; | ||||
4290 | barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT | | ||||
4291 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; | ||||
4292 | barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | | ||||
4293 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; | ||||
4294 | barrier.oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
4295 | barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; | ||||
4296 | barrier.image = m_depthStencil->handle(); | ||||
4297 | range.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; | ||||
4298 | range.baseMipLevel = 0; | ||||
4299 | range.levelCount = 1; | ||||
4300 | range.baseArrayLayer = 0; | ||||
4301 | range.layerCount = 1; | ||||
4302 | barrier.subresourceRange = range; | ||||
4303 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
4304 | VkCommandBufferObj cmdbuf(m_device, m_commandPool); | ||||
4305 | cmdbuf.BeginCommandBuffer(); | ||||
4306 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
4307 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, | ||||
4308 | nullptr, 1, &barrier); | ||||
4309 | barrier.srcAccessMask = 0; | ||||
4310 | barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; | ||||
4311 | barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; | ||||
4312 | barrier.image = destImage.handle(); | ||||
4313 | barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT | | ||||
4314 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; | ||||
4315 | cmdbuf.PipelineBarrier(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
4316 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, | ||||
4317 | nullptr, 1, &barrier); | ||||
4318 | VkImageCopy cregion; | ||||
4319 | cregion.srcSubresource.aspectMask = | ||||
4320 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; | ||||
4321 | cregion.srcSubresource.mipLevel = 0; | ||||
4322 | cregion.srcSubresource.baseArrayLayer = 0; | ||||
4323 | cregion.srcSubresource.layerCount = 1; | ||||
4324 | cregion.srcOffset.x = 0; | ||||
4325 | cregion.srcOffset.y = 0; | ||||
4326 | cregion.srcOffset.z = 0; | ||||
4327 | cregion.dstSubresource.aspectMask = | ||||
4328 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; | ||||
4329 | cregion.dstSubresource.mipLevel = 0; | ||||
4330 | cregion.dstSubresource.baseArrayLayer = 0; | ||||
4331 | cregion.dstSubresource.layerCount = 1; | ||||
4332 | cregion.dstOffset.x = 0; | ||||
4333 | cregion.dstOffset.y = 0; | ||||
4334 | cregion.dstOffset.z = 0; | ||||
4335 | cregion.extent.width = 100; | ||||
4336 | cregion.extent.height = 100; | ||||
4337 | cregion.extent.depth = 1; | ||||
4338 | cmdbuf.CopyImage(m_depthStencil->handle(), | ||||
4339 | VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, destImage.handle(), | ||||
4340 | VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &cregion); | ||||
4341 | cmdbuf.EndCommandBuffer(); | ||||
4342 | |||||
4343 | VkSubmitInfo submit_info; | ||||
4344 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
4345 | submit_info.pNext = NULL; | ||||
4346 | submit_info.waitSemaphoreCount = 0; | ||||
4347 | submit_info.pWaitSemaphores = NULL; | ||||
4348 | submit_info.pWaitDstStageMask = NULL; | ||||
4349 | submit_info.commandBufferCount = 1; | ||||
4350 | submit_info.pCommandBuffers = &cmdbuf.handle(); | ||||
4351 | submit_info.signalSemaphoreCount = 0; | ||||
4352 | submit_info.pSignalSemaphores = NULL; | ||||
4353 | |||||
4354 | m_errorMonitor->ExpectSuccess(); | ||||
4355 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
4356 | m_errorMonitor->VerifyNotFound(); | ||||
4357 | |||||
Mark Lobodzinski | d0440da | 2016-06-17 15:10:03 -0600 | [diff] [blame] | 4358 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | ce7eee7 | 2016-06-14 16:33:29 -0600 | [diff] [blame] | 4359 | vkDestroyFence(m_device->device(), fence, nullptr); |
4360 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
4361 | vkDestroyFramebuffer(m_device->device(), fb, nullptr); | ||||
4362 | } | ||||
4363 | |||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4364 | TEST_F(VkLayerTest, UnusedPreserveAttachment) { |
4365 | TEST_DESCRIPTION("Create a framebuffer where a subpass has a preserve " | ||||
4366 | "attachment reference of VK_ATTACHMENT_UNUSED"); | ||||
4367 | |||||
4368 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4369 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
4370 | |||||
4371 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4372 | "must not be VK_ATTACHMENT_UNUSED"); | ||||
4373 | |||||
4374 | VkAttachmentReference color_attach = {}; | ||||
4375 | color_attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
4376 | color_attach.attachment = 0; | ||||
4377 | uint32_t preserve_attachment = VK_ATTACHMENT_UNUSED; | ||||
4378 | VkSubpassDescription subpass = {}; | ||||
4379 | subpass.colorAttachmentCount = 1; | ||||
4380 | subpass.pColorAttachments = &color_attach; | ||||
4381 | subpass.preserveAttachmentCount = 1; | ||||
4382 | subpass.pPreserveAttachments = &preserve_attachment; | ||||
4383 | |||||
4384 | VkRenderPassCreateInfo rpci = {}; | ||||
4385 | rpci.subpassCount = 1; | ||||
4386 | rpci.pSubpasses = &subpass; | ||||
4387 | rpci.attachmentCount = 1; | ||||
4388 | VkAttachmentDescription attach_desc = {}; | ||||
4389 | attach_desc.format = VK_FORMAT_UNDEFINED; | ||||
4390 | rpci.pAttachments = &attach_desc; | ||||
4391 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; | ||||
4392 | VkRenderPass rp; | ||||
Mark Lobodzinski | a4feeeb | 2016-06-17 12:00:46 -0600 | [diff] [blame] | 4393 | VkResult result = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4394 | |
4395 | m_errorMonitor->VerifyFound(); | ||||
4396 | |||||
Mark Lobodzinski | a4feeeb | 2016-06-17 12:00:46 -0600 | [diff] [blame] | 4397 | if (result == VK_SUCCESS) { |
4398 | vkDestroyRenderPass(m_device->device(), rp, NULL); | ||||
4399 | } | ||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4400 | } |
4401 | |||||
Chris Forbes | c538974 | 2016-06-29 11:49:23 +1200 | [diff] [blame] | 4402 | TEST_F(VkLayerTest, CreateRenderPassResolveRequiresColorMsaa) { |
Chris Forbes | 6655bb3 | 2016-07-01 18:27:30 +1200 | [diff] [blame] | 4403 | TEST_DESCRIPTION("Ensure that CreateRenderPass produces a validation error " |
4404 | "when the source of a subpass multisample resolve " | ||||
4405 | "does not have multiple samples."); | ||||
4406 | |||||
Chris Forbes | c538974 | 2016-06-29 11:49:23 +1200 | [diff] [blame] | 4407 | ASSERT_NO_FATAL_FAILURE(InitState()); |
4408 | |||||
4409 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4410 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Chris Forbes | 6655bb3 | 2016-07-01 18:27:30 +1200 | [diff] [blame] | 4411 | "Subpass 0 requests multisample resolve from attachment 0 which has " |
4412 | "VK_SAMPLE_COUNT_1_BIT"); | ||||
Chris Forbes | c538974 | 2016-06-29 11:49:23 +1200 | [diff] [blame] | 4413 | |
4414 | VkAttachmentDescription attachments[] = { | ||||
4415 | { | ||||
4416 | 0, VK_FORMAT_R8G8B8A8_UNORM, | ||||
4417 | VK_SAMPLE_COUNT_1_BIT, | ||||
4418 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4419 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4420 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4421 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4422 | }, | ||||
4423 | { | ||||
4424 | 0, VK_FORMAT_R8G8B8A8_UNORM, | ||||
4425 | VK_SAMPLE_COUNT_1_BIT, | ||||
4426 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4427 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4428 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4429 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4430 | }, | ||||
4431 | }; | ||||
4432 | |||||
4433 | VkAttachmentReference color = { | ||||
4434 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4435 | }; | ||||
4436 | |||||
4437 | VkAttachmentReference resolve = { | ||||
4438 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4439 | }; | ||||
4440 | |||||
4441 | VkSubpassDescription subpass = { | ||||
4442 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
4443 | 0, nullptr, | ||||
4444 | 1, &color, | ||||
4445 | &resolve, | ||||
4446 | nullptr, | ||||
4447 | 0, nullptr | ||||
4448 | }; | ||||
4449 | |||||
4450 | VkRenderPassCreateInfo rpci = { | ||||
4451 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
4452 | 0, 2, attachments, 1, &subpass, 0, nullptr | ||||
4453 | }; | ||||
4454 | |||||
4455 | VkRenderPass rp; | ||||
4456 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
4457 | |||||
4458 | m_errorMonitor->VerifyFound(); | ||||
4459 | |||||
4460 | if (err == VK_SUCCESS) | ||||
4461 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
4462 | } | ||||
4463 | |||||
4464 | TEST_F(VkLayerTest, CreateRenderPassResolveRequiresSingleSampleDest) { | ||||
Chris Forbes | 6655bb3 | 2016-07-01 18:27:30 +1200 | [diff] [blame] | 4465 | TEST_DESCRIPTION("Ensure CreateRenderPass produces a validation error " |
4466 | "when a subpass multisample resolve operation is " | ||||
4467 | "requested, and the destination of that resolve has " | ||||
4468 | "multiple samples."); | ||||
4469 | |||||
Chris Forbes | c538974 | 2016-06-29 11:49:23 +1200 | [diff] [blame] | 4470 | ASSERT_NO_FATAL_FAILURE(InitState()); |
4471 | |||||
4472 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4473 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4474 | "Subpass 0 requests multisample resolve into attachment 1, which " | ||||
4475 | "must have VK_SAMPLE_COUNT_1_BIT but has VK_SAMPLE_COUNT_4_BIT"); | ||||
4476 | |||||
4477 | VkAttachmentDescription attachments[] = { | ||||
4478 | { | ||||
4479 | 0, VK_FORMAT_R8G8B8A8_UNORM, | ||||
4480 | VK_SAMPLE_COUNT_4_BIT, | ||||
4481 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4482 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4483 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4484 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4485 | }, | ||||
4486 | { | ||||
4487 | 0, VK_FORMAT_R8G8B8A8_UNORM, | ||||
4488 | VK_SAMPLE_COUNT_4_BIT, | ||||
4489 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4490 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4491 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4492 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4493 | }, | ||||
4494 | }; | ||||
4495 | |||||
4496 | VkAttachmentReference color = { | ||||
4497 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4498 | }; | ||||
4499 | |||||
4500 | VkAttachmentReference resolve = { | ||||
4501 | 1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4502 | }; | ||||
4503 | |||||
4504 | VkSubpassDescription subpass = { | ||||
4505 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
4506 | 0, nullptr, | ||||
4507 | 1, &color, | ||||
4508 | &resolve, | ||||
4509 | nullptr, | ||||
4510 | 0, nullptr | ||||
4511 | }; | ||||
4512 | |||||
4513 | VkRenderPassCreateInfo rpci = { | ||||
4514 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
4515 | 0, 2, attachments, 1, &subpass, 0, nullptr | ||||
4516 | }; | ||||
4517 | |||||
4518 | VkRenderPass rp; | ||||
4519 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
4520 | |||||
4521 | m_errorMonitor->VerifyFound(); | ||||
4522 | |||||
4523 | if (err == VK_SUCCESS) | ||||
4524 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
4525 | } | ||||
4526 | |||||
Chris Forbes | 3f128ef | 2016-06-29 14:58:53 +1200 | [diff] [blame] | 4527 | TEST_F(VkLayerTest, CreateRenderPassSubpassSampleCountConsistency) { |
Chris Forbes | 6655bb3 | 2016-07-01 18:27:30 +1200 | [diff] [blame] | 4528 | TEST_DESCRIPTION("Ensure CreateRenderPass produces a validation error " |
4529 | "when the color and depth attachments used by a subpass " | ||||
4530 | "have inconsistent sample counts"); | ||||
4531 | |||||
Chris Forbes | 3f128ef | 2016-06-29 14:58:53 +1200 | [diff] [blame] | 4532 | ASSERT_NO_FATAL_FAILURE(InitState()); |
4533 | |||||
4534 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4535 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4536 | "Subpass 0 attempts to render to attachments with inconsistent sample counts"); | ||||
4537 | |||||
4538 | VkAttachmentDescription attachments[] = { | ||||
4539 | { | ||||
4540 | 0, VK_FORMAT_R8G8B8A8_UNORM, | ||||
4541 | VK_SAMPLE_COUNT_1_BIT, | ||||
4542 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4543 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4544 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4545 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4546 | }, | ||||
4547 | { | ||||
4548 | 0, VK_FORMAT_R8G8B8A8_UNORM, | ||||
4549 | VK_SAMPLE_COUNT_4_BIT, | ||||
4550 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4551 | VK_ATTACHMENT_LOAD_OP_DONT_CARE, VK_ATTACHMENT_STORE_OP_DONT_CARE, | ||||
4552 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4553 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL | ||||
4554 | }, | ||||
4555 | }; | ||||
4556 | |||||
4557 | VkAttachmentReference color[] = { | ||||
4558 | { | ||||
4559 | 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4560 | }, | ||||
4561 | { | ||||
4562 | 1, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, | ||||
4563 | }, | ||||
4564 | }; | ||||
4565 | |||||
4566 | VkSubpassDescription subpass = { | ||||
4567 | 0, VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
4568 | 0, nullptr, | ||||
4569 | 2, color, | ||||
4570 | nullptr, | ||||
4571 | nullptr, | ||||
4572 | 0, nullptr | ||||
4573 | }; | ||||
4574 | |||||
4575 | VkRenderPassCreateInfo rpci = { | ||||
4576 | VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, nullptr, | ||||
4577 | 0, 2, attachments, 1, &subpass, 0, nullptr | ||||
4578 | }; | ||||
4579 | |||||
4580 | VkRenderPass rp; | ||||
4581 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, nullptr, &rp); | ||||
4582 | |||||
4583 | m_errorMonitor->VerifyFound(); | ||||
4584 | |||||
4585 | if (err == VK_SUCCESS) | ||||
4586 | vkDestroyRenderPass(m_device->device(), rp, nullptr); | ||||
4587 | } | ||||
4588 | |||||
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4589 | TEST_F(VkLayerTest, FramebufferCreateErrors) { |
4590 | TEST_DESCRIPTION("Hit errors when attempting to create a framebuffer :\n" | ||||
4591 | " 1. Mismatch between fb & renderPass attachmentCount\n" | ||||
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 4592 | " 2. Use a color image as depthStencil attachment\n" |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 4593 | " 3. Mismatch fb & renderPass attachment formats\n" |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 4594 | " 4. Mismatch fb & renderPass attachment #samples\n" |
Tobin Ehlis | 27f2ae8 | 2016-06-23 07:36:57 -0600 | [diff] [blame] | 4595 | " 5. FB attachment w/ non-1 mip-levels\n" |
Tobin Ehlis | b1f303b | 2016-06-23 08:19:55 -0600 | [diff] [blame] | 4596 | " 6. FB attachment where dimensions don't match\n" |
Tobin Ehlis | 08d4b5e | 2016-06-23 08:52:39 -0600 | [diff] [blame] | 4597 | " 7. FB attachment w/o identity swizzle\n" |
4598 | " 8. FB dimensions exceed physical device limits\n"); | ||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4599 | |
4600 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
4601 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
4602 | |||||
4603 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4604 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4605 | "vkCreateFramebuffer(): VkFramebufferCreateInfo attachmentCount of 2 " |
4606 | "does not match attachmentCount of 1 of "); | ||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4607 | |
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4608 | // Create a renderPass with a single color attachment |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4609 | VkAttachmentReference attach = {}; |
4610 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
4611 | VkSubpassDescription subpass = {}; | ||||
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4612 | subpass.pColorAttachments = &attach; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4613 | VkRenderPassCreateInfo rpci = {}; |
4614 | rpci.subpassCount = 1; | ||||
4615 | rpci.pSubpasses = &subpass; | ||||
4616 | rpci.attachmentCount = 1; | ||||
4617 | VkAttachmentDescription attach_desc = {}; | ||||
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 4618 | attach_desc.format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 4619 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4620 | rpci.pAttachments = &attach_desc; |
4621 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; | ||||
4622 | VkRenderPass rp; | ||||
4623 | VkResult err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
4624 | ASSERT_VK_SUCCESS(err); | ||||
4625 | |||||
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4626 | VkImageView ivs[2]; |
4627 | ivs[0] = m_renderTargets[0]->targetView(VK_FORMAT_B8G8R8A8_UNORM); | ||||
4628 | ivs[1] = m_renderTargets[0]->targetView(VK_FORMAT_B8G8R8A8_UNORM); | ||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4629 | VkFramebufferCreateInfo fb_info = {}; |
4630 | fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; | ||||
4631 | fb_info.pNext = NULL; | ||||
4632 | fb_info.renderPass = rp; | ||||
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4633 | // Set mis-matching attachmentCount |
4634 | fb_info.attachmentCount = 2; | ||||
4635 | fb_info.pAttachments = ivs; | ||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4636 | fb_info.width = 100; |
4637 | fb_info.height = 100; | ||||
4638 | fb_info.layers = 1; | ||||
4639 | |||||
4640 | VkFramebuffer fb; | ||||
4641 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4642 | |||||
4643 | m_errorMonitor->VerifyFound(); | ||||
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4644 | if (err == VK_SUCCESS) { |
4645 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4646 | } | ||||
4647 | vkDestroyRenderPass(m_device->device(), rp, NULL); | ||||
Tobin Ehlis | 2545e6f | 2016-06-22 10:42:19 -0600 | [diff] [blame] | 4648 | |
4649 | // Create a renderPass with a depth-stencil attachment created with | ||||
4650 | // IMAGE_USAGE_COLOR_ATTACHMENT | ||||
4651 | // Add our color attachment to pDepthStencilAttachment | ||||
4652 | subpass.pDepthStencilAttachment = &attach; | ||||
4653 | subpass.pColorAttachments = NULL; | ||||
4654 | VkRenderPass rp_ds; | ||||
4655 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp_ds); | ||||
4656 | ASSERT_VK_SUCCESS(err); | ||||
4657 | // Set correct attachment count, but attachment has COLOR usage bit set | ||||
4658 | fb_info.attachmentCount = 1; | ||||
4659 | fb_info.renderPass = rp_ds; | ||||
4660 | |||||
4661 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4662 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4663 | " conflicts with the image's IMAGE_USAGE flags "); | ||||
4664 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4665 | |||||
4666 | m_errorMonitor->VerifyFound(); | ||||
4667 | if (err == VK_SUCCESS) { | ||||
4668 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4669 | } | ||||
4670 | vkDestroyRenderPass(m_device->device(), rp_ds, NULL); | ||||
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 4671 | |
4672 | // Create new renderpass with alternate attachment format from fb | ||||
4673 | attach_desc.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
4674 | subpass.pDepthStencilAttachment = NULL; | ||||
4675 | subpass.pColorAttachments = &attach; | ||||
4676 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
4677 | ASSERT_VK_SUCCESS(err); | ||||
4678 | |||||
4679 | // Cause error due to mis-matched formats between rp & fb | ||||
4680 | // rp attachment 0 now has RGBA8 but corresponding fb attach is BGRA8 | ||||
4681 | fb_info.renderPass = rp; | ||||
4682 | m_errorMonitor->SetDesiredFailureMsg( | ||||
4683 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4684 | " has format of VK_FORMAT_B8G8R8A8_UNORM that does not match "); | ||||
4685 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4686 | |||||
4687 | m_errorMonitor->VerifyFound(); | ||||
4688 | if (err == VK_SUCCESS) { | ||||
4689 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4690 | } | ||||
Tobin Ehlis | 77d717c | 2016-06-22 14:19:19 -0600 | [diff] [blame] | 4691 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
4692 | |||||
4693 | // Create new renderpass with alternate sample count from fb | ||||
4694 | attach_desc.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
4695 | attach_desc.samples = VK_SAMPLE_COUNT_4_BIT; | ||||
4696 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
4697 | ASSERT_VK_SUCCESS(err); | ||||
4698 | |||||
4699 | // Cause error due to mis-matched sample count between rp & fb | ||||
4700 | fb_info.renderPass = rp; | ||||
4701 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4702 | " has VK_SAMPLE_COUNT_1_BIT samples " | ||||
4703 | "that do not match the " | ||||
4704 | "VK_SAMPLE_COUNT_4_BIT "); | ||||
4705 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4706 | |||||
4707 | m_errorMonitor->VerifyFound(); | ||||
4708 | if (err == VK_SUCCESS) { | ||||
4709 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4710 | } | ||||
Tobin Ehlis | d3bb23a | 2016-06-22 13:34:46 -0600 | [diff] [blame] | 4711 | |
4712 | vkDestroyRenderPass(m_device->device(), rp, NULL); | ||||
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 4713 | |
4714 | // Create a custom imageView with non-1 mip levels | ||||
4715 | VkImageObj image(m_device); | ||||
4716 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
4717 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); | ||||
4718 | ASSERT_TRUE(image.initialized()); | ||||
4719 | |||||
4720 | VkImageView view; | ||||
4721 | VkImageViewCreateInfo ivci = {}; | ||||
4722 | ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
4723 | ivci.image = image.handle(); | ||||
4724 | ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
4725 | ivci.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
4726 | ivci.subresourceRange.layerCount = 1; | ||||
4727 | ivci.subresourceRange.baseMipLevel = 0; | ||||
4728 | // Set level count 2 (only 1 is allowed for FB attachment) | ||||
4729 | ivci.subresourceRange.levelCount = 2; | ||||
4730 | ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
4731 | err = vkCreateImageView(m_device->device(), &ivci, NULL, &view); | ||||
4732 | ASSERT_VK_SUCCESS(err); | ||||
4733 | // Re-create renderpass to have matching sample count | ||||
4734 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
4735 | err = vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
4736 | ASSERT_VK_SUCCESS(err); | ||||
4737 | |||||
4738 | fb_info.renderPass = rp; | ||||
4739 | fb_info.pAttachments = &view; | ||||
4740 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4741 | " has mip levelCount of 2 but only "); | ||||
4742 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4743 | |||||
4744 | m_errorMonitor->VerifyFound(); | ||||
4745 | if (err == VK_SUCCESS) { | ||||
4746 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4747 | } | ||||
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 4748 | vkDestroyImageView(m_device->device(), view, NULL); |
Tobin Ehlis | 27f2ae8 | 2016-06-23 07:36:57 -0600 | [diff] [blame] | 4749 | // Update view to original color buffer and grow FB dimensions too big |
4750 | fb_info.pAttachments = ivs; | ||||
4751 | fb_info.height = 1024; | ||||
4752 | fb_info.width = 1024; | ||||
4753 | fb_info.layers = 2; | ||||
4754 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4755 | " Attachment dimensions must be at " | ||||
4756 | "least as large. "); | ||||
4757 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4758 | |||||
4759 | m_errorMonitor->VerifyFound(); | ||||
4760 | if (err == VK_SUCCESS) { | ||||
4761 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4762 | } | ||||
Tobin Ehlis | b1f303b | 2016-06-23 08:19:55 -0600 | [diff] [blame] | 4763 | // Create view attachment with non-identity swizzle |
4764 | ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
4765 | ivci.image = image.handle(); | ||||
4766 | ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
4767 | ivci.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
4768 | ivci.subresourceRange.layerCount = 1; | ||||
4769 | ivci.subresourceRange.baseMipLevel = 0; | ||||
4770 | ivci.subresourceRange.levelCount = 1; | ||||
4771 | ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
4772 | ivci.components.r = VK_COMPONENT_SWIZZLE_G; | ||||
4773 | ivci.components.g = VK_COMPONENT_SWIZZLE_R; | ||||
4774 | ivci.components.b = VK_COMPONENT_SWIZZLE_A; | ||||
4775 | ivci.components.a = VK_COMPONENT_SWIZZLE_B; | ||||
4776 | err = vkCreateImageView(m_device->device(), &ivci, NULL, &view); | ||||
4777 | ASSERT_VK_SUCCESS(err); | ||||
4778 | |||||
4779 | fb_info.pAttachments = &view; | ||||
4780 | fb_info.height = 100; | ||||
4781 | fb_info.width = 100; | ||||
4782 | fb_info.layers = 1; | ||||
4783 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4784 | " has non-identy swizzle. All " | ||||
4785 | "framebuffer attachments must have " | ||||
4786 | "been created with the identity " | ||||
4787 | "swizzle. "); | ||||
4788 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4789 | |||||
4790 | m_errorMonitor->VerifyFound(); | ||||
4791 | if (err == VK_SUCCESS) { | ||||
4792 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4793 | } | ||||
4794 | vkDestroyImageView(m_device->device(), view, NULL); | ||||
Tobin Ehlis | 08d4b5e | 2016-06-23 08:52:39 -0600 | [diff] [blame] | 4795 | // Request fb that exceeds max dimensions |
4796 | // reset attachment to color attachment | ||||
4797 | fb_info.pAttachments = ivs; | ||||
4798 | fb_info.width = m_device->props.limits.maxFramebufferWidth + 1; | ||||
4799 | fb_info.height = m_device->props.limits.maxFramebufferHeight + 1; | ||||
4800 | fb_info.layers = m_device->props.limits.maxFramebufferLayers + 1; | ||||
4801 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
4802 | " Requested VkFramebufferCreateInfo " | ||||
4803 | "dimensions exceed physical device " | ||||
4804 | "limits. "); | ||||
4805 | err = vkCreateFramebuffer(device(), &fb_info, NULL, &fb); | ||||
4806 | |||||
4807 | m_errorMonitor->VerifyFound(); | ||||
4808 | if (err == VK_SUCCESS) { | ||||
4809 | vkDestroyFramebuffer(m_device->device(), fb, NULL); | ||||
4810 | } | ||||
Tobin Ehlis | 27f2ae8 | 2016-06-23 07:36:57 -0600 | [diff] [blame] | 4811 | |
Tobin Ehlis | 6cfda64 | 2016-06-22 16:12:58 -0600 | [diff] [blame] | 4812 | vkDestroyRenderPass(m_device->device(), rp, NULL); |
Mark Lobodzinski | 6d17b9f | 2016-06-16 13:21:38 -0600 | [diff] [blame] | 4813 | } |
4814 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 4815 | // This is a positive test. No errors should be generated. |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4816 | TEST_F(VkLayerTest, WaitEventThenSet) { |
4817 | TEST_DESCRIPTION( | ||||
4818 | "Wait on a event then set it after the wait has been submitted."); | ||||
4819 | |||||
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4820 | m_errorMonitor->ExpectSuccess(); |
4821 | |||||
4822 | VkEvent event; | ||||
4823 | VkEventCreateInfo event_create_info{}; | ||||
4824 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
4825 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); | ||||
4826 | |||||
4827 | VkCommandPool command_pool; | ||||
4828 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
4829 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
4830 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
4831 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
4832 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
4833 | &command_pool); | ||||
4834 | |||||
4835 | VkCommandBuffer command_buffer; | ||||
4836 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
4837 | command_buffer_allocate_info.sType = | ||||
4838 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
4839 | command_buffer_allocate_info.commandPool = command_pool; | ||||
4840 | command_buffer_allocate_info.commandBufferCount = 1; | ||||
4841 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
4842 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
4843 | &command_buffer); | ||||
4844 | |||||
4845 | VkQueue queue = VK_NULL_HANDLE; | ||||
4846 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 4847 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 4848 | |
4849 | { | ||||
4850 | VkCommandBufferBeginInfo begin_info{}; | ||||
4851 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
4852 | vkBeginCommandBuffer(command_buffer, &begin_info); | ||||
4853 | |||||
4854 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, | ||||
4855 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, | ||||
4856 | nullptr, 0, nullptr); | ||||
4857 | vkCmdResetEvent(command_buffer, event, | ||||
4858 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); | ||||
4859 | vkEndCommandBuffer(command_buffer); | ||||
4860 | } | ||||
4861 | { | ||||
4862 | VkSubmitInfo submit_info{}; | ||||
4863 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
4864 | submit_info.commandBufferCount = 1; | ||||
4865 | submit_info.pCommandBuffers = &command_buffer; | ||||
4866 | submit_info.signalSemaphoreCount = 0; | ||||
4867 | submit_info.pSignalSemaphores = nullptr; | ||||
4868 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
4869 | } | ||||
4870 | { vkSetEvent(m_device->device(), event); } | ||||
4871 | |||||
4872 | vkQueueWaitIdle(queue); | ||||
4873 | |||||
4874 | vkDestroyEvent(m_device->device(), event, nullptr); | ||||
4875 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); | ||||
4876 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
4877 | |||||
4878 | m_errorMonitor->VerifyNotFound(); | ||||
4879 | } | ||||
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 4880 | // This is a positive test. No errors should be generated. |
Michael Lentine | f01fb38 | 2016-07-21 17:24:56 -0500 | [diff] [blame] | 4881 | TEST_F(VkLayerTest, QueryAndCopySecondaryCommandBuffers) { |
4882 | TEST_DESCRIPTION( | ||||
4883 | "Issue a query on a secondary command buffery and copy it on a primary."); | ||||
4884 | |||||
4885 | if ((m_device->queue_props.empty()) || | ||||
4886 | (m_device->queue_props[0].queueCount < 2)) | ||||
4887 | return; | ||||
4888 | |||||
4889 | m_errorMonitor->ExpectSuccess(); | ||||
4890 | |||||
4891 | VkQueryPool query_pool; | ||||
4892 | VkQueryPoolCreateInfo query_pool_create_info{}; | ||||
4893 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; | ||||
4894 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; | ||||
4895 | query_pool_create_info.queryCount = 1; | ||||
4896 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, | ||||
4897 | &query_pool); | ||||
4898 | |||||
4899 | VkCommandPool command_pool; | ||||
4900 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
4901 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
4902 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
4903 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
4904 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
4905 | &command_pool); | ||||
4906 | |||||
4907 | VkCommandBuffer command_buffer; | ||||
4908 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
4909 | command_buffer_allocate_info.sType = | ||||
4910 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
4911 | command_buffer_allocate_info.commandPool = command_pool; | ||||
4912 | command_buffer_allocate_info.commandBufferCount = 1; | ||||
4913 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
4914 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
4915 | &command_buffer); | ||||
4916 | |||||
4917 | VkCommandBuffer secondary_command_buffer; | ||||
4918 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; | ||||
4919 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
4920 | &secondary_command_buffer); | ||||
4921 | |||||
4922 | VkQueue queue = VK_NULL_HANDLE; | ||||
4923 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
4924 | 1, &queue); | ||||
4925 | |||||
4926 | uint32_t qfi = 0; | ||||
4927 | VkBufferCreateInfo buff_create_info = {}; | ||||
4928 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
4929 | buff_create_info.size = 1024; | ||||
4930 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; | ||||
4931 | buff_create_info.queueFamilyIndexCount = 1; | ||||
4932 | buff_create_info.pQueueFamilyIndices = &qfi; | ||||
4933 | |||||
4934 | VkResult err; | ||||
4935 | VkBuffer buffer; | ||||
4936 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); | ||||
4937 | ASSERT_VK_SUCCESS(err); | ||||
4938 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
4939 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
4940 | mem_alloc.pNext = NULL; | ||||
4941 | mem_alloc.allocationSize = 1024; | ||||
4942 | mem_alloc.memoryTypeIndex = 0; | ||||
4943 | |||||
4944 | VkMemoryRequirements memReqs; | ||||
4945 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); | ||||
4946 | bool pass = | ||||
4947 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); | ||||
4948 | if (!pass) { | ||||
4949 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
4950 | return; | ||||
4951 | } | ||||
4952 | |||||
4953 | VkDeviceMemory mem; | ||||
4954 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); | ||||
4955 | ASSERT_VK_SUCCESS(err); | ||||
4956 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
4957 | ASSERT_VK_SUCCESS(err); | ||||
4958 | |||||
4959 | VkCommandBufferInheritanceInfo hinfo = {}; | ||||
4960 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; | ||||
4961 | hinfo.renderPass = VK_NULL_HANDLE; | ||||
4962 | hinfo.subpass = 0; | ||||
4963 | hinfo.framebuffer = VK_NULL_HANDLE; | ||||
4964 | hinfo.occlusionQueryEnable = VK_FALSE; | ||||
4965 | hinfo.queryFlags = 0; | ||||
4966 | hinfo.pipelineStatistics = 0; | ||||
4967 | |||||
4968 | { | ||||
4969 | VkCommandBufferBeginInfo begin_info{}; | ||||
4970 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
4971 | begin_info.pInheritanceInfo = &hinfo; | ||||
4972 | vkBeginCommandBuffer(secondary_command_buffer, &begin_info); | ||||
4973 | |||||
4974 | vkCmdResetQueryPool(secondary_command_buffer, query_pool, 0, 1); | ||||
4975 | vkCmdWriteTimestamp(secondary_command_buffer, | ||||
4976 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); | ||||
4977 | |||||
4978 | vkEndCommandBuffer(secondary_command_buffer); | ||||
4979 | |||||
4980 | begin_info.pInheritanceInfo = nullptr; | ||||
4981 | vkBeginCommandBuffer(command_buffer, &begin_info); | ||||
4982 | |||||
4983 | vkCmdExecuteCommands(command_buffer, 1, &secondary_command_buffer); | ||||
4984 | vkCmdCopyQueryPoolResults(command_buffer, query_pool, 0, 1, buffer, | ||||
4985 | 0, 0, 0); | ||||
4986 | |||||
4987 | vkEndCommandBuffer(command_buffer); | ||||
4988 | } | ||||
4989 | { | ||||
4990 | VkSubmitInfo submit_info{}; | ||||
4991 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
4992 | submit_info.commandBufferCount = 1; | ||||
4993 | submit_info.pCommandBuffers = &command_buffer; | ||||
4994 | submit_info.signalSemaphoreCount = 0; | ||||
4995 | submit_info.pSignalSemaphores = nullptr; | ||||
4996 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
4997 | } | ||||
4998 | |||||
4999 | vkQueueWaitIdle(queue); | ||||
5000 | |||||
5001 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); | ||||
5002 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); | ||||
5003 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &secondary_command_buffer); | ||||
5004 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5005 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
5006 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
5007 | |||||
5008 | m_errorMonitor->VerifyNotFound(); | ||||
5009 | } | ||||
5010 | |||||
5011 | // This is a positive test. No errors should be generated. | ||||
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 5012 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { |
5013 | TEST_DESCRIPTION( | ||||
5014 | "Issue a query and copy from it on a second command buffer."); | ||||
5015 | |||||
5016 | if ((m_device->queue_props.empty()) || | ||||
5017 | (m_device->queue_props[0].queueCount < 2)) | ||||
5018 | return; | ||||
5019 | |||||
5020 | m_errorMonitor->ExpectSuccess(); | ||||
5021 | |||||
5022 | VkQueryPool query_pool; | ||||
5023 | VkQueryPoolCreateInfo query_pool_create_info{}; | ||||
5024 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; | ||||
5025 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; | ||||
5026 | query_pool_create_info.queryCount = 1; | ||||
5027 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, | ||||
5028 | &query_pool); | ||||
5029 | |||||
5030 | VkCommandPool command_pool; | ||||
5031 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5032 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5033 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5034 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5035 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5036 | &command_pool); | ||||
5037 | |||||
5038 | VkCommandBuffer command_buffer[2]; | ||||
5039 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5040 | command_buffer_allocate_info.sType = | ||||
5041 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5042 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5043 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5044 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5045 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5046 | command_buffer); | ||||
5047 | |||||
5048 | VkQueue queue = VK_NULL_HANDLE; | ||||
5049 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
5050 | 1, &queue); | ||||
5051 | |||||
5052 | uint32_t qfi = 0; | ||||
5053 | VkBufferCreateInfo buff_create_info = {}; | ||||
5054 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
5055 | buff_create_info.size = 1024; | ||||
5056 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; | ||||
5057 | buff_create_info.queueFamilyIndexCount = 1; | ||||
5058 | buff_create_info.pQueueFamilyIndices = &qfi; | ||||
5059 | |||||
5060 | VkResult err; | ||||
5061 | VkBuffer buffer; | ||||
5062 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); | ||||
5063 | ASSERT_VK_SUCCESS(err); | ||||
5064 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
5065 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
5066 | mem_alloc.pNext = NULL; | ||||
5067 | mem_alloc.allocationSize = 1024; | ||||
5068 | mem_alloc.memoryTypeIndex = 0; | ||||
5069 | |||||
5070 | VkMemoryRequirements memReqs; | ||||
5071 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); | ||||
5072 | bool pass = | ||||
5073 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); | ||||
5074 | if (!pass) { | ||||
5075 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
5076 | return; | ||||
5077 | } | ||||
5078 | |||||
5079 | VkDeviceMemory mem; | ||||
5080 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); | ||||
5081 | ASSERT_VK_SUCCESS(err); | ||||
5082 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
5083 | ASSERT_VK_SUCCESS(err); | ||||
5084 | |||||
5085 | { | ||||
5086 | VkCommandBufferBeginInfo begin_info{}; | ||||
5087 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5088 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5089 | |||||
5090 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); | ||||
5091 | vkCmdWriteTimestamp(command_buffer[0], | ||||
5092 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); | ||||
5093 | |||||
5094 | vkEndCommandBuffer(command_buffer[0]); | ||||
5095 | |||||
5096 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5097 | |||||
5098 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, | ||||
5099 | 0, 0, 0); | ||||
5100 | |||||
5101 | vkEndCommandBuffer(command_buffer[1]); | ||||
5102 | } | ||||
5103 | { | ||||
5104 | VkSubmitInfo submit_info{}; | ||||
5105 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5106 | submit_info.commandBufferCount = 2; | ||||
5107 | submit_info.pCommandBuffers = command_buffer; | ||||
5108 | submit_info.signalSemaphoreCount = 0; | ||||
5109 | submit_info.pSignalSemaphores = nullptr; | ||||
5110 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5111 | } | ||||
5112 | |||||
5113 | vkQueueWaitIdle(queue); | ||||
5114 | |||||
5115 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); | ||||
5116 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); | ||||
5117 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5118 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
5119 | vkFreeMemory(m_device->device(), mem, NULL); | ||||
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 5120 | |
5121 | m_errorMonitor->VerifyNotFound(); | ||||
5122 | } | ||||
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 5123 | |
5124 | TEST_F(VkLayerTest, ResetEventThenSet) { | ||||
5125 | TEST_DESCRIPTION( | ||||
5126 | "Reset an event then set it after the reset has been submitted."); | ||||
5127 | |||||
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 5128 | m_errorMonitor->ExpectSuccess(); |
5129 | |||||
5130 | VkEvent event; | ||||
5131 | VkEventCreateInfo event_create_info{}; | ||||
5132 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
5133 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); | ||||
5134 | |||||
5135 | VkCommandPool command_pool; | ||||
5136 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5137 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5138 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5139 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5140 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5141 | &command_pool); | ||||
5142 | |||||
5143 | VkCommandBuffer command_buffer; | ||||
5144 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5145 | command_buffer_allocate_info.sType = | ||||
5146 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5147 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5148 | command_buffer_allocate_info.commandBufferCount = 1; | ||||
5149 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5150 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5151 | &command_buffer); | ||||
5152 | |||||
5153 | VkQueue queue = VK_NULL_HANDLE; | ||||
5154 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
Tony Barbour | fe302c0 | 2016-06-06 13:05:19 -0600 | [diff] [blame] | 5155 | 0, &queue); |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 5156 | |
5157 | { | ||||
5158 | VkCommandBufferBeginInfo begin_info{}; | ||||
5159 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5160 | vkBeginCommandBuffer(command_buffer, &begin_info); | ||||
5161 | |||||
5162 | vkCmdResetEvent(command_buffer, event, | ||||
5163 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); | ||||
5164 | vkCmdWaitEvents(command_buffer, 1, &event, | ||||
5165 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5166 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, | ||||
5167 | nullptr, 0, nullptr); | ||||
5168 | vkEndCommandBuffer(command_buffer); | ||||
5169 | } | ||||
5170 | { | ||||
5171 | VkSubmitInfo submit_info{}; | ||||
5172 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5173 | submit_info.commandBufferCount = 1; | ||||
5174 | submit_info.pCommandBuffers = &command_buffer; | ||||
5175 | submit_info.signalSemaphoreCount = 0; | ||||
5176 | submit_info.pSignalSemaphores = nullptr; | ||||
5177 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5178 | } | ||||
5179 | { | ||||
5180 | m_errorMonitor->SetDesiredFailureMsg( | ||||
5181 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " | ||||
5182 | "0x1 that is already in use by a " | ||||
5183 | "command buffer."); | ||||
5184 | vkSetEvent(m_device->device(), event); | ||||
5185 | m_errorMonitor->VerifyFound(); | ||||
5186 | } | ||||
5187 | |||||
5188 | vkQueueWaitIdle(queue); | ||||
5189 | |||||
5190 | vkDestroyEvent(m_device->device(), event, nullptr); | ||||
5191 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); | ||||
5192 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5193 | } | ||||
5194 | |||||
5195 | // This is a positive test. No errors should be generated. | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 5196 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
5197 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " | ||||
5198 | "run through a Submit & WaitForFences cycle 3 times. This " | ||||
5199 | "previously revealed a bug so running this positive test " | ||||
5200 | "to prevent a regression."); | ||||
5201 | m_errorMonitor->ExpectSuccess(); | ||||
5202 | |||||
5203 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
5204 | VkQueue queue = VK_NULL_HANDLE; | ||||
5205 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
5206 | 0, &queue); | ||||
5207 | |||||
5208 | static const uint32_t NUM_OBJECTS = 2; | ||||
5209 | static const uint32_t NUM_FRAMES = 3; | ||||
5210 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; | ||||
5211 | VkFence fences[NUM_OBJECTS] = {}; | ||||
5212 | |||||
5213 | VkCommandPool cmd_pool; | ||||
5214 | VkCommandPoolCreateInfo cmd_pool_ci = {}; | ||||
5215 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5216 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5217 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5218 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, | ||||
5219 | nullptr, &cmd_pool); | ||||
5220 | ASSERT_VK_SUCCESS(err); | ||||
5221 | |||||
5222 | VkCommandBufferAllocateInfo cmd_buf_info = {}; | ||||
5223 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5224 | cmd_buf_info.commandPool = cmd_pool; | ||||
5225 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5226 | cmd_buf_info.commandBufferCount = 1; | ||||
5227 | |||||
5228 | VkFenceCreateInfo fence_ci = {}; | ||||
5229 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5230 | fence_ci.pNext = nullptr; | ||||
5231 | fence_ci.flags = 0; | ||||
5232 | |||||
5233 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { | ||||
5234 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, | ||||
5235 | &cmd_buffers[i]); | ||||
5236 | ASSERT_VK_SUCCESS(err); | ||||
5237 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); | ||||
5238 | ASSERT_VK_SUCCESS(err); | ||||
5239 | } | ||||
5240 | |||||
5241 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { | ||||
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 5242 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
5243 | // Create empty cmd buffer | ||||
5244 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; | ||||
5245 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 5246 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 5247 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
5248 | ASSERT_VK_SUCCESS(err); | ||||
5249 | err = vkEndCommandBuffer(cmd_buffers[obj]); | ||||
5250 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 5251 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 5252 | VkSubmitInfo submit_info = {}; |
5253 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5254 | submit_info.commandBufferCount = 1; | ||||
5255 | submit_info.pCommandBuffers = &cmd_buffers[obj]; | ||||
5256 | // Submit cmd buffer and wait for fence | ||||
5257 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); | ||||
5258 | ASSERT_VK_SUCCESS(err); | ||||
5259 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, | ||||
5260 | UINT64_MAX); | ||||
5261 | ASSERT_VK_SUCCESS(err); | ||||
5262 | err = vkResetFences(m_device->device(), 1, &fences[obj]); | ||||
5263 | ASSERT_VK_SUCCESS(err); | ||||
5264 | } | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 5265 | } |
5266 | m_errorMonitor->VerifyNotFound(); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 5267 | vkDestroyCommandPool(m_device->device(), cmd_pool, NULL); |
5268 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { | ||||
5269 | vkDestroyFence(m_device->device(), fences[i], nullptr); | ||||
5270 | } | ||||
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 5271 | } |
5272 | // This is a positive test. No errors should be generated. | ||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5273 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
5274 | |||||
5275 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
5276 | "submitted on separate queues followed by a QueueWaitIdle."); | ||||
5277 | |||||
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 5278 | if ((m_device->queue_props.empty()) || |
5279 | (m_device->queue_props[0].queueCount < 2)) | ||||
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 5280 | return; |
5281 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5282 | m_errorMonitor->ExpectSuccess(); |
5283 | |||||
5284 | VkSemaphore semaphore; | ||||
5285 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
5286 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
5287 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
5288 | &semaphore); | ||||
5289 | |||||
5290 | VkCommandPool command_pool; | ||||
5291 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5292 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5293 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5294 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5295 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5296 | &command_pool); | ||||
5297 | |||||
5298 | VkCommandBuffer command_buffer[2]; | ||||
5299 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5300 | command_buffer_allocate_info.sType = | ||||
5301 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5302 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5303 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5304 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5305 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5306 | command_buffer); | ||||
5307 | |||||
5308 | VkQueue queue = VK_NULL_HANDLE; | ||||
5309 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
5310 | 1, &queue); | ||||
5311 | |||||
5312 | { | ||||
5313 | VkCommandBufferBeginInfo begin_info{}; | ||||
5314 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5315 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5316 | |||||
5317 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5318 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5319 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5320 | 0, nullptr, 0, nullptr); | ||||
5321 | |||||
5322 | VkViewport viewport{}; | ||||
5323 | viewport.maxDepth = 1.0f; | ||||
5324 | viewport.minDepth = 0.0f; | ||||
5325 | viewport.width = 512; | ||||
5326 | viewport.height = 512; | ||||
5327 | viewport.x = 0; | ||||
5328 | viewport.y = 0; | ||||
5329 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5330 | vkEndCommandBuffer(command_buffer[0]); | ||||
5331 | } | ||||
5332 | { | ||||
5333 | VkCommandBufferBeginInfo begin_info{}; | ||||
5334 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5335 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5336 | |||||
5337 | VkViewport viewport{}; | ||||
5338 | viewport.maxDepth = 1.0f; | ||||
5339 | viewport.minDepth = 0.0f; | ||||
5340 | viewport.width = 512; | ||||
5341 | viewport.height = 512; | ||||
5342 | viewport.x = 0; | ||||
5343 | viewport.y = 0; | ||||
5344 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5345 | vkEndCommandBuffer(command_buffer[1]); | ||||
5346 | } | ||||
5347 | { | ||||
5348 | VkSubmitInfo submit_info{}; | ||||
5349 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5350 | submit_info.commandBufferCount = 1; | ||||
5351 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
5352 | submit_info.signalSemaphoreCount = 1; | ||||
5353 | submit_info.pSignalSemaphores = &semaphore; | ||||
5354 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5355 | } | ||||
5356 | { | ||||
5357 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5358 | VkSubmitInfo submit_info{}; | ||||
5359 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5360 | submit_info.commandBufferCount = 1; | ||||
5361 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5362 | submit_info.waitSemaphoreCount = 1; | ||||
5363 | submit_info.pWaitSemaphores = &semaphore; | ||||
5364 | submit_info.pWaitDstStageMask = flags; | ||||
5365 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5366 | } | ||||
5367 | |||||
5368 | vkQueueWaitIdle(m_device->m_queue); | ||||
5369 | |||||
5370 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
5371 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5372 | &command_buffer[0]); | ||||
5373 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5374 | |||||
5375 | m_errorMonitor->VerifyNotFound(); | ||||
5376 | } | ||||
5377 | |||||
5378 | // This is a positive test. No errors should be generated. | ||||
5379 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { | ||||
5380 | |||||
5381 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
5382 | "submitted on separate queues, the second having a fence" | ||||
5383 | "followed by a QueueWaitIdle."); | ||||
5384 | |||||
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 5385 | if ((m_device->queue_props.empty()) || |
5386 | (m_device->queue_props[0].queueCount < 2)) | ||||
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 5387 | return; |
5388 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5389 | m_errorMonitor->ExpectSuccess(); |
5390 | |||||
5391 | VkFence fence; | ||||
5392 | VkFenceCreateInfo fence_create_info{}; | ||||
5393 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5394 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
5395 | |||||
5396 | VkSemaphore semaphore; | ||||
5397 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
5398 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
5399 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
5400 | &semaphore); | ||||
5401 | |||||
5402 | VkCommandPool command_pool; | ||||
5403 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5404 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5405 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5406 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5407 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5408 | &command_pool); | ||||
5409 | |||||
5410 | VkCommandBuffer command_buffer[2]; | ||||
5411 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5412 | command_buffer_allocate_info.sType = | ||||
5413 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5414 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5415 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5416 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5417 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5418 | command_buffer); | ||||
5419 | |||||
5420 | VkQueue queue = VK_NULL_HANDLE; | ||||
5421 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
5422 | 1, &queue); | ||||
5423 | |||||
5424 | { | ||||
5425 | VkCommandBufferBeginInfo begin_info{}; | ||||
5426 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5427 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5428 | |||||
5429 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5430 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5431 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5432 | 0, nullptr, 0, nullptr); | ||||
5433 | |||||
5434 | VkViewport viewport{}; | ||||
5435 | viewport.maxDepth = 1.0f; | ||||
5436 | viewport.minDepth = 0.0f; | ||||
5437 | viewport.width = 512; | ||||
5438 | viewport.height = 512; | ||||
5439 | viewport.x = 0; | ||||
5440 | viewport.y = 0; | ||||
5441 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5442 | vkEndCommandBuffer(command_buffer[0]); | ||||
5443 | } | ||||
5444 | { | ||||
5445 | VkCommandBufferBeginInfo begin_info{}; | ||||
5446 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5447 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5448 | |||||
5449 | VkViewport viewport{}; | ||||
5450 | viewport.maxDepth = 1.0f; | ||||
5451 | viewport.minDepth = 0.0f; | ||||
5452 | viewport.width = 512; | ||||
5453 | viewport.height = 512; | ||||
5454 | viewport.x = 0; | ||||
5455 | viewport.y = 0; | ||||
5456 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5457 | vkEndCommandBuffer(command_buffer[1]); | ||||
5458 | } | ||||
5459 | { | ||||
5460 | VkSubmitInfo submit_info{}; | ||||
5461 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5462 | submit_info.commandBufferCount = 1; | ||||
5463 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
5464 | submit_info.signalSemaphoreCount = 1; | ||||
5465 | submit_info.pSignalSemaphores = &semaphore; | ||||
5466 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5467 | } | ||||
5468 | { | ||||
5469 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5470 | VkSubmitInfo submit_info{}; | ||||
5471 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5472 | submit_info.commandBufferCount = 1; | ||||
5473 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5474 | submit_info.waitSemaphoreCount = 1; | ||||
5475 | submit_info.pWaitSemaphores = &semaphore; | ||||
5476 | submit_info.pWaitDstStageMask = flags; | ||||
5477 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
5478 | } | ||||
5479 | |||||
5480 | vkQueueWaitIdle(m_device->m_queue); | ||||
5481 | |||||
5482 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
5483 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
5484 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5485 | &command_buffer[0]); | ||||
5486 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5487 | |||||
5488 | m_errorMonitor->VerifyNotFound(); | ||||
5489 | } | ||||
5490 | |||||
5491 | // This is a positive test. No errors should be generated. | ||||
5492 | TEST_F(VkLayerTest, | ||||
5493 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { | ||||
5494 | |||||
5495 | TEST_DESCRIPTION( | ||||
5496 | "Two command buffers, each in a separate QueueSubmit call " | ||||
5497 | "submitted on separate queues, the second having a fence" | ||||
5498 | "followed by two consecutive WaitForFences calls on the same fence."); | ||||
5499 | |||||
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 5500 | if ((m_device->queue_props.empty()) || |
5501 | (m_device->queue_props[0].queueCount < 2)) | ||||
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 5502 | return; |
5503 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5504 | m_errorMonitor->ExpectSuccess(); |
5505 | |||||
5506 | VkFence fence; | ||||
5507 | VkFenceCreateInfo fence_create_info{}; | ||||
5508 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5509 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
5510 | |||||
5511 | VkSemaphore semaphore; | ||||
5512 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
5513 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
5514 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
5515 | &semaphore); | ||||
5516 | |||||
5517 | VkCommandPool command_pool; | ||||
5518 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5519 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5520 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5521 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5522 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5523 | &command_pool); | ||||
5524 | |||||
5525 | VkCommandBuffer command_buffer[2]; | ||||
5526 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5527 | command_buffer_allocate_info.sType = | ||||
5528 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5529 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5530 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5531 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5532 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5533 | command_buffer); | ||||
5534 | |||||
5535 | VkQueue queue = VK_NULL_HANDLE; | ||||
5536 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
5537 | 1, &queue); | ||||
5538 | |||||
5539 | { | ||||
5540 | VkCommandBufferBeginInfo begin_info{}; | ||||
5541 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5542 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5543 | |||||
5544 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5545 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5546 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5547 | 0, nullptr, 0, nullptr); | ||||
5548 | |||||
5549 | VkViewport viewport{}; | ||||
5550 | viewport.maxDepth = 1.0f; | ||||
5551 | viewport.minDepth = 0.0f; | ||||
5552 | viewport.width = 512; | ||||
5553 | viewport.height = 512; | ||||
5554 | viewport.x = 0; | ||||
5555 | viewport.y = 0; | ||||
5556 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5557 | vkEndCommandBuffer(command_buffer[0]); | ||||
5558 | } | ||||
5559 | { | ||||
5560 | VkCommandBufferBeginInfo begin_info{}; | ||||
5561 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5562 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5563 | |||||
5564 | VkViewport viewport{}; | ||||
5565 | viewport.maxDepth = 1.0f; | ||||
5566 | viewport.minDepth = 0.0f; | ||||
5567 | viewport.width = 512; | ||||
5568 | viewport.height = 512; | ||||
5569 | viewport.x = 0; | ||||
5570 | viewport.y = 0; | ||||
5571 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5572 | vkEndCommandBuffer(command_buffer[1]); | ||||
5573 | } | ||||
5574 | { | ||||
5575 | VkSubmitInfo submit_info{}; | ||||
5576 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5577 | submit_info.commandBufferCount = 1; | ||||
5578 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
5579 | submit_info.signalSemaphoreCount = 1; | ||||
5580 | submit_info.pSignalSemaphores = &semaphore; | ||||
5581 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5582 | } | ||||
5583 | { | ||||
5584 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5585 | VkSubmitInfo submit_info{}; | ||||
5586 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5587 | submit_info.commandBufferCount = 1; | ||||
5588 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5589 | submit_info.waitSemaphoreCount = 1; | ||||
5590 | submit_info.pWaitSemaphores = &semaphore; | ||||
5591 | submit_info.pWaitDstStageMask = flags; | ||||
5592 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
5593 | } | ||||
5594 | |||||
5595 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
5596 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
5597 | |||||
5598 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
5599 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
5600 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5601 | &command_buffer[0]); | ||||
5602 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5603 | |||||
5604 | m_errorMonitor->VerifyNotFound(); | ||||
5605 | } | ||||
5606 | |||||
Chris Forbes | 0f8126b | 2016-06-20 17:48:22 +1200 | [diff] [blame] | 5607 | #if 0 |
5608 | TEST_F(VkLayerTest, TwoQueuesEnsureCorrectRetirementWithWorkStolen) { | ||||
5609 | if ((m_device->queue_props.empty()) || | ||||
5610 | (m_device->queue_props[0].queueCount < 2)) { | ||||
5611 | printf("Test requires two queues, skipping\n"); | ||||
5612 | return; | ||||
5613 | } | ||||
5614 | |||||
5615 | VkResult err; | ||||
5616 | |||||
5617 | m_errorMonitor->ExpectSuccess(); | ||||
5618 | |||||
5619 | VkQueue q0 = m_device->m_queue; | ||||
5620 | VkQueue q1 = nullptr; | ||||
5621 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, 1, &q1); | ||||
5622 | ASSERT_NE(q1, nullptr); | ||||
5623 | |||||
5624 | // An (empty) command buffer. We must have work in the first submission -- | ||||
5625 | // the layer treats unfenced work differently from fenced work. | ||||
5626 | VkCommandPoolCreateInfo cpci = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, nullptr, 0, 0 }; | ||||
5627 | VkCommandPool pool; | ||||
5628 | err = vkCreateCommandPool(m_device->device(), &cpci, nullptr, &pool); | ||||
5629 | ASSERT_VK_SUCCESS(err); | ||||
5630 | VkCommandBufferAllocateInfo cbai = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, nullptr, | ||||
5631 | pool, VK_COMMAND_BUFFER_LEVEL_PRIMARY, 1 | ||||
5632 | }; | ||||
5633 | VkCommandBuffer cb; | ||||
5634 | err = vkAllocateCommandBuffers(m_device->device(), &cbai, &cb); | ||||
5635 | ASSERT_VK_SUCCESS(err); | ||||
5636 | VkCommandBufferBeginInfo cbbi = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, | ||||
5637 | 0, nullptr | ||||
5638 | }; | ||||
5639 | err = vkBeginCommandBuffer(cb, &cbbi); | ||||
5640 | ASSERT_VK_SUCCESS(err); | ||||
5641 | err = vkEndCommandBuffer(cb); | ||||
5642 | ASSERT_VK_SUCCESS(err); | ||||
5643 | |||||
5644 | // A semaphore | ||||
5645 | VkSemaphoreCreateInfo sci = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, nullptr, 0 }; | ||||
5646 | VkSemaphore s; | ||||
5647 | err = vkCreateSemaphore(m_device->device(), &sci, nullptr, &s); | ||||
5648 | ASSERT_VK_SUCCESS(err); | ||||
5649 | |||||
5650 | // First submission, to q0 | ||||
5651 | VkSubmitInfo s0 = { | ||||
5652 | VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, | ||||
5653 | 0, nullptr, nullptr, | ||||
5654 | 1, &cb, | ||||
5655 | 1, &s | ||||
5656 | }; | ||||
5657 | |||||
5658 | err = vkQueueSubmit(q0, 1, &s0, VK_NULL_HANDLE); | ||||
5659 | ASSERT_VK_SUCCESS(err); | ||||
5660 | |||||
5661 | // Second submission, to q1, waiting on s | ||||
5662 | VkFlags waitmask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; // doesn't really matter what this value is. | ||||
5663 | VkSubmitInfo s1 = { | ||||
5664 | VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, | ||||
5665 | 1, &s, &waitmask, | ||||
5666 | 0, nullptr, | ||||
5667 | 0, nullptr | ||||
5668 | }; | ||||
5669 | |||||
5670 | err = vkQueueSubmit(q1, 1, &s1, VK_NULL_HANDLE); | ||||
5671 | ASSERT_VK_SUCCESS(err); | ||||
5672 | |||||
5673 | // Wait for q0 idle | ||||
5674 | err = vkQueueWaitIdle(q0); | ||||
5675 | ASSERT_VK_SUCCESS(err); | ||||
5676 | |||||
5677 | // Command buffer should have been completed (it was on q0); reset the pool. | ||||
5678 | vkFreeCommandBuffers(m_device->device(), pool, 1, &cb); | ||||
5679 | |||||
5680 | m_errorMonitor->VerifyNotFound(); | ||||
5681 | |||||
5682 | // Force device completely idle and clean up resources | ||||
5683 | vkDeviceWaitIdle(m_device->device()); | ||||
5684 | vkDestroyCommandPool(m_device->device(), pool, nullptr); | ||||
5685 | vkDestroySemaphore(m_device->device(), s, nullptr); | ||||
5686 | } | ||||
5687 | #endif | ||||
5688 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5689 | // This is a positive test. No errors should be generated. |
5690 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { | ||||
5691 | |||||
5692 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
5693 | "submitted on separate queues, the second having a fence, " | ||||
5694 | "followed by a WaitForFences call."); | ||||
5695 | |||||
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 5696 | if ((m_device->queue_props.empty()) || |
5697 | (m_device->queue_props[0].queueCount < 2)) | ||||
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 5698 | return; |
5699 | |||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 5700 | m_errorMonitor->ExpectSuccess(); |
5701 | |||||
5702 | VkFence fence; | ||||
5703 | VkFenceCreateInfo fence_create_info{}; | ||||
5704 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5705 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
5706 | |||||
5707 | VkSemaphore semaphore; | ||||
5708 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
5709 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
5710 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
5711 | &semaphore); | ||||
5712 | |||||
5713 | VkCommandPool command_pool; | ||||
5714 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5715 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5716 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5717 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5718 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5719 | &command_pool); | ||||
5720 | |||||
5721 | VkCommandBuffer command_buffer[2]; | ||||
5722 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5723 | command_buffer_allocate_info.sType = | ||||
5724 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5725 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5726 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5727 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5728 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5729 | command_buffer); | ||||
5730 | |||||
5731 | VkQueue queue = VK_NULL_HANDLE; | ||||
5732 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, | ||||
5733 | 1, &queue); | ||||
5734 | |||||
5735 | |||||
5736 | { | ||||
5737 | VkCommandBufferBeginInfo begin_info{}; | ||||
5738 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5739 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5740 | |||||
5741 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5742 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5743 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5744 | 0, nullptr, 0, nullptr); | ||||
5745 | |||||
5746 | VkViewport viewport{}; | ||||
5747 | viewport.maxDepth = 1.0f; | ||||
5748 | viewport.minDepth = 0.0f; | ||||
5749 | viewport.width = 512; | ||||
5750 | viewport.height = 512; | ||||
5751 | viewport.x = 0; | ||||
5752 | viewport.y = 0; | ||||
5753 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5754 | vkEndCommandBuffer(command_buffer[0]); | ||||
5755 | } | ||||
5756 | { | ||||
5757 | VkCommandBufferBeginInfo begin_info{}; | ||||
5758 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5759 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5760 | |||||
5761 | VkViewport viewport{}; | ||||
5762 | viewport.maxDepth = 1.0f; | ||||
5763 | viewport.minDepth = 0.0f; | ||||
5764 | viewport.width = 512; | ||||
5765 | viewport.height = 512; | ||||
5766 | viewport.x = 0; | ||||
5767 | viewport.y = 0; | ||||
5768 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5769 | vkEndCommandBuffer(command_buffer[1]); | ||||
5770 | } | ||||
5771 | { | ||||
5772 | VkSubmitInfo submit_info{}; | ||||
5773 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5774 | submit_info.commandBufferCount = 1; | ||||
5775 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
5776 | submit_info.signalSemaphoreCount = 1; | ||||
5777 | submit_info.pSignalSemaphores = &semaphore; | ||||
5778 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5779 | } | ||||
5780 | { | ||||
5781 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5782 | VkSubmitInfo submit_info{}; | ||||
5783 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5784 | submit_info.commandBufferCount = 1; | ||||
5785 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5786 | submit_info.waitSemaphoreCount = 1; | ||||
5787 | submit_info.pWaitSemaphores = &semaphore; | ||||
5788 | submit_info.pWaitDstStageMask = flags; | ||||
5789 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
5790 | } | ||||
5791 | |||||
5792 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
5793 | |||||
5794 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
5795 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
5796 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5797 | &command_buffer[0]); | ||||
5798 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5799 | |||||
5800 | m_errorMonitor->VerifyNotFound(); | ||||
5801 | } | ||||
5802 | |||||
5803 | // This is a positive test. No errors should be generated. | ||||
5804 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { | ||||
5805 | |||||
5806 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
5807 | "on the same queue, sharing a signal/wait semaphore, the " | ||||
5808 | "second having a fence, " | ||||
5809 | "followed by a WaitForFences call."); | ||||
5810 | |||||
5811 | m_errorMonitor->ExpectSuccess(); | ||||
5812 | |||||
5813 | VkFence fence; | ||||
5814 | VkFenceCreateInfo fence_create_info{}; | ||||
5815 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5816 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
5817 | |||||
5818 | VkSemaphore semaphore; | ||||
5819 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
5820 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
5821 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
5822 | &semaphore); | ||||
5823 | |||||
5824 | VkCommandPool command_pool; | ||||
5825 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5826 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5827 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5828 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5829 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5830 | &command_pool); | ||||
5831 | |||||
5832 | VkCommandBuffer command_buffer[2]; | ||||
5833 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5834 | command_buffer_allocate_info.sType = | ||||
5835 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5836 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5837 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5838 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5839 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5840 | command_buffer); | ||||
5841 | |||||
5842 | { | ||||
5843 | VkCommandBufferBeginInfo begin_info{}; | ||||
5844 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5845 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5846 | |||||
5847 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5848 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5849 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5850 | 0, nullptr, 0, nullptr); | ||||
5851 | |||||
5852 | VkViewport viewport{}; | ||||
5853 | viewport.maxDepth = 1.0f; | ||||
5854 | viewport.minDepth = 0.0f; | ||||
5855 | viewport.width = 512; | ||||
5856 | viewport.height = 512; | ||||
5857 | viewport.x = 0; | ||||
5858 | viewport.y = 0; | ||||
5859 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5860 | vkEndCommandBuffer(command_buffer[0]); | ||||
5861 | } | ||||
5862 | { | ||||
5863 | VkCommandBufferBeginInfo begin_info{}; | ||||
5864 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5865 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5866 | |||||
5867 | VkViewport viewport{}; | ||||
5868 | viewport.maxDepth = 1.0f; | ||||
5869 | viewport.minDepth = 0.0f; | ||||
5870 | viewport.width = 512; | ||||
5871 | viewport.height = 512; | ||||
5872 | viewport.x = 0; | ||||
5873 | viewport.y = 0; | ||||
5874 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5875 | vkEndCommandBuffer(command_buffer[1]); | ||||
5876 | } | ||||
5877 | { | ||||
5878 | VkSubmitInfo submit_info{}; | ||||
5879 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5880 | submit_info.commandBufferCount = 1; | ||||
5881 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
5882 | submit_info.signalSemaphoreCount = 1; | ||||
5883 | submit_info.pSignalSemaphores = &semaphore; | ||||
5884 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5885 | } | ||||
5886 | { | ||||
5887 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5888 | VkSubmitInfo submit_info{}; | ||||
5889 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5890 | submit_info.commandBufferCount = 1; | ||||
5891 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5892 | submit_info.waitSemaphoreCount = 1; | ||||
5893 | submit_info.pWaitSemaphores = &semaphore; | ||||
5894 | submit_info.pWaitDstStageMask = flags; | ||||
5895 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
5896 | } | ||||
5897 | |||||
5898 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
5899 | |||||
5900 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
5901 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); | ||||
5902 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
5903 | &command_buffer[0]); | ||||
5904 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
5905 | |||||
5906 | m_errorMonitor->VerifyNotFound(); | ||||
5907 | } | ||||
5908 | |||||
5909 | // This is a positive test. No errors should be generated. | ||||
5910 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { | ||||
5911 | |||||
5912 | TEST_DESCRIPTION( | ||||
5913 | "Two command buffers, each in a separate QueueSubmit call " | ||||
5914 | "on the same queue, no fences, followed by a third QueueSubmit with NO " | ||||
5915 | "SubmitInfos but with a fence, followed by a WaitForFences call."); | ||||
5916 | |||||
5917 | m_errorMonitor->ExpectSuccess(); | ||||
5918 | |||||
5919 | VkFence fence; | ||||
5920 | VkFenceCreateInfo fence_create_info{}; | ||||
5921 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
5922 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
5923 | |||||
5924 | VkCommandPool command_pool; | ||||
5925 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
5926 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
5927 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
5928 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
5929 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
5930 | &command_pool); | ||||
5931 | |||||
5932 | VkCommandBuffer command_buffer[2]; | ||||
5933 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
5934 | command_buffer_allocate_info.sType = | ||||
5935 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
5936 | command_buffer_allocate_info.commandPool = command_pool; | ||||
5937 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
5938 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
5939 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
5940 | command_buffer); | ||||
5941 | |||||
5942 | { | ||||
5943 | VkCommandBufferBeginInfo begin_info{}; | ||||
5944 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5945 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
5946 | |||||
5947 | vkCmdPipelineBarrier(command_buffer[0], | ||||
5948 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
5949 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
5950 | 0, nullptr, 0, nullptr); | ||||
5951 | |||||
5952 | VkViewport viewport{}; | ||||
5953 | viewport.maxDepth = 1.0f; | ||||
5954 | viewport.minDepth = 0.0f; | ||||
5955 | viewport.width = 512; | ||||
5956 | viewport.height = 512; | ||||
5957 | viewport.x = 0; | ||||
5958 | viewport.y = 0; | ||||
5959 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
5960 | vkEndCommandBuffer(command_buffer[0]); | ||||
5961 | } | ||||
5962 | { | ||||
5963 | VkCommandBufferBeginInfo begin_info{}; | ||||
5964 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
5965 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
5966 | |||||
5967 | VkViewport viewport{}; | ||||
5968 | viewport.maxDepth = 1.0f; | ||||
5969 | viewport.minDepth = 0.0f; | ||||
5970 | viewport.width = 512; | ||||
5971 | viewport.height = 512; | ||||
5972 | viewport.x = 0; | ||||
5973 | viewport.y = 0; | ||||
5974 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
5975 | vkEndCommandBuffer(command_buffer[1]); | ||||
5976 | } | ||||
5977 | { | ||||
5978 | VkSubmitInfo submit_info{}; | ||||
5979 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5980 | submit_info.commandBufferCount = 1; | ||||
5981 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
5982 | submit_info.signalSemaphoreCount = 0; | ||||
5983 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; | ||||
5984 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5985 | } | ||||
5986 | { | ||||
5987 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
5988 | VkSubmitInfo submit_info{}; | ||||
5989 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
5990 | submit_info.commandBufferCount = 1; | ||||
5991 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
5992 | submit_info.waitSemaphoreCount = 0; | ||||
5993 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; | ||||
5994 | submit_info.pWaitDstStageMask = flags; | ||||
5995 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
5996 | } | ||||
5997 | |||||
5998 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); | ||||
5999 | |||||
Mike Stroyan | cd1c3e5 | 2016-06-21 09:20:01 -0600 | [diff] [blame] | 6000 | VkResult err = |
6001 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
6002 | ASSERT_VK_SUCCESS(err); | ||||
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 6003 | |
6004 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
6005 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
6006 | &command_buffer[0]); | ||||
6007 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
6008 | |||||
6009 | m_errorMonitor->VerifyNotFound(); | ||||
6010 | } | ||||
6011 | |||||
6012 | // This is a positive test. No errors should be generated. | ||||
6013 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { | ||||
6014 | |||||
6015 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " | ||||
6016 | "on the same queue, the second having a fence, followed " | ||||
6017 | "by a WaitForFences call."); | ||||
6018 | |||||
6019 | m_errorMonitor->ExpectSuccess(); | ||||
6020 | |||||
6021 | VkFence fence; | ||||
6022 | VkFenceCreateInfo fence_create_info{}; | ||||
6023 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
6024 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
6025 | |||||
6026 | VkCommandPool command_pool; | ||||
6027 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
6028 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
6029 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
6030 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
6031 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
6032 | &command_pool); | ||||
6033 | |||||
6034 | VkCommandBuffer command_buffer[2]; | ||||
6035 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
6036 | command_buffer_allocate_info.sType = | ||||
6037 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
6038 | command_buffer_allocate_info.commandPool = command_pool; | ||||
6039 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
6040 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
6041 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
6042 | command_buffer); | ||||
6043 | |||||
6044 | { | ||||
6045 | VkCommandBufferBeginInfo begin_info{}; | ||||
6046 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
6047 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
6048 | |||||
6049 | vkCmdPipelineBarrier(command_buffer[0], | ||||
6050 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
6051 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
6052 | 0, nullptr, 0, nullptr); | ||||
6053 | |||||
6054 | VkViewport viewport{}; | ||||
6055 | viewport.maxDepth = 1.0f; | ||||
6056 | viewport.minDepth = 0.0f; | ||||
6057 | viewport.width = 512; | ||||
6058 | viewport.height = 512; | ||||
6059 | viewport.x = 0; | ||||
6060 | viewport.y = 0; | ||||
6061 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
6062 | vkEndCommandBuffer(command_buffer[0]); | ||||
6063 | } | ||||
6064 | { | ||||
6065 | VkCommandBufferBeginInfo begin_info{}; | ||||
6066 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
6067 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
6068 | |||||
6069 | VkViewport viewport{}; | ||||
6070 | viewport.maxDepth = 1.0f; | ||||
6071 | viewport.minDepth = 0.0f; | ||||
6072 | viewport.width = 512; | ||||
6073 | viewport.height = 512; | ||||
6074 | viewport.x = 0; | ||||
6075 | viewport.y = 0; | ||||
6076 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
6077 | vkEndCommandBuffer(command_buffer[1]); | ||||
6078 | } | ||||
6079 | { | ||||
6080 | VkSubmitInfo submit_info{}; | ||||
6081 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
6082 | submit_info.commandBufferCount = 1; | ||||
6083 | submit_info.pCommandBuffers = &command_buffer[0]; | ||||
6084 | submit_info.signalSemaphoreCount = 0; | ||||
6085 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; | ||||
6086 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
6087 | } | ||||
6088 | { | ||||
6089 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
6090 | VkSubmitInfo submit_info{}; | ||||
6091 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
6092 | submit_info.commandBufferCount = 1; | ||||
6093 | submit_info.pCommandBuffers = &command_buffer[1]; | ||||
6094 | submit_info.waitSemaphoreCount = 0; | ||||
6095 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; | ||||
6096 | submit_info.pWaitDstStageMask = flags; | ||||
6097 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); | ||||
6098 | } | ||||
6099 | |||||
6100 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
6101 | |||||
6102 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
6103 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
6104 | &command_buffer[0]); | ||||
6105 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
6106 | |||||
6107 | m_errorMonitor->VerifyNotFound(); | ||||
6108 | } | ||||
6109 | |||||
6110 | // This is a positive test. No errors should be generated. | ||||
6111 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { | ||||
6112 | |||||
6113 | TEST_DESCRIPTION( | ||||
6114 | "Two command buffers each in a separate SubmitInfo sent in a single " | ||||
6115 | "QueueSubmit call followed by a WaitForFences call."); | ||||
6116 | |||||
6117 | m_errorMonitor->ExpectSuccess(); | ||||
6118 | |||||
6119 | VkFence fence; | ||||
6120 | VkFenceCreateInfo fence_create_info{}; | ||||
6121 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | ||||
6122 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); | ||||
6123 | |||||
6124 | VkSemaphore semaphore; | ||||
6125 | VkSemaphoreCreateInfo semaphore_create_info{}; | ||||
6126 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; | ||||
6127 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, | ||||
6128 | &semaphore); | ||||
6129 | |||||
6130 | VkCommandPool command_pool; | ||||
6131 | VkCommandPoolCreateInfo pool_create_info{}; | ||||
6132 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; | ||||
6133 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; | ||||
6134 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; | ||||
6135 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, | ||||
6136 | &command_pool); | ||||
6137 | |||||
6138 | VkCommandBuffer command_buffer[2]; | ||||
6139 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; | ||||
6140 | command_buffer_allocate_info.sType = | ||||
6141 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; | ||||
6142 | command_buffer_allocate_info.commandPool = command_pool; | ||||
6143 | command_buffer_allocate_info.commandBufferCount = 2; | ||||
6144 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; | ||||
6145 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, | ||||
6146 | command_buffer); | ||||
6147 | |||||
6148 | { | ||||
6149 | VkCommandBufferBeginInfo begin_info{}; | ||||
6150 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
6151 | vkBeginCommandBuffer(command_buffer[0], &begin_info); | ||||
6152 | |||||
6153 | vkCmdPipelineBarrier(command_buffer[0], | ||||
6154 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, | ||||
6155 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, | ||||
6156 | 0, nullptr, 0, nullptr); | ||||
6157 | |||||
6158 | VkViewport viewport{}; | ||||
6159 | viewport.maxDepth = 1.0f; | ||||
6160 | viewport.minDepth = 0.0f; | ||||
6161 | viewport.width = 512; | ||||
6162 | viewport.height = 512; | ||||
6163 | viewport.x = 0; | ||||
6164 | viewport.y = 0; | ||||
6165 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); | ||||
6166 | vkEndCommandBuffer(command_buffer[0]); | ||||
6167 | } | ||||
6168 | { | ||||
6169 | VkCommandBufferBeginInfo begin_info{}; | ||||
6170 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
6171 | vkBeginCommandBuffer(command_buffer[1], &begin_info); | ||||
6172 | |||||
6173 | VkViewport viewport{}; | ||||
6174 | viewport.maxDepth = 1.0f; | ||||
6175 | viewport.minDepth = 0.0f; | ||||
6176 | viewport.width = 512; | ||||
6177 | viewport.height = 512; | ||||
6178 | viewport.x = 0; | ||||
6179 | viewport.y = 0; | ||||
6180 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); | ||||
6181 | vkEndCommandBuffer(command_buffer[1]); | ||||
6182 | } | ||||
6183 | { | ||||
6184 | VkSubmitInfo submit_info[2]; | ||||
6185 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; | ||||
6186 | |||||
6187 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
6188 | submit_info[0].pNext = NULL; | ||||
6189 | submit_info[0].commandBufferCount = 1; | ||||
6190 | submit_info[0].pCommandBuffers = &command_buffer[0]; | ||||
6191 | submit_info[0].signalSemaphoreCount = 1; | ||||
6192 | submit_info[0].pSignalSemaphores = &semaphore; | ||||
6193 | submit_info[0].waitSemaphoreCount = 0; | ||||
6194 | submit_info[0].pWaitSemaphores = NULL; | ||||
6195 | submit_info[0].pWaitDstStageMask = 0; | ||||
6196 | |||||
6197 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
6198 | submit_info[1].pNext = NULL; | ||||
6199 | submit_info[1].commandBufferCount = 1; | ||||
6200 | submit_info[1].pCommandBuffers = &command_buffer[1]; | ||||
6201 | submit_info[1].waitSemaphoreCount = 1; | ||||
6202 | submit_info[1].pWaitSemaphores = &semaphore; | ||||
6203 | submit_info[1].pWaitDstStageMask = flags; | ||||
6204 | submit_info[1].signalSemaphoreCount = 0; | ||||
6205 | submit_info[1].pSignalSemaphores = NULL; | ||||
6206 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); | ||||
6207 | } | ||||
6208 | |||||
6209 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); | ||||
6210 | |||||
6211 | vkDestroyFence(m_device->device(), fence, nullptr); | ||||
6212 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, | ||||
6213 | &command_buffer[0]); | ||||
6214 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 6215 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 6216 | |
6217 | m_errorMonitor->VerifyNotFound(); | ||||
6218 | } | ||||
6219 | |||||
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 6220 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 6221 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 6222 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
6223 | "state is required but not correctly bound."); | ||||
6224 | |||||
6225 | // Dynamic depth bias | ||||
6226 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6227 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6228 | "Dynamic depth bias state not set for this command buffer"); | ||||
6229 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, | ||||
6230 | BsoFailDepthBias); | ||||
6231 | m_errorMonitor->VerifyFound(); | ||||
6232 | } | ||||
6233 | |||||
6234 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { | ||||
6235 | TEST_DESCRIPTION( | ||||
6236 | "Run a simple draw calls to validate failure when Line Width dynamic " | ||||
6237 | "state is required but not correctly bound."); | ||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 6238 | |
6239 | // Dynamic line width | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6240 | m_errorMonitor->SetDesiredFailureMsg( |
6241 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6242 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6243 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
6244 | BsoFailLineWidth); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6245 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 6246 | } |
6247 | |||||
6248 | TEST_F(VkLayerTest, DynamicViewportNotBound) { | ||||
6249 | TEST_DESCRIPTION( | ||||
6250 | "Run a simple draw calls to validate failure when Viewport dynamic " | ||||
6251 | "state is required but not correctly bound."); | ||||
6252 | |||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 6253 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6254 | m_errorMonitor->SetDesiredFailureMsg( |
6255 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6256 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6257 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
6258 | BsoFailViewport); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6259 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 6260 | } |
6261 | |||||
6262 | TEST_F(VkLayerTest, DynamicScissorNotBound) { | ||||
6263 | TEST_DESCRIPTION( | ||||
6264 | "Run a simple draw calls to validate failure when Scissor dynamic " | ||||
6265 | "state is required but not correctly bound."); | ||||
6266 | |||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 6267 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6268 | m_errorMonitor->SetDesiredFailureMsg( |
6269 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6270 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6271 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
6272 | BsoFailScissor); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6273 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 6274 | } |
6275 | |||||
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 6276 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 6277 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 6278 | "Run a simple draw calls to validate failure when Blend Constants " |
6279 | "dynamic state is required but not correctly bound."); | ||||
6280 | // Dynamic blend constant state | ||||
6281 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6282 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6283 | "Dynamic blend constants state not set for this command buffer"); | ||||
6284 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, | ||||
6285 | BsoFailBlend); | ||||
6286 | m_errorMonitor->VerifyFound(); | ||||
6287 | } | ||||
6288 | |||||
6289 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { | ||||
6290 | TEST_DESCRIPTION( | ||||
6291 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " | ||||
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 6292 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 6293 | if (!m_device->phy().features().depthBounds) { |
6294 | printf("Device does not support depthBounds test; skipped.\n"); | ||||
6295 | return; | ||||
6296 | } | ||||
6297 | // Dynamic depth bounds | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6298 | m_errorMonitor->SetDesiredFailureMsg( |
6299 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6300 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6301 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
6302 | BsoFailDepthBounds); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6303 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 6304 | } |
6305 | |||||
6306 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { | ||||
6307 | TEST_DESCRIPTION( | ||||
6308 | "Run a simple draw calls to validate failure when Stencil Read dynamic " | ||||
6309 | "state is required but not correctly bound."); | ||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 6310 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6311 | m_errorMonitor->SetDesiredFailureMsg( |
6312 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6313 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6314 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
6315 | BsoFailStencilReadMask); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6316 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 6317 | } |
6318 | |||||
6319 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { | ||||
6320 | TEST_DESCRIPTION( | ||||
6321 | "Run a simple draw calls to validate failure when Stencil Write dynamic" | ||||
6322 | " state is required but not correctly bound."); | ||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 6323 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6324 | m_errorMonitor->SetDesiredFailureMsg( |
6325 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6326 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6327 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
6328 | BsoFailStencilWriteMask); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6329 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 6330 | } |
6331 | |||||
6332 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { | ||||
6333 | TEST_DESCRIPTION( | ||||
6334 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " | ||||
6335 | "state is required but not correctly bound."); | ||||
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 6336 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6337 | m_errorMonitor->SetDesiredFailureMsg( |
6338 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6339 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6340 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
6341 | BsoFailStencilReference); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6342 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 6343 | } |
6344 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6345 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6346 | m_errorMonitor->SetDesiredFailureMsg( |
6347 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6348 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " | ||||
6349 | "been submitted"); | ||||
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6350 | |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6351 | ASSERT_NO_FATAL_FAILURE(InitState()); |
6352 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
6353 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
6354 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6355 | // We luck out b/c by default the framework creates CB w/ the |
6356 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set | ||||
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6357 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6358 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
6359 | m_stencil_clear_color, NULL); | ||||
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6360 | EndCommandBuffer(); |
6361 | |||||
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6362 | // Bypass framework since it does the waits automatically |
6363 | VkResult err = VK_SUCCESS; | ||||
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 6364 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 6365 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
6366 | submit_info.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6367 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 6368 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 6369 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6370 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6371 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6372 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 6373 | submit_info.pSignalSemaphores = NULL; |
6374 | |||||
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 6375 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6376 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6377 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6378 | // Cause validation error by re-submitting cmd buffer that should only be |
6379 | // submitted once | ||||
Chris Forbes | 40028e2 | 2016-06-13 09:59:34 +1200 | [diff] [blame] | 6380 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6381 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6382 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 6383 | } |
6384 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6385 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6386 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6387 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6388 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6389 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6390 | "Unable to allocate 1 descriptors of " |
6391 | "type " | ||||
6392 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6393 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6394 | ASSERT_NO_FATAL_FAILURE(InitState()); |
6395 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6396 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6397 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
6398 | // descriptor from it | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6399 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6400 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
6401 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6402 | |
6403 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6404 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
6405 | ds_pool_ci.pNext = NULL; | ||||
6406 | ds_pool_ci.flags = 0; | ||||
6407 | ds_pool_ci.maxSets = 1; | ||||
6408 | ds_pool_ci.poolSizeCount = 1; | ||||
6409 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6410 | |
6411 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6412 | err = |
6413 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6414 | ASSERT_VK_SUCCESS(err); |
6415 | |||||
6416 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6417 | dsl_binding.binding = 0; |
6418 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6419 | dsl_binding.descriptorCount = 1; | ||||
6420 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
6421 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6422 | |
6423 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6424 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
6425 | ds_layout_ci.pNext = NULL; | ||||
6426 | ds_layout_ci.bindingCount = 1; | ||||
6427 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6428 | |
6429 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6430 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
6431 | &ds_layout); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6432 | ASSERT_VK_SUCCESS(err); |
6433 | |||||
6434 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6435 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6436 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6437 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6438 | alloc_info.descriptorPool = ds_pool; |
6439 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6440 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
6441 | &descriptorSet); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6442 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6443 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6444 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6445 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
6446 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 6447 | } |
6448 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6449 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
6450 | VkResult err; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6451 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6452 | m_errorMonitor->SetDesiredFailureMsg( |
6453 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6454 | "It is invalid to call vkFreeDescriptorSets() with a pool created " | ||||
6455 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6456 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6457 | ASSERT_NO_FATAL_FAILURE(InitState()); |
6458 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6459 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6460 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6461 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
6462 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6463 | |
6464 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6465 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
6466 | ds_pool_ci.pNext = NULL; | ||||
6467 | ds_pool_ci.maxSets = 1; | ||||
6468 | ds_pool_ci.poolSizeCount = 1; | ||||
6469 | ds_pool_ci.flags = 0; | ||||
6470 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means | ||||
6471 | // app can only call vkResetDescriptorPool on this pool.; | ||||
6472 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6473 | |
6474 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6475 | err = |
6476 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6477 | ASSERT_VK_SUCCESS(err); |
6478 | |||||
6479 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6480 | dsl_binding.binding = 0; |
6481 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6482 | dsl_binding.descriptorCount = 1; | ||||
6483 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
6484 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6485 | |
6486 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6487 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
6488 | ds_layout_ci.pNext = NULL; | ||||
6489 | ds_layout_ci.bindingCount = 1; | ||||
6490 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6491 | |
6492 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6493 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
6494 | &ds_layout); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6495 | ASSERT_VK_SUCCESS(err); |
6496 | |||||
6497 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6498 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6499 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6500 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6501 | alloc_info.descriptorPool = ds_pool; |
6502 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6503 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
6504 | &descriptorSet); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6505 | ASSERT_VK_SUCCESS(err); |
6506 | |||||
6507 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6508 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6509 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6510 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
6511 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 6512 | } |
6513 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6514 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6515 | // Attempt to clear Descriptor Pool with bad object. |
6516 | // ObjectTracker should catch this. | ||||
6517 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 01714f5 | 2016-07-06 09:35:04 -0600 | [diff] [blame] | 6518 | "Invalid Descriptor Pool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 6519 | uint64_t fake_pool_handle = 0xbaad6001; |
6520 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); | ||||
6521 | vkResetDescriptorPool(device(), bad_pool, 0); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6522 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6523 | } |
6524 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6525 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6526 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
6527 | // ObjectTracker should catch this. | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6528 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6529 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 6530 | |
6531 | uint64_t fake_set_handle = 0xbaad6001; | ||||
6532 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6533 | VkResult err; |
6534 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 01714f5 | 2016-07-06 09:35:04 -0600 | [diff] [blame] | 6535 | "Invalid Descriptor Set Object 0xbaad6001"); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6536 | |
6537 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6538 | |||||
6539 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; | ||||
6540 | layout_bindings[0].binding = 0; | ||||
6541 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6542 | layout_bindings[0].descriptorCount = 1; | ||||
6543 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; | ||||
6544 | layout_bindings[0].pImmutableSamplers = NULL; | ||||
6545 | |||||
6546 | VkDescriptorSetLayout descriptor_set_layout; | ||||
6547 | VkDescriptorSetLayoutCreateInfo dslci = {}; | ||||
6548 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
6549 | dslci.pNext = NULL; | ||||
6550 | dslci.bindingCount = 1; | ||||
6551 | dslci.pBindings = layout_bindings; | ||||
6552 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); | ||||
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 6553 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6554 | |
6555 | VkPipelineLayout pipeline_layout; | ||||
6556 | VkPipelineLayoutCreateInfo plci = {}; | ||||
6557 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
6558 | plci.pNext = NULL; | ||||
6559 | plci.setLayoutCount = 1; | ||||
6560 | plci.pSetLayouts = &descriptor_set_layout; | ||||
6561 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); | ||||
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 6562 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6563 | |
6564 | BeginCommandBuffer(); | ||||
6565 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 6566 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6567 | m_errorMonitor->VerifyFound(); |
6568 | EndCommandBuffer(); | ||||
6569 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); | ||||
6570 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6571 | } |
6572 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6573 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6574 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
6575 | // ObjectTracker should catch this. | ||||
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 6576 | uint64_t fake_layout_handle = 0xbaad6001; |
6577 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6578 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 01714f5 | 2016-07-06 09:35:04 -0600 | [diff] [blame] | 6579 | "Invalid Descriptor Set Layout Object 0xbaad6001"); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6580 | |
6581 | VkPipelineLayout pipeline_layout; | ||||
6582 | VkPipelineLayoutCreateInfo plci = {}; | ||||
6583 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
6584 | plci.pNext = NULL; | ||||
6585 | plci.setLayoutCount = 1; | ||||
6586 | plci.pSetLayouts = &bad_layout; | ||||
6587 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); | ||||
6588 | |||||
6589 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6590 | } |
6591 | |||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6592 | TEST_F(VkLayerTest, WriteDescriptorSetIntegrityCheck) { |
6593 | TEST_DESCRIPTION("This test verifies some requirements of chapter 13.2.3 of the Vulkan Spec " | ||||
6594 | "1) A uniform buffer update must have a valid buffer index." | ||||
6595 | "2) When using an array of descriptors in a single WriteDescriptor," | ||||
6596 | " the descriptor types and stageflags must all be the same." | ||||
6597 | "3) Immutable Sampler state must match across descriptors"); | ||||
6598 | |||||
6599 | const char *invalid_BufferInfo_ErrorMessage = | ||||
6600 | "vkUpdateDescriptorSets: if pDescriptorWrites[0].descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, " | ||||
6601 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or " | ||||
6602 | "VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pDescriptorWrites[0].pBufferInfo must not be NULL"; | ||||
6603 | const char *stateFlag_ErrorMessage = | ||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6604 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6605 | const char *immutable_ErrorMessage = |
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6606 | "Attempting write update to descriptor set "; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6607 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6608 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, invalid_BufferInfo_ErrorMessage); |
6609 | |||||
6610 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6611 | VkDescriptorPoolSize ds_type_count[4] = {}; | ||||
6612 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6613 | ds_type_count[0].descriptorCount = 1; | ||||
6614 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; | ||||
6615 | ds_type_count[1].descriptorCount = 1; | ||||
6616 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; | ||||
6617 | ds_type_count[2].descriptorCount = 1; | ||||
6618 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; | ||||
6619 | ds_type_count[3].descriptorCount = 1; | ||||
6620 | |||||
6621 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
6622 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
6623 | ds_pool_ci.maxSets = 1; | ||||
6624 | ds_pool_ci.poolSizeCount = sizeof(ds_type_count) / sizeof(VkDescriptorPoolSize); | ||||
6625 | ds_pool_ci.pPoolSizes = ds_type_count; | ||||
6626 | |||||
6627 | VkDescriptorPool ds_pool; | ||||
6628 | VkResult err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
6629 | ASSERT_VK_SUCCESS(err); | ||||
6630 | |||||
Mark Mueller | b989672 | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6631 | VkDescriptorSetLayoutBinding layout_binding[3] = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6632 | layout_binding[0].binding = 0; |
6633 | layout_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6634 | layout_binding[0].descriptorCount = 1; | ||||
6635 | layout_binding[0].stageFlags = VK_SHADER_STAGE_ALL; | ||||
6636 | layout_binding[0].pImmutableSamplers = NULL; | ||||
6637 | |||||
6638 | layout_binding[1].binding = 1; | ||||
6639 | layout_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
6640 | layout_binding[1].descriptorCount = 1; | ||||
6641 | layout_binding[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; | ||||
6642 | layout_binding[1].pImmutableSamplers = NULL; | ||||
6643 | |||||
6644 | VkSamplerCreateInfo sampler_ci = {}; | ||||
6645 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; | ||||
6646 | sampler_ci.pNext = NULL; | ||||
6647 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
6648 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
6649 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
6650 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
6651 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
6652 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
6653 | sampler_ci.mipLodBias = 1.0; | ||||
6654 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
6655 | sampler_ci.maxAnisotropy = 1; | ||||
6656 | sampler_ci.compareEnable = VK_FALSE; | ||||
6657 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
6658 | sampler_ci.minLod = 1.0; | ||||
6659 | sampler_ci.maxLod = 1.0; | ||||
6660 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
6661 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
6662 | VkSampler sampler; | ||||
6663 | |||||
6664 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); | ||||
6665 | ASSERT_VK_SUCCESS(err); | ||||
6666 | |||||
6667 | layout_binding[2].binding = 2; | ||||
6668 | layout_binding[2].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
6669 | layout_binding[2].descriptorCount = 1; | ||||
6670 | layout_binding[2].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; | ||||
6671 | layout_binding[2].pImmutableSamplers = static_cast<VkSampler *>(&sampler); | ||||
6672 | |||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6673 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
6674 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
6675 | ds_layout_ci.bindingCount = sizeof(layout_binding) / sizeof(VkDescriptorSetLayoutBinding); | ||||
6676 | ds_layout_ci.pBindings = layout_binding; | ||||
6677 | VkDescriptorSetLayout ds_layout; | ||||
6678 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); | ||||
6679 | ASSERT_VK_SUCCESS(err); | ||||
6680 | |||||
6681 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
6682 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
6683 | alloc_info.descriptorSetCount = 1; | ||||
6684 | alloc_info.descriptorPool = ds_pool; | ||||
6685 | alloc_info.pSetLayouts = &ds_layout; | ||||
6686 | VkDescriptorSet descriptorSet; | ||||
6687 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); | ||||
6688 | ASSERT_VK_SUCCESS(err); | ||||
6689 | |||||
6690 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
6691 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
6692 | pipeline_layout_ci.pNext = NULL; | ||||
6693 | pipeline_layout_ci.setLayoutCount = 1; | ||||
6694 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
6695 | |||||
6696 | VkPipelineLayout pipeline_layout; | ||||
6697 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); | ||||
6698 | ASSERT_VK_SUCCESS(err); | ||||
6699 | |||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6700 | VkWriteDescriptorSet descriptor_write = {}; |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6701 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
6702 | descriptor_write.dstSet = descriptorSet; | ||||
6703 | descriptor_write.dstBinding = 0; | ||||
6704 | descriptor_write.descriptorCount = 1; | ||||
6705 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
6706 | |||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6707 | // 1) The uniform buffer is intentionally invalid here |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6708 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
6709 | m_errorMonitor->VerifyFound(); | ||||
6710 | |||||
6711 | // Create a buffer to update the descriptor with | ||||
6712 | uint32_t qfi = 0; | ||||
6713 | VkBufferCreateInfo buffCI = {}; | ||||
6714 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
6715 | buffCI.size = 1024; | ||||
6716 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
6717 | buffCI.queueFamilyIndexCount = 1; | ||||
6718 | buffCI.pQueueFamilyIndices = &qfi; | ||||
6719 | |||||
6720 | VkBuffer dyub; | ||||
6721 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); | ||||
6722 | ASSERT_VK_SUCCESS(err); | ||||
6723 | VkDescriptorBufferInfo buffInfo = {}; | ||||
6724 | buffInfo.buffer = dyub; | ||||
6725 | buffInfo.offset = 0; | ||||
6726 | buffInfo.range = 1024; | ||||
6727 | |||||
6728 | descriptor_write.pBufferInfo = &buffInfo; | ||||
6729 | descriptor_write.descriptorCount = 2; | ||||
6730 | |||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6731 | // 2) The stateFlags don't match between the first and second descriptor |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6732 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, stateFlag_ErrorMessage); |
6733 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
6734 | m_errorMonitor->VerifyFound(); | ||||
6735 | |||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6736 | // 3) The second descriptor has a null_ptr pImmutableSamplers and |
6737 | // the third descriptor contains an immutable sampler | ||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6738 | descriptor_write.dstBinding = 1; |
6739 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
Mark Mueller | 5c838ce | 2016-06-16 09:54:29 -0600 | [diff] [blame] | 6740 | |
6741 | |||||
6742 | // Make pImageInfo index non-null to avoid complaints of it missing | ||||
6743 | VkDescriptorImageInfo imageInfo = {}; | ||||
6744 | imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
6745 | descriptor_write.pImageInfo = &imageInfo; | ||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6746 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, immutable_ErrorMessage); |
6747 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
6748 | m_errorMonitor->VerifyFound(); | ||||
6749 | |||||
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 6750 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
6751 | vkDestroySampler(m_device->device(), sampler, NULL); | ||||
6752 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
6753 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
6754 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
6755 | } | ||||
6756 | |||||
Tobin Ehlis | 0283c4d | 2016-06-28 17:57:07 -0600 | [diff] [blame] | 6757 | TEST_F(VkLayerTest, InvalidCmdBufferBufferDestroyed) { |
6758 | TEST_DESCRIPTION("Attempt to draw with a command buffer that is invalid " | ||||
6759 | "due to a buffer dependency being destroyed."); | ||||
6760 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6761 | |||||
6762 | VkImageObj image(m_device); | ||||
6763 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
6764 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | ||||
6765 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
6766 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
6767 | ASSERT_TRUE(image.initialized()); | ||||
6768 | |||||
6769 | VkBuffer buffer; | ||||
6770 | VkDeviceMemory mem; | ||||
6771 | VkMemoryRequirements mem_reqs; | ||||
6772 | |||||
6773 | VkBufferCreateInfo buf_info = {}; | ||||
6774 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
6775 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
6776 | buf_info.size = 256; | ||||
6777 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
6778 | VkResult err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); | ||||
6779 | ASSERT_VK_SUCCESS(err); | ||||
6780 | |||||
6781 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); | ||||
6782 | |||||
6783 | VkMemoryAllocateInfo alloc_info = {}; | ||||
6784 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
6785 | alloc_info.allocationSize = 256; | ||||
6786 | bool pass = false; | ||||
6787 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, | ||||
6788 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
6789 | if (!pass) { | ||||
6790 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
6791 | return; | ||||
6792 | } | ||||
6793 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); | ||||
6794 | ASSERT_VK_SUCCESS(err); | ||||
6795 | |||||
6796 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
6797 | ASSERT_VK_SUCCESS(err); | ||||
6798 | |||||
6799 | VkBufferImageCopy region = {}; | ||||
6800 | region.bufferRowLength = 128; | ||||
6801 | region.bufferImageHeight = 128; | ||||
6802 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
6803 | |||||
6804 | region.imageSubresource.layerCount = 1; | ||||
6805 | region.imageExtent.height = 4; | ||||
6806 | region.imageExtent.width = 4; | ||||
6807 | region.imageExtent.depth = 1; | ||||
6808 | m_commandBuffer->BeginCommandBuffer(); | ||||
6809 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer, | ||||
6810 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
6811 | 1, ®ion); | ||||
6812 | m_commandBuffer->EndCommandBuffer(); | ||||
6813 | |||||
6814 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6815 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6816 | " that is invalid because bound buffer "); | ||||
6817 | // Destroy buffer dependency prior to submit to cause ERROR | ||||
6818 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
6819 | |||||
6820 | VkSubmitInfo submit_info = {}; | ||||
6821 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
6822 | submit_info.commandBufferCount = 1; | ||||
6823 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); | ||||
6824 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
6825 | |||||
6826 | m_errorMonitor->VerifyFound(); | ||||
6827 | vkFreeMemory(m_device->handle(), mem, NULL); | ||||
6828 | } | ||||
6829 | |||||
Tobin Ehlis | 11c8cea | 2016-06-28 17:44:21 -0600 | [diff] [blame] | 6830 | TEST_F(VkLayerTest, InvalidCmdBufferImageDestroyed) { |
6831 | TEST_DESCRIPTION("Attempt to draw with a command buffer that is invalid " | ||||
6832 | "due to an image dependency being destroyed."); | ||||
6833 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6834 | |||||
6835 | VkImage image; | ||||
6836 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
6837 | VkImageCreateInfo image_create_info = {}; | ||||
6838 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
6839 | image_create_info.pNext = NULL; | ||||
6840 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
6841 | image_create_info.format = tex_format; | ||||
6842 | image_create_info.extent.width = 32; | ||||
6843 | image_create_info.extent.height = 32; | ||||
6844 | image_create_info.extent.depth = 1; | ||||
6845 | image_create_info.mipLevels = 1; | ||||
6846 | image_create_info.arrayLayers = 1; | ||||
6847 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
6848 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
6849 | image_create_info.usage = | ||||
6850 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; | ||||
6851 | image_create_info.flags = 0; | ||||
6852 | VkResult err = | ||||
6853 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
6854 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 3d09fd5 | 2016-07-06 08:12:56 -0600 | [diff] [blame] | 6855 | // Have to bind memory to image before recording cmd in cmd buffer using it |
6856 | VkMemoryRequirements mem_reqs; | ||||
6857 | VkDeviceMemory image_mem; | ||||
6858 | bool pass; | ||||
6859 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
6860 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
6861 | mem_alloc.pNext = NULL; | ||||
6862 | mem_alloc.memoryTypeIndex = 0; | ||||
6863 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
6864 | mem_alloc.allocationSize = mem_reqs.size; | ||||
6865 | pass = | ||||
6866 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
6867 | ASSERT_TRUE(pass); | ||||
6868 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); | ||||
6869 | ASSERT_VK_SUCCESS(err); | ||||
6870 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); | ||||
6871 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 11c8cea | 2016-06-28 17:44:21 -0600 | [diff] [blame] | 6872 | |
Tobin Ehlis | 11c8cea | 2016-06-28 17:44:21 -0600 | [diff] [blame] | 6873 | m_commandBuffer->BeginCommandBuffer(); |
Tobin Ehlis | 764d707 | 2016-07-01 12:54:29 -0600 | [diff] [blame] | 6874 | VkClearColorValue ccv; |
6875 | ccv.float32[0] = 1.0f; | ||||
6876 | ccv.float32[1] = 1.0f; | ||||
6877 | ccv.float32[2] = 1.0f; | ||||
6878 | ccv.float32[3] = 1.0f; | ||||
6879 | VkImageSubresourceRange isr = {}; | ||||
6880 | isr.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | 3d09fd5 | 2016-07-06 08:12:56 -0600 | [diff] [blame] | 6881 | isr.baseArrayLayer = 0; |
6882 | isr.baseMipLevel = 0; | ||||
Tobin Ehlis | 764d707 | 2016-07-01 12:54:29 -0600 | [diff] [blame] | 6883 | isr.layerCount = 1; |
6884 | isr.levelCount = 1; | ||||
6885 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), image, | ||||
6886 | VK_IMAGE_LAYOUT_GENERAL, &ccv, 1, &isr); | ||||
Tobin Ehlis | 11c8cea | 2016-06-28 17:44:21 -0600 | [diff] [blame] | 6887 | m_commandBuffer->EndCommandBuffer(); |
6888 | |||||
6889 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6890 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " that is invalid because bound image "); | ||||
6891 | // Destroy image dependency prior to submit to cause ERROR | ||||
6892 | vkDestroyImage(m_device->device(), image, NULL); | ||||
6893 | |||||
6894 | VkSubmitInfo submit_info = {}; | ||||
6895 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
6896 | submit_info.commandBufferCount = 1; | ||||
6897 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); | ||||
6898 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
6899 | |||||
6900 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 3d09fd5 | 2016-07-06 08:12:56 -0600 | [diff] [blame] | 6901 | vkFreeMemory(m_device->device(), image_mem, nullptr); |
Tobin Ehlis | 11c8cea | 2016-06-28 17:44:21 -0600 | [diff] [blame] | 6902 | } |
6903 | |||||
Mark Lobodzinski | a4df363 | 2016-07-14 09:57:41 -0600 | [diff] [blame] | 6904 | TEST_F(VkLayerTest, ImageMemoryNotBound) { |
6905 | TEST_DESCRIPTION( | ||||
6906 | "Attempt to draw with an image which has not had memory bound to it."); | ||||
6907 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6908 | |||||
6909 | VkImage image; | ||||
6910 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
6911 | VkImageCreateInfo image_create_info = {}; | ||||
6912 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
6913 | image_create_info.pNext = NULL; | ||||
6914 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
6915 | image_create_info.format = tex_format; | ||||
6916 | image_create_info.extent.width = 32; | ||||
6917 | image_create_info.extent.height = 32; | ||||
6918 | image_create_info.extent.depth = 1; | ||||
6919 | image_create_info.mipLevels = 1; | ||||
6920 | image_create_info.arrayLayers = 1; | ||||
6921 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
6922 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
6923 | image_create_info.usage = | ||||
6924 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; | ||||
6925 | image_create_info.flags = 0; | ||||
6926 | VkResult err = | ||||
6927 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
6928 | ASSERT_VK_SUCCESS(err); | ||||
6929 | // Have to bind memory to image before recording cmd in cmd buffer using it | ||||
6930 | VkMemoryRequirements mem_reqs; | ||||
6931 | VkDeviceMemory image_mem; | ||||
6932 | bool pass; | ||||
6933 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
6934 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
6935 | mem_alloc.pNext = NULL; | ||||
6936 | mem_alloc.memoryTypeIndex = 0; | ||||
6937 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
6938 | mem_alloc.allocationSize = mem_reqs.size; | ||||
6939 | pass = | ||||
6940 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
6941 | ASSERT_TRUE(pass); | ||||
6942 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); | ||||
6943 | ASSERT_VK_SUCCESS(err); | ||||
6944 | |||||
6945 | // Introduce error, do not call vkBindImageMemory(m_device->device(), image, | ||||
6946 | // image_mem, 0); | ||||
6947 | m_errorMonitor->SetDesiredFailureMsg( | ||||
6948 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
6949 | "used without first calling vkBindImageMemory"); | ||||
6950 | |||||
6951 | m_commandBuffer->BeginCommandBuffer(); | ||||
6952 | VkClearColorValue ccv; | ||||
6953 | ccv.float32[0] = 1.0f; | ||||
6954 | ccv.float32[1] = 1.0f; | ||||
6955 | ccv.float32[2] = 1.0f; | ||||
6956 | ccv.float32[3] = 1.0f; | ||||
6957 | VkImageSubresourceRange isr = {}; | ||||
6958 | isr.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
6959 | isr.baseArrayLayer = 0; | ||||
6960 | isr.baseMipLevel = 0; | ||||
6961 | isr.layerCount = 1; | ||||
6962 | isr.levelCount = 1; | ||||
6963 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), image, | ||||
6964 | VK_IMAGE_LAYOUT_GENERAL, &ccv, 1, &isr); | ||||
6965 | m_commandBuffer->EndCommandBuffer(); | ||||
6966 | |||||
6967 | m_errorMonitor->VerifyFound(); | ||||
6968 | vkDestroyImage(m_device->device(), image, NULL); | ||||
6969 | vkFreeMemory(m_device->device(), image_mem, nullptr); | ||||
6970 | } | ||||
6971 | |||||
6972 | TEST_F(VkLayerTest, BufferMemoryNotBound) { | ||||
6973 | TEST_DESCRIPTION( | ||||
6974 | "Attempt to copy from a buffer which has not had memory bound to it."); | ||||
6975 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
6976 | |||||
6977 | VkImageObj image(m_device); | ||||
6978 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
6979 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | ||||
6980 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
6981 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
6982 | ASSERT_TRUE(image.initialized()); | ||||
6983 | |||||
6984 | VkBuffer buffer; | ||||
6985 | VkDeviceMemory mem; | ||||
6986 | VkMemoryRequirements mem_reqs; | ||||
6987 | |||||
6988 | VkBufferCreateInfo buf_info = {}; | ||||
6989 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
6990 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
6991 | buf_info.size = 256; | ||||
6992 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
6993 | VkResult err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); | ||||
6994 | ASSERT_VK_SUCCESS(err); | ||||
6995 | |||||
6996 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); | ||||
6997 | |||||
6998 | VkMemoryAllocateInfo alloc_info = {}; | ||||
6999 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
7000 | alloc_info.allocationSize = 256; | ||||
7001 | bool pass = false; | ||||
7002 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, | ||||
7003 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | ||||
7004 | if (!pass) { | ||||
7005 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
7006 | return; | ||||
7007 | } | ||||
7008 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); | ||||
7009 | ASSERT_VK_SUCCESS(err); | ||||
7010 | |||||
7011 | // Introduce failure by not calling vkBindBufferMemory(m_device->device(), | ||||
7012 | // buffer, mem, 0); | ||||
7013 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7014 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7015 | "used without first calling vkBindBufferMemory"); | ||||
7016 | VkBufferImageCopy region = {}; | ||||
7017 | region.bufferRowLength = 128; | ||||
7018 | region.bufferImageHeight = 128; | ||||
7019 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
7020 | |||||
7021 | region.imageSubresource.layerCount = 1; | ||||
7022 | region.imageExtent.height = 4; | ||||
7023 | region.imageExtent.width = 4; | ||||
7024 | region.imageExtent.depth = 1; | ||||
7025 | m_commandBuffer->BeginCommandBuffer(); | ||||
7026 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer, | ||||
7027 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
7028 | 1, ®ion); | ||||
7029 | m_commandBuffer->EndCommandBuffer(); | ||||
7030 | |||||
7031 | m_errorMonitor->VerifyFound(); | ||||
7032 | |||||
7033 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
7034 | vkFreeMemory(m_device->handle(), mem, NULL); | ||||
7035 | } | ||||
7036 | |||||
Tobin Ehlis | 85940f5 | 2016-07-07 16:57:21 -0600 | [diff] [blame] | 7037 | TEST_F(VkLayerTest, InvalidCmdBufferEventDestroyed) { |
7038 | TEST_DESCRIPTION("Attempt to draw with a command buffer that is invalid " | ||||
7039 | "due to an event dependency being destroyed."); | ||||
7040 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7041 | |||||
7042 | VkEvent event; | ||||
7043 | VkEventCreateInfo evci = {}; | ||||
7044 | evci.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
7045 | VkResult result = vkCreateEvent(m_device->device(), &evci, NULL, &event); | ||||
7046 | ASSERT_VK_SUCCESS(result); | ||||
7047 | |||||
7048 | m_commandBuffer->BeginCommandBuffer(); | ||||
7049 | vkCmdSetEvent(m_commandBuffer->GetBufferHandle(), event, | ||||
7050 | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT); | ||||
7051 | m_commandBuffer->EndCommandBuffer(); | ||||
7052 | |||||
7053 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7054 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " that is invalid because bound event "); | ||||
7055 | // Destroy event dependency prior to submit to cause ERROR | ||||
7056 | vkDestroyEvent(m_device->device(), event, NULL); | ||||
7057 | |||||
7058 | VkSubmitInfo submit_info = {}; | ||||
7059 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
7060 | submit_info.commandBufferCount = 1; | ||||
7061 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); | ||||
7062 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
7063 | |||||
7064 | m_errorMonitor->VerifyFound(); | ||||
7065 | } | ||||
7066 | |||||
Tobin Ehlis | dbea755 | 2016-07-08 14:33:31 -0600 | [diff] [blame] | 7067 | TEST_F(VkLayerTest, InvalidCmdBufferQueryPoolDestroyed) { |
7068 | TEST_DESCRIPTION("Attempt to draw with a command buffer that is invalid " | ||||
7069 | "due to a query pool dependency being destroyed."); | ||||
7070 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7071 | |||||
7072 | VkQueryPool query_pool; | ||||
7073 | VkQueryPoolCreateInfo qpci{}; | ||||
7074 | qpci.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; | ||||
7075 | qpci.queryType = VK_QUERY_TYPE_TIMESTAMP; | ||||
7076 | qpci.queryCount = 1; | ||||
7077 | VkResult result = | ||||
7078 | vkCreateQueryPool(m_device->device(), &qpci, nullptr, &query_pool); | ||||
7079 | ASSERT_VK_SUCCESS(result); | ||||
7080 | |||||
7081 | m_commandBuffer->BeginCommandBuffer(); | ||||
7082 | vkCmdResetQueryPool(m_commandBuffer->GetBufferHandle(), query_pool, 0, 1); | ||||
7083 | m_commandBuffer->EndCommandBuffer(); | ||||
7084 | |||||
7085 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7086 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7087 | " that is invalid because bound query pool "); | ||||
7088 | // Destroy query pool dependency prior to submit to cause ERROR | ||||
7089 | vkDestroyQueryPool(m_device->device(), query_pool, NULL); | ||||
7090 | |||||
7091 | VkSubmitInfo submit_info = {}; | ||||
7092 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
7093 | submit_info.commandBufferCount = 1; | ||||
7094 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); | ||||
7095 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
7096 | |||||
7097 | m_errorMonitor->VerifyFound(); | ||||
7098 | } | ||||
7099 | |||||
Tobin Ehlis | 24130d9 | 2016-07-08 15:50:53 -0600 | [diff] [blame] | 7100 | TEST_F(VkLayerTest, InvalidCmdBufferPipelineDestroyed) { |
7101 | TEST_DESCRIPTION("Attempt to draw with a command buffer that is invalid " | ||||
7102 | "due to a pipeline dependency being destroyed."); | ||||
7103 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7104 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
7105 | |||||
7106 | VkResult err; | ||||
7107 | |||||
7108 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
7109 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
7110 | |||||
7111 | VkPipelineLayout pipeline_layout; | ||||
7112 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
7113 | &pipeline_layout); | ||||
7114 | ASSERT_VK_SUCCESS(err); | ||||
7115 | |||||
7116 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
7117 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; | ||||
7118 | vp_state_ci.viewportCount = 1; | ||||
7119 | VkViewport vp = {}; // Just need dummy vp to point to | ||||
7120 | vp_state_ci.pViewports = &vp; // Null vp w/ count of 1 should cause error | ||||
7121 | vp_state_ci.scissorCount = 1; | ||||
7122 | VkRect2D scissors = {}; // Dummy scissors to point to | ||||
7123 | vp_state_ci.pScissors = &scissors; | ||||
7124 | // No dynamic state | ||||
7125 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
7126 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; | ||||
7127 | |||||
7128 | VkPipelineShaderStageCreateInfo shaderStages[2]; | ||||
7129 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); | ||||
7130 | |||||
7131 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
7132 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
7133 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
7134 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
7135 | this); // We shouldn't need a fragment shader | ||||
7136 | // but add it to be able to run on more devices | ||||
7137 | shaderStages[0] = vs.GetStageCreateInfo(); | ||||
7138 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
7139 | |||||
7140 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; | ||||
7141 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; | ||||
7142 | |||||
7143 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; | ||||
7144 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
7145 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; | ||||
7146 | |||||
7147 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; | ||||
7148 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
7149 | |||||
7150 | VkPipelineColorBlendAttachmentState att = {}; | ||||
7151 | att.blendEnable = VK_FALSE; | ||||
7152 | att.colorWriteMask = 0xf; | ||||
7153 | |||||
7154 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; | ||||
7155 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; | ||||
7156 | cb_ci.attachmentCount = 1; | ||||
7157 | cb_ci.pAttachments = &att; | ||||
7158 | |||||
7159 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
7160 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; | ||||
7161 | gp_ci.stageCount = 2; | ||||
7162 | gp_ci.pStages = shaderStages; | ||||
7163 | gp_ci.pVertexInputState = &vi_ci; | ||||
7164 | gp_ci.pInputAssemblyState = &ia_ci; | ||||
7165 | gp_ci.pViewportState = &vp_state_ci; | ||||
7166 | gp_ci.pRasterizationState = &rs_ci; | ||||
7167 | gp_ci.pColorBlendState = &cb_ci; | ||||
7168 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
7169 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
7170 | gp_ci.layout = pipeline_layout; | ||||
7171 | gp_ci.renderPass = renderPass(); | ||||
7172 | |||||
7173 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
7174 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; | ||||
7175 | |||||
7176 | VkPipeline pipeline; | ||||
7177 | VkPipelineCache pipelineCache; | ||||
7178 | err = | ||||
7179 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
7180 | ASSERT_VK_SUCCESS(err); | ||||
7181 | |||||
7182 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
7183 | &gp_ci, NULL, &pipeline); | ||||
7184 | ASSERT_VK_SUCCESS(err); | ||||
7185 | |||||
7186 | m_commandBuffer->BeginCommandBuffer(); | ||||
7187 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
7188 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); | ||||
7189 | m_commandBuffer->EndCommandBuffer(); | ||||
7190 | // Now destroy pipeline in order to cause error when submitting | ||||
7191 | vkDestroyPipeline(m_device->device(), pipeline, nullptr); | ||||
7192 | |||||
7193 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7194 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7195 | " that is invalid because bound pipeline "); | ||||
7196 | |||||
7197 | VkSubmitInfo submit_info = {}; | ||||
7198 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | ||||
7199 | submit_info.commandBufferCount = 1; | ||||
7200 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); | ||||
7201 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); | ||||
7202 | |||||
7203 | m_errorMonitor->VerifyFound(); | ||||
7204 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); | ||||
7205 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
7206 | } | ||||
7207 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7208 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7209 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
7210 | // ObjectTracker should catch this. | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7211 | // Create a valid cmd buffer |
7212 | // call vkCmdBindPipeline w/ false Pipeline | ||||
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 7213 | uint64_t fake_pipeline_handle = 0xbaad6001; |
7214 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7215 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 01714f5 | 2016-07-06 09:35:04 -0600 | [diff] [blame] | 7216 | "Invalid Pipeline Object 0xbaad6001"); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7217 | ASSERT_NO_FATAL_FAILURE(InitState()); |
7218 | BeginCommandBuffer(); | ||||
7219 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
7220 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); | ||||
7221 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 7222 | // Now issue a draw call with no pipeline bound |
7223 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7224 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7225 | "At Draw/Dispatch time no valid VkPipeline is bound!"); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7226 | |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 7227 | BeginCommandBuffer(); |
7228 | Draw(1, 0, 0, 0); | ||||
7229 | m_errorMonitor->VerifyFound(); | ||||
7230 | // Finally same check once more but with Dispatch/Compute | ||||
7231 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7232 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7233 | "At Draw/Dispatch time no valid VkPipeline is bound!"); | ||||
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 7234 | BeginCommandBuffer(); |
7235 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); | ||||
7236 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7237 | } |
7238 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7239 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
7240 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on | ||||
7241 | // CommandBuffer | ||||
7242 | VkResult err; | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7243 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7244 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7245 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7246 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7247 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 7248 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
7249 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7250 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7251 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
7252 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7253 | |
7254 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7255 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
7256 | ds_pool_ci.pNext = NULL; | ||||
7257 | ds_pool_ci.maxSets = 1; | ||||
7258 | ds_pool_ci.poolSizeCount = 1; | ||||
7259 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 7260 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7261 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7262 | err = |
7263 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7264 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7265 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7266 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7267 | dsl_binding.binding = 0; |
7268 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
7269 | dsl_binding.descriptorCount = 1; | ||||
7270 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
7271 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7272 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7273 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7274 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
7275 | ds_layout_ci.pNext = NULL; | ||||
7276 | ds_layout_ci.bindingCount = 1; | ||||
7277 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7278 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7279 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
7280 | &ds_layout); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7281 | ASSERT_VK_SUCCESS(err); |
7282 | |||||
7283 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7284 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7285 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7286 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7287 | alloc_info.descriptorPool = ds_pool; |
7288 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7289 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
7290 | &descriptorSet); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7291 | ASSERT_VK_SUCCESS(err); |
7292 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7293 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7294 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
7295 | pipeline_layout_ci.pNext = NULL; | ||||
7296 | pipeline_layout_ci.setLayoutCount = 1; | ||||
7297 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7298 | |
7299 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7300 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7301 | &pipeline_layout); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7302 | ASSERT_VK_SUCCESS(err); |
7303 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7304 | VkShaderObj vs(m_device, bindStateVertShaderText, |
7305 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7306 | // 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] | 7307 | // on more devices |
7308 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
7309 | VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7310 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 7311 | VkPipelineObj pipe(m_device); |
7312 | pipe.AddShader(&vs); | ||||
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7313 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7314 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 7315 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7316 | |
7317 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7318 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
7319 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
7320 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
7321 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
7322 | 1, &descriptorSet, 0, NULL); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 7323 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7324 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7325 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7326 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
7327 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
7328 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 7329 | } |
7330 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7331 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7332 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7333 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7334 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7335 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7336 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
7337 | "descriptor with invalid buffer view"); | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7338 | |
7339 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7340 | VkDescriptorPoolSize ds_type_count = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7341 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
7342 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7343 | |
7344 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7345 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
7346 | ds_pool_ci.pNext = NULL; | ||||
7347 | ds_pool_ci.maxSets = 1; | ||||
7348 | ds_pool_ci.poolSizeCount = 1; | ||||
7349 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7350 | |
7351 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7352 | err = |
7353 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7354 | ASSERT_VK_SUCCESS(err); |
7355 | |||||
7356 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7357 | dsl_binding.binding = 0; |
7358 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; | ||||
7359 | dsl_binding.descriptorCount = 1; | ||||
7360 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
7361 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7362 | |
7363 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7364 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
7365 | ds_layout_ci.pNext = NULL; | ||||
7366 | ds_layout_ci.bindingCount = 1; | ||||
7367 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7368 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7369 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
7370 | &ds_layout); | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7371 | ASSERT_VK_SUCCESS(err); |
7372 | |||||
7373 | VkDescriptorSet descriptorSet; | ||||
7374 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7375 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7376 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7377 | alloc_info.descriptorPool = ds_pool; |
7378 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7379 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
7380 | &descriptorSet); | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7381 | ASSERT_VK_SUCCESS(err); |
7382 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7383 | VkBufferView view = |
7384 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object | ||||
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7385 | VkWriteDescriptorSet descriptor_write; |
7386 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
7387 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
7388 | descriptor_write.dstSet = descriptorSet; | ||||
7389 | descriptor_write.dstBinding = 0; | ||||
7390 | descriptor_write.descriptorCount = 1; | ||||
7391 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; | ||||
7392 | descriptor_write.pTexelBufferView = &view; | ||||
7393 | |||||
7394 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
7395 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7396 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 7397 | |
7398 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
7399 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
7400 | } | ||||
7401 | |||||
Mark Young | d339ba3 | 2016-05-30 13:28:35 -0600 | [diff] [blame] | 7402 | TEST_F(VkLayerTest, CreateBufferViewNoMemoryBoundToBuffer) { |
7403 | TEST_DESCRIPTION("Attempt to create a buffer view with a buffer that has" | ||||
7404 | " no memory bound to it."); | ||||
7405 | |||||
7406 | VkResult err; | ||||
7407 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7408 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 0dcf272 | 2016-07-14 09:54:11 -0600 | [diff] [blame] | 7409 | "used without first calling vkBindBufferMemory"); |
Mark Young | d339ba3 | 2016-05-30 13:28:35 -0600 | [diff] [blame] | 7410 | |
7411 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7412 | |||||
7413 | // Create a buffer with no bound memory and then attempt to create | ||||
7414 | // a buffer view. | ||||
7415 | VkBufferCreateInfo buff_ci = {}; | ||||
7416 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
7417 | buff_ci.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
7418 | buff_ci.size = 256; | ||||
7419 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
7420 | VkBuffer buffer; | ||||
7421 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); | ||||
7422 | ASSERT_VK_SUCCESS(err); | ||||
7423 | |||||
7424 | VkBufferViewCreateInfo buff_view_ci = {}; | ||||
7425 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; | ||||
7426 | buff_view_ci.buffer = buffer; | ||||
7427 | buff_view_ci.format = VK_FORMAT_R8_UNORM; | ||||
7428 | buff_view_ci.range = VK_WHOLE_SIZE; | ||||
7429 | VkBufferView buff_view; | ||||
7430 | err = | ||||
7431 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); | ||||
7432 | |||||
7433 | m_errorMonitor->VerifyFound(); | ||||
7434 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
7435 | // If last error is success, it still created the view, so delete it. | ||||
7436 | if (err == VK_SUCCESS) { | ||||
7437 | vkDestroyBufferView(m_device->device(), buff_view, NULL); | ||||
7438 | } | ||||
7439 | } | ||||
7440 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7441 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
7442 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error | ||||
7443 | // cases: | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 7444 | // 1. No dynamicOffset supplied |
7445 | // 2. Too many dynamicOffsets supplied | ||||
7446 | // 3. Dynamic offset oversteps buffer being updated | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7447 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7448 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7449 | " requires 1 dynamicOffsets, but only " |
7450 | "0 dynamicOffsets are left in " | ||||
7451 | "pDynamicOffsets "); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7452 | |
7453 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7454 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
7455 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
7456 | |||||
7457 | VkDescriptorPoolSize ds_type_count = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7458 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
7459 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7460 | |
7461 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7462 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
7463 | ds_pool_ci.pNext = NULL; | ||||
7464 | ds_pool_ci.maxSets = 1; | ||||
7465 | ds_pool_ci.poolSizeCount = 1; | ||||
7466 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7467 | |
7468 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7469 | err = |
7470 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7471 | ASSERT_VK_SUCCESS(err); |
7472 | |||||
7473 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7474 | dsl_binding.binding = 0; |
7475 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; | ||||
7476 | dsl_binding.descriptorCount = 1; | ||||
7477 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
7478 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7479 | |
7480 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7481 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
7482 | ds_layout_ci.pNext = NULL; | ||||
7483 | ds_layout_ci.bindingCount = 1; | ||||
7484 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7485 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7486 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
7487 | &ds_layout); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7488 | ASSERT_VK_SUCCESS(err); |
7489 | |||||
7490 | VkDescriptorSet descriptorSet; | ||||
7491 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7492 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7493 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7494 | alloc_info.descriptorPool = ds_pool; |
7495 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7496 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
7497 | &descriptorSet); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7498 | ASSERT_VK_SUCCESS(err); |
7499 | |||||
7500 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7501 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
7502 | pipeline_layout_ci.pNext = NULL; | ||||
7503 | pipeline_layout_ci.setLayoutCount = 1; | ||||
7504 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7505 | |
7506 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7507 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7508 | &pipeline_layout); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7509 | ASSERT_VK_SUCCESS(err); |
7510 | |||||
7511 | // Create a buffer to update the descriptor with | ||||
7512 | uint32_t qfi = 0; | ||||
7513 | VkBufferCreateInfo buffCI = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7514 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
7515 | buffCI.size = 1024; | ||||
7516 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
7517 | buffCI.queueFamilyIndexCount = 1; | ||||
7518 | buffCI.pQueueFamilyIndices = &qfi; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7519 | |
7520 | VkBuffer dyub; | ||||
7521 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); | ||||
7522 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7523 | // Allocate memory and bind to buffer so we can make it to the appropriate |
7524 | // error | ||||
7525 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
7526 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
7527 | mem_alloc.pNext = NULL; | ||||
7528 | mem_alloc.allocationSize = 1024; | ||||
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 7529 | mem_alloc.memoryTypeIndex = 0; |
7530 | |||||
7531 | VkMemoryRequirements memReqs; | ||||
7532 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); | ||||
7533 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, | ||||
7534 | 0); | ||||
7535 | if (!pass) { | ||||
7536 | vkDestroyBuffer(m_device->device(), dyub, NULL); | ||||
7537 | return; | ||||
7538 | } | ||||
7539 | |||||
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7540 | VkDeviceMemory mem; |
7541 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); | ||||
7542 | ASSERT_VK_SUCCESS(err); | ||||
7543 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); | ||||
7544 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7545 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
7546 | VkDescriptorBufferInfo buffInfo = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7547 | buffInfo.buffer = dyub; |
7548 | buffInfo.offset = 0; | ||||
7549 | buffInfo.range = 1024; | ||||
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7550 | |
7551 | VkWriteDescriptorSet descriptor_write; | ||||
7552 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
7553 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
7554 | descriptor_write.dstSet = descriptorSet; | ||||
7555 | descriptor_write.dstBinding = 0; | ||||
7556 | descriptor_write.descriptorCount = 1; | ||||
7557 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; | ||||
7558 | descriptor_write.pBufferInfo = &buffInfo; | ||||
7559 | |||||
7560 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
7561 | |||||
7562 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7563 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
7564 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
7565 | 1, &descriptorSet, 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7566 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 7567 | uint32_t pDynOff[2] = {512, 756}; |
7568 | // 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] | 7569 | m_errorMonitor->SetDesiredFailureMsg( |
7570 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 7571 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7572 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
7573 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
7574 | 1, &descriptorSet, 2, pDynOff); | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 7575 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 7576 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7577 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
7578 | " dynamic offset 512 combined with " | ||||
7579 | "offset 0 and range 1024 that " | ||||
7580 | "oversteps the buffer size of 1024"); | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 7581 | // Create PSO to be used for draw-time errors below |
7582 | char const *vsSource = | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 7583 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 7584 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7585 | "out gl_PerVertex { \n" |
7586 | " vec4 gl_Position;\n" | ||||
7587 | "};\n" | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 7588 | "void main(){\n" |
7589 | " gl_Position = vec4(1);\n" | ||||
7590 | "}\n"; | ||||
7591 | char const *fsSource = | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 7592 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 7593 | "\n" |
7594 | "layout(location=0) out vec4 x;\n" | ||||
7595 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" | ||||
7596 | "void main(){\n" | ||||
7597 | " x = vec4(bar.y);\n" | ||||
7598 | "}\n"; | ||||
7599 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
7600 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
7601 | VkPipelineObj pipe(m_device); | ||||
7602 | pipe.AddShader(&vs); | ||||
7603 | pipe.AddShader(&fs); | ||||
7604 | pipe.AddColorAttachment(); | ||||
7605 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
7606 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7607 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
7608 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
7609 | // This update should succeed, but offset size of 512 will overstep buffer | ||||
7610 | // /w range 1024 & size 1024 | ||||
7611 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
7612 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
7613 | 1, &descriptorSet, 1, pDynOff); | ||||
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 7614 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7615 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7616 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7617 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 7618 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7619 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7620 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 7621 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 7622 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
7623 | } | ||||
7624 | |||||
Tobin Ehlis | 8ef479c | 2016-07-20 16:14:49 -0600 | [diff] [blame] | 7625 | TEST_F(VkLayerTest, DescriptorBufferUpdateNoMemoryBound) { |
7626 | TEST_DESCRIPTION("Attempt to update a descriptor with a non-sparse buffer " | ||||
7627 | "that doesn't have memory bound"); | ||||
7628 | VkResult err; | ||||
7629 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7630 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7631 | " used without first calling vkBindBufferMemory."); | ||||
7632 | |||||
7633 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
7634 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
7635 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
7636 | |||||
7637 | VkDescriptorPoolSize ds_type_count = {}; | ||||
7638 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; | ||||
7639 | ds_type_count.descriptorCount = 1; | ||||
7640 | |||||
7641 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
7642 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
7643 | ds_pool_ci.pNext = NULL; | ||||
7644 | ds_pool_ci.maxSets = 1; | ||||
7645 | ds_pool_ci.poolSizeCount = 1; | ||||
7646 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
7647 | |||||
7648 | VkDescriptorPool ds_pool; | ||||
7649 | err = | ||||
7650 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
7651 | ASSERT_VK_SUCCESS(err); | ||||
7652 | |||||
7653 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
7654 | dsl_binding.binding = 0; | ||||
7655 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; | ||||
7656 | dsl_binding.descriptorCount = 1; | ||||
7657 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
7658 | dsl_binding.pImmutableSamplers = NULL; | ||||
7659 | |||||
7660 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
7661 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
7662 | ds_layout_ci.pNext = NULL; | ||||
7663 | ds_layout_ci.bindingCount = 1; | ||||
7664 | ds_layout_ci.pBindings = &dsl_binding; | ||||
7665 | VkDescriptorSetLayout ds_layout; | ||||
7666 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
7667 | &ds_layout); | ||||
7668 | ASSERT_VK_SUCCESS(err); | ||||
7669 | |||||
7670 | VkDescriptorSet descriptorSet; | ||||
7671 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
7672 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
7673 | alloc_info.descriptorSetCount = 1; | ||||
7674 | alloc_info.descriptorPool = ds_pool; | ||||
7675 | alloc_info.pSetLayouts = &ds_layout; | ||||
7676 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
7677 | &descriptorSet); | ||||
7678 | ASSERT_VK_SUCCESS(err); | ||||
7679 | |||||
7680 | // Create a buffer to update the descriptor with | ||||
7681 | uint32_t qfi = 0; | ||||
7682 | VkBufferCreateInfo buffCI = {}; | ||||
7683 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
7684 | buffCI.size = 1024; | ||||
7685 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
7686 | buffCI.queueFamilyIndexCount = 1; | ||||
7687 | buffCI.pQueueFamilyIndices = &qfi; | ||||
7688 | |||||
7689 | VkBuffer dyub; | ||||
7690 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); | ||||
7691 | ASSERT_VK_SUCCESS(err); | ||||
7692 | |||||
7693 | // Attempt to update descriptor without binding memory to it | ||||
7694 | VkDescriptorBufferInfo buffInfo = {}; | ||||
7695 | buffInfo.buffer = dyub; | ||||
7696 | buffInfo.offset = 0; | ||||
7697 | buffInfo.range = 1024; | ||||
7698 | |||||
7699 | VkWriteDescriptorSet descriptor_write; | ||||
7700 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
7701 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
7702 | descriptor_write.dstSet = descriptorSet; | ||||
7703 | descriptor_write.dstBinding = 0; | ||||
7704 | descriptor_write.descriptorCount = 1; | ||||
7705 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; | ||||
7706 | descriptor_write.pBufferInfo = &buffInfo; | ||||
7707 | |||||
7708 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
7709 | m_errorMonitor->VerifyFound(); | ||||
7710 | |||||
7711 | vkDestroyBuffer(m_device->device(), dyub, NULL); | ||||
7712 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
7713 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
7714 | } | ||||
7715 | |||||
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7716 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7717 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7718 | ASSERT_NO_FATAL_FAILURE(InitState()); |
7719 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
7720 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
7721 | |||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7722 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7723 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7724 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
7725 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
7726 | pipeline_layout_ci.pushConstantRangeCount = 1; | ||||
7727 | pipeline_layout_ci.pPushConstantRanges = &pc_range; | ||||
7728 | |||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7729 | // |
7730 | // Check for invalid push constant ranges in pipeline layouts. | ||||
7731 | // | ||||
7732 | struct PipelineLayoutTestCase { | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7733 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7734 | char const *msg; |
7735 | }; | ||||
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7736 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7737 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
7738 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ | ||||
7739 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, | ||||
7740 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
7741 | "size 0."}, | ||||
7742 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, | ||||
7743 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
7744 | "size 1."}, | ||||
7745 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, | ||||
7746 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
7747 | "size 1."}, | ||||
7748 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, | ||||
7749 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
7750 | "size 0."}, | ||||
7751 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, | ||||
7752 | "vkCreatePipelineLayout() call has push constants index 0 with " | ||||
7753 | "offset 1. Offset must"}, | ||||
7754 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, | ||||
7755 | "vkCreatePipelineLayout() call has push constants index 0 " | ||||
7756 | "with offset "}, | ||||
7757 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, | ||||
7758 | "vkCreatePipelineLayout() call has push constants " | ||||
7759 | "index 0 with offset "}, | ||||
7760 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, | ||||
7761 | "vkCreatePipelineLayout() call has push constants index 0 " | ||||
7762 | "with offset "}, | ||||
7763 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, | ||||
7764 | "vkCreatePipelineLayout() call has push " | ||||
7765 | "constants index 0 with offset "}, | ||||
7766 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, | ||||
7767 | "vkCreatePipelineLayout() call has push " | ||||
7768 | "constants index 0 with offset "}, | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7769 | }}; |
7770 | |||||
7771 | // Check for invalid offset and size | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7772 | for (const auto &iter : range_tests) { |
7773 | pc_range = iter.range; | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7774 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
7775 | iter.msg); | ||||
7776 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, | ||||
7777 | NULL, &pipeline_layout); | ||||
7778 | m_errorMonitor->VerifyFound(); | ||||
7779 | if (VK_SUCCESS == err) { | ||||
7780 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
7781 | } | ||||
7782 | } | ||||
7783 | |||||
7784 | // Check for invalid stage flag | ||||
7785 | pc_range.offset = 0; | ||||
7786 | pc_range.size = 16; | ||||
7787 | pc_range.stageFlags = 0; | ||||
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7788 | m_errorMonitor->SetDesiredFailureMsg( |
7789 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7790 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7791 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7792 | &pipeline_layout); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7793 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7794 | if (VK_SUCCESS == err) { |
7795 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
7796 | } | ||||
7797 | |||||
7798 | // Check for overlapping ranges | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7799 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7800 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7801 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7802 | char const *msg; |
7803 | }; | ||||
7804 | |||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7805 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7806 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
7807 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7808 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7809 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7810 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, | ||||
7811 | "vkCreatePipelineLayout() call has push constants with overlapping " | ||||
7812 | "ranges: 0:[0, 4), 1:[0, 4)"}, | ||||
7813 | { | ||||
7814 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7815 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, | ||||
7816 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, | ||||
7817 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, | ||||
7818 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, | ||||
7819 | "vkCreatePipelineLayout() call has push constants with " | ||||
7820 | "overlapping " | ||||
7821 | "ranges: 3:[12, 20), 4:[16, 20)", | ||||
7822 | }, | ||||
7823 | { | ||||
7824 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, | ||||
7825 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, | ||||
7826 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, | ||||
7827 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, | ||||
7828 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, | ||||
7829 | "vkCreatePipelineLayout() call has push constants with " | ||||
7830 | "overlapping " | ||||
7831 | "ranges: 0:[16, 20), 1:[12, 20)", | ||||
7832 | }, | ||||
7833 | { | ||||
7834 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, | ||||
7835 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, | ||||
7836 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, | ||||
7837 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, | ||||
7838 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, | ||||
7839 | "vkCreatePipelineLayout() call has push constants with " | ||||
7840 | "overlapping " | ||||
7841 | "ranges: 0:[16, 20), 3:[12, 20)", | ||||
7842 | }, | ||||
7843 | { | ||||
7844 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, | ||||
7845 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, | ||||
7846 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, | ||||
7847 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, | ||||
7848 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, | ||||
7849 | "vkCreatePipelineLayout() call has push constants with " | ||||
7850 | "overlapping " | ||||
7851 | "ranges: 0:[16, 20), 2:[4, 100)", | ||||
7852 | }}}; | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7853 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7854 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7855 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7856 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
7857 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7858 | iter.msg); |
7859 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, | ||||
7860 | NULL, &pipeline_layout); | ||||
7861 | m_errorMonitor->VerifyFound(); | ||||
7862 | if (VK_SUCCESS == err) { | ||||
7863 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
7864 | } | ||||
7865 | } | ||||
7866 | |||||
7867 | // 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] | 7868 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
7869 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7870 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, | ||||
7871 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, | ||||
7872 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, | ||||
7873 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, | ||||
7874 | ""}, | ||||
7875 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, | ||||
7876 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, | ||||
7877 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, | ||||
7878 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, | ||||
7879 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, | ||||
7880 | ""}}}; | ||||
7881 | for (const auto &iter : overlapping_range_tests_pos) { | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7882 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
7883 | m_errorMonitor->ExpectSuccess(); | ||||
7884 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, | ||||
7885 | NULL, &pipeline_layout); | ||||
7886 | m_errorMonitor->VerifyNotFound(); | ||||
7887 | if (VK_SUCCESS == err) { | ||||
7888 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
7889 | } | ||||
7890 | } | ||||
7891 | |||||
7892 | // | ||||
7893 | // CmdPushConstants tests | ||||
7894 | // | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7895 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7896 | |
7897 | // 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] | 7898 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
7899 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, | ||||
7900 | "vkCmdPushConstants() call has push constants with size 0. Size " | ||||
7901 | "must be greater than zero and a multiple of 4."}, | ||||
7902 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, | ||||
7903 | "vkCmdPushConstants() call has push constants with size 1. Size " | ||||
7904 | "must be greater than zero and a multiple of 4."}, | ||||
7905 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, | ||||
7906 | "vkCmdPushConstants() call has push constants with size 1. Size " | ||||
7907 | "must be greater than zero and a multiple of 4."}, | ||||
7908 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, | ||||
7909 | "vkCmdPushConstants() call has push constants with offset 1. " | ||||
7910 | "Offset must be a multiple of 4."}, | ||||
7911 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, | ||||
7912 | "vkCmdPushConstants() call has push constants with offset 1. " | ||||
7913 | "Offset must be a multiple of 4."}, | ||||
7914 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, | ||||
7915 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " | ||||
7916 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7917 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, | ||||
7918 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " | ||||
7919 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7920 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, | ||||
7921 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " | ||||
7922 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7923 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, | ||||
7924 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " | ||||
7925 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7926 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, | ||||
7927 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " | ||||
7928 | "any of the ranges in pipeline layout"}, | ||||
7929 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, | ||||
7930 | 0, 16}, | ||||
7931 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " | ||||
7932 | "any of the ranges in pipeline layout"}, | ||||
7933 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7934 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7935 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7936 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7937 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7938 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7939 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7940 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7941 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7942 | "vkCmdPushConstants() call has push constants with offset "}, |
7943 | }}; | ||||
7944 | |||||
7945 | // Two ranges for testing robustness | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7946 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7947 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7948 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7949 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7950 | pipeline_layout_ci.pushConstantRangeCount = |
7951 | sizeof(pc_range2) / sizeof(VkPushConstantRange); | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7952 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 7953 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
7954 | &pipeline_layout); | ||||
7955 | ASSERT_VK_SUCCESS(err); | ||||
7956 | BeginCommandBuffer(); | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7957 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7958 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
7959 | iter.msg); | ||||
7960 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7961 | iter.range.stageFlags, iter.range.offset, |
7962 | iter.range.size, dummy_values); | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7963 | m_errorMonitor->VerifyFound(); |
7964 | } | ||||
7965 | |||||
7966 | // Check for invalid stage flag | ||||
7967 | m_errorMonitor->SetDesiredFailureMsg( | ||||
7968 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
7969 | "vkCmdPushConstants() call has no stageFlags set."); | ||||
7970 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, | ||||
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7971 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7972 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7973 | EndCommandBuffer(); |
7974 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); | ||||
7975 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 7976 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 7977 | // overlapping range tests with cmd |
7978 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ | ||||
7979 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, | ||||
7980 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " | ||||
7981 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7982 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, | ||||
7983 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " | ||||
7984 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7985 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, | ||||
7986 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " | ||||
7987 | "0x1 not within flag-matching ranges in pipeline layout"}, | ||||
7988 | }}; | ||||
7989 | const VkPushConstantRange pc_range3[] = { | ||||
7990 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, | ||||
7991 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, | ||||
7992 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
7993 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, | ||||
7994 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, | ||||
7995 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, | ||||
7996 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, | ||||
7997 | }; | ||||
7998 | pipeline_layout_ci.pushConstantRangeCount = | ||||
7999 | sizeof(pc_range3) / sizeof(VkPushConstantRange); | ||||
8000 | pipeline_layout_ci.pPushConstantRanges = pc_range3; | ||||
8001 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
8002 | &pipeline_layout); | ||||
8003 | ASSERT_VK_SUCCESS(err); | ||||
8004 | BeginCommandBuffer(); | ||||
8005 | for (const auto &iter : cmd_overlap_tests) { | ||||
8006 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8007 | iter.msg); | ||||
8008 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, | ||||
8009 | iter.range.stageFlags, iter.range.offset, | ||||
8010 | iter.range.size, dummy_values); | ||||
8011 | m_errorMonitor->VerifyFound(); | ||||
8012 | } | ||||
8013 | EndCommandBuffer(); | ||||
8014 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); | ||||
8015 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
8016 | |||||
8017 | // positive overlapping range tests with cmd | ||||
8018 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ | ||||
8019 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, | ||||
8020 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, | ||||
8021 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, | ||||
8022 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, | ||||
8023 | }}; | ||||
8024 | const VkPushConstantRange pc_range4[] = { | ||||
8025 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, | ||||
8026 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, | ||||
8027 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, | ||||
8028 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, | ||||
8029 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, | ||||
8030 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, | ||||
8031 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, | ||||
8032 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, | ||||
8033 | }; | ||||
8034 | pipeline_layout_ci.pushConstantRangeCount = | ||||
8035 | sizeof(pc_range4) / sizeof(VkPushConstantRange); | ||||
8036 | pipeline_layout_ci.pPushConstantRanges = pc_range4; | ||||
8037 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
8038 | &pipeline_layout); | ||||
8039 | ASSERT_VK_SUCCESS(err); | ||||
8040 | BeginCommandBuffer(); | ||||
8041 | for (const auto &iter : cmd_overlap_tests_pos) { | ||||
8042 | m_errorMonitor->ExpectSuccess(); | ||||
8043 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, | ||||
8044 | iter.range.stageFlags, iter.range.offset, | ||||
8045 | iter.range.size, dummy_values); | ||||
8046 | m_errorMonitor->VerifyNotFound(); | ||||
8047 | } | ||||
8048 | EndCommandBuffer(); | ||||
8049 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); | ||||
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 8050 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
8051 | } | ||||
8052 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8053 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8054 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8055 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8056 | |
8057 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
8058 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
8059 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
8060 | |||||
Mike Stroyan | b8a6100 | 2016-06-20 16:00:28 -0600 | [diff] [blame] | 8061 | const VkFormat tex_format = VK_FORMAT_R8G8B8A8_UNORM; |
8062 | VkImageTiling tiling; | ||||
8063 | VkFormatProperties format_properties; | ||||
8064 | vkGetPhysicalDeviceFormatProperties(gpu(), tex_format, &format_properties); | ||||
8065 | if (format_properties.linearTilingFeatures & | ||||
8066 | VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) { | ||||
8067 | tiling = VK_IMAGE_TILING_LINEAR; | ||||
8068 | } else if (format_properties.optimalTilingFeatures & | ||||
8069 | VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) { | ||||
8070 | tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
8071 | } else { | ||||
8072 | printf("Device does not support VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT; " | ||||
8073 | "skipped.\n"); | ||||
8074 | return; | ||||
8075 | } | ||||
8076 | |||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8077 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
8078 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8079 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
8080 | ds_type_count[0].descriptorCount = 10; | ||||
8081 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
8082 | ds_type_count[1].descriptorCount = 2; | ||||
8083 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; | ||||
8084 | ds_type_count[2].descriptorCount = 2; | ||||
8085 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
8086 | ds_type_count[3].descriptorCount = 5; | ||||
8087 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT | ||||
8088 | // type | ||||
8089 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; | ||||
8090 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; | ||||
8091 | ds_type_count[4].descriptorCount = 2; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8092 | |
8093 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8094 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8095 | ds_pool_ci.pNext = NULL; | ||||
8096 | ds_pool_ci.maxSets = 5; | ||||
8097 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; | ||||
8098 | ds_pool_ci.pPoolSizes = ds_type_count; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8099 | |
8100 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8101 | err = |
8102 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8103 | ASSERT_VK_SUCCESS(err); |
8104 | |||||
8105 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; | ||||
8106 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8107 | dsl_binding[0].binding = 0; |
8108 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8109 | dsl_binding[0].descriptorCount = 5; | ||||
8110 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; | ||||
8111 | dsl_binding[0].pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8112 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8113 | // Create layout identical to set0 layout but w/ different stageFlags |
8114 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8115 | dsl_fs_stage_only.binding = 0; |
8116 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8117 | dsl_fs_stage_only.descriptorCount = 5; | ||||
8118 | dsl_fs_stage_only.stageFlags = | ||||
8119 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at | ||||
8120 | // bind time | ||||
8121 | dsl_fs_stage_only.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8122 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8123 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
8124 | ds_layout_ci.pNext = NULL; | ||||
8125 | ds_layout_ci.bindingCount = 1; | ||||
8126 | ds_layout_ci.pBindings = dsl_binding; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8127 | static const uint32_t NUM_LAYOUTS = 4; |
8128 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8129 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8130 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
8131 | // layout for error case | ||||
8132 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
8133 | &ds_layout[0]); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8134 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 8135 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8136 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8137 | &ds_layout_fs_only); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8138 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8139 | dsl_binding[0].binding = 0; |
8140 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8141 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 8142 | dsl_binding[1].binding = 1; |
8143 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; | ||||
8144 | dsl_binding[1].descriptorCount = 2; | ||||
8145 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; | ||||
8146 | dsl_binding[1].pImmutableSamplers = NULL; | ||||
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 8147 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8148 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8149 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8150 | &ds_layout[1]); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8151 | ASSERT_VK_SUCCESS(err); |
8152 | dsl_binding[0].binding = 0; | ||||
8153 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8154 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8155 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8156 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8157 | &ds_layout[2]); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8158 | ASSERT_VK_SUCCESS(err); |
8159 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8160 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8161 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8162 | &ds_layout[3]); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8163 | ASSERT_VK_SUCCESS(err); |
8164 | |||||
8165 | static const uint32_t NUM_SETS = 4; | ||||
8166 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; | ||||
8167 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8168 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8169 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8170 | alloc_info.descriptorPool = ds_pool; |
8171 | alloc_info.pSetLayouts = ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8172 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
8173 | descriptorSet); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8174 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8175 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8176 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8177 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8178 | err = |
8179 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8180 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8181 | |
8182 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8183 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
8184 | pipeline_layout_ci.pNext = NULL; | ||||
8185 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; | ||||
8186 | pipeline_layout_ci.pSetLayouts = ds_layout; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8187 | |
8188 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8189 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8190 | &pipeline_layout); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8191 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8192 | // Create pipelineLayout with only one setLayout |
8193 | pipeline_layout_ci.setLayoutCount = 1; | ||||
8194 | VkPipelineLayout single_pipe_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8195 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8196 | &single_pipe_layout); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8197 | ASSERT_VK_SUCCESS(err); |
8198 | // Create pipelineLayout with 2 descriptor setLayout at index 0 | ||||
8199 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; | ||||
8200 | VkPipelineLayout pipe_layout_one_desc; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8201 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8202 | &pipe_layout_one_desc); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8203 | ASSERT_VK_SUCCESS(err); |
8204 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 | ||||
8205 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; | ||||
8206 | VkPipelineLayout pipe_layout_five_samp; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8207 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8208 | &pipe_layout_five_samp); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8209 | ASSERT_VK_SUCCESS(err); |
8210 | // Create pipelineLayout with UB type, but stageFlags for FS only | ||||
8211 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; | ||||
8212 | VkPipelineLayout pipe_layout_fs_only; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8213 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8214 | &pipe_layout_fs_only); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8215 | ASSERT_VK_SUCCESS(err); |
8216 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine | ||||
8217 | VkDescriptorSetLayout pl_bad_s0[2] = {}; | ||||
8218 | pl_bad_s0[0] = ds_layout_fs_only; | ||||
8219 | pl_bad_s0[1] = ds_layout[1]; | ||||
8220 | pipeline_layout_ci.setLayoutCount = 2; | ||||
8221 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; | ||||
8222 | VkPipelineLayout pipe_layout_bad_set0; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8223 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8224 | &pipe_layout_bad_set0); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8225 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8226 | |
8227 | // Create a buffer to update the descriptor with | ||||
8228 | uint32_t qfi = 0; | ||||
8229 | VkBufferCreateInfo buffCI = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8230 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
8231 | buffCI.size = 1024; | ||||
8232 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
8233 | buffCI.queueFamilyIndexCount = 1; | ||||
8234 | buffCI.pQueueFamilyIndices = &qfi; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8235 | |
8236 | VkBuffer dyub; | ||||
8237 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); | ||||
8238 | ASSERT_VK_SUCCESS(err); | ||||
8239 | // Correctly update descriptor to avoid "NOT_UPDATED" error | ||||
8240 | static const uint32_t NUM_BUFFS = 5; | ||||
8241 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8242 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8243 | buffInfo[i].buffer = dyub; |
8244 | buffInfo[i].offset = 0; | ||||
8245 | buffInfo[i].range = 1024; | ||||
8246 | } | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8247 | VkImage image; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8248 | const int32_t tex_width = 32; |
8249 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8250 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8251 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
8252 | image_create_info.pNext = NULL; | ||||
8253 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
8254 | image_create_info.format = tex_format; | ||||
8255 | image_create_info.extent.width = tex_width; | ||||
8256 | image_create_info.extent.height = tex_height; | ||||
8257 | image_create_info.extent.depth = 1; | ||||
8258 | image_create_info.mipLevels = 1; | ||||
8259 | image_create_info.arrayLayers = 1; | ||||
8260 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
Mike Stroyan | b8a6100 | 2016-06-20 16:00:28 -0600 | [diff] [blame] | 8261 | image_create_info.tiling = tiling; |
8262 | image_create_info.usage = | ||||
8263 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8264 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8265 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
8266 | ASSERT_VK_SUCCESS(err); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8267 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8268 | VkMemoryRequirements memReqs; |
8269 | VkDeviceMemory imageMem; | ||||
8270 | bool pass; | ||||
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 8271 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8272 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
8273 | memAlloc.pNext = NULL; | ||||
8274 | memAlloc.allocationSize = 0; | ||||
8275 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 8276 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
8277 | memAlloc.allocationSize = memReqs.size; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8278 | pass = |
8279 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 8280 | ASSERT_TRUE(pass); |
8281 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); | ||||
8282 | ASSERT_VK_SUCCESS(err); | ||||
8283 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); | ||||
8284 | ASSERT_VK_SUCCESS(err); | ||||
8285 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8286 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8287 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
8288 | image_view_create_info.image = image; | ||||
8289 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
8290 | image_view_create_info.format = tex_format; | ||||
8291 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
8292 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
8293 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
8294 | image_view_create_info.subresourceRange.aspectMask = | ||||
8295 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8296 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8297 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8298 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
8299 | &view); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8300 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 8301 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8302 | imageInfo[0].imageView = view; |
8303 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
8304 | imageInfo[1].imageView = view; | ||||
8305 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 8306 | imageInfo[2].imageView = view; |
8307 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
8308 | imageInfo[3].imageView = view; | ||||
8309 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8310 | |
8311 | static const uint32_t NUM_SET_UPDATES = 3; | ||||
8312 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; | ||||
8313 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
8314 | descriptor_write[0].dstSet = descriptorSet[0]; | ||||
8315 | descriptor_write[0].dstBinding = 0; | ||||
8316 | descriptor_write[0].descriptorCount = 5; | ||||
8317 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8318 | descriptor_write[0].pBufferInfo = buffInfo; | ||||
8319 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
8320 | descriptor_write[1].dstSet = descriptorSet[1]; | ||||
8321 | descriptor_write[1].dstBinding = 0; | ||||
8322 | descriptor_write[1].descriptorCount = 2; | ||||
8323 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
8324 | descriptor_write[1].pImageInfo = imageInfo; | ||||
8325 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
8326 | descriptor_write[2].dstSet = descriptorSet[1]; | ||||
8327 | descriptor_write[2].dstBinding = 1; | ||||
8328 | descriptor_write[2].descriptorCount = 2; | ||||
8329 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; | ||||
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 8330 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8331 | |
8332 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8333 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 8334 | // Create PSO to be used for draw-time errors below |
8335 | char const *vsSource = | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 8336 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 8337 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8338 | "out gl_PerVertex {\n" |
8339 | " vec4 gl_Position;\n" | ||||
8340 | "};\n" | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 8341 | "void main(){\n" |
8342 | " gl_Position = vec4(1);\n" | ||||
8343 | "}\n"; | ||||
8344 | char const *fsSource = | ||||
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 8345 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 8346 | "\n" |
8347 | "layout(location=0) out vec4 x;\n" | ||||
8348 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" | ||||
8349 | "void main(){\n" | ||||
8350 | " x = vec4(bar.y);\n" | ||||
8351 | "}\n"; | ||||
8352 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
8353 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8354 | VkPipelineObj pipe(m_device); |
8355 | pipe.AddShader(&vs); | ||||
8356 | pipe.AddShader(&fs); | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 8357 | pipe.AddColorAttachment(); |
8358 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8359 | |
8360 | BeginCommandBuffer(); | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 8361 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8362 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
8363 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
8364 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding | ||||
8365 | // of PSO | ||||
8366 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of | ||||
8367 | // cmd_pipeline.c | ||||
8368 | // due to the fact that cmd_alloc_dset_data() has not been called in | ||||
8369 | // cmd_bind_graphics_pipeline() | ||||
8370 | // TODO : Want to cause various binding incompatibility issues here to test | ||||
8371 | // DrawState | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8372 | // First cause various verify_layout_compatibility() fails |
8373 | // Second disturb early and late sets and verify INFO msgs | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8374 | // verify_set_layout_compatibility fail cases: |
8375 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8376 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 01714f5 | 2016-07-06 09:35:04 -0600 | [diff] [blame] | 8377 | "Invalid Pipeline Layout Object "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8378 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
8379 | VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
8380 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, | ||||
8381 | &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8382 | m_errorMonitor->VerifyFound(); |
8383 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8384 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8385 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
8386 | " attempting to bind set to index 1"); | ||||
8387 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
8388 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, | ||||
8389 | 0, 2, &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8390 | m_errorMonitor->VerifyFound(); |
8391 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8392 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8393 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
8394 | // descriptors | ||||
8395 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8396 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 8397 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8398 | vkCmdBindDescriptorSets( |
8399 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
8400 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8401 | m_errorMonitor->VerifyFound(); |
8402 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8403 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
8404 | // 4. same # of descriptors but mismatch in type | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8405 | m_errorMonitor->SetDesiredFailureMsg( |
8406 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 8407 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8408 | vkCmdBindDescriptorSets( |
8409 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
8410 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8411 | m_errorMonitor->VerifyFound(); |
8412 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8413 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
8414 | // 5. same # of descriptors but mismatch in stageFlags | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8415 | m_errorMonitor->SetDesiredFailureMsg( |
8416 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 8417 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8418 | vkCmdBindDescriptorSets( |
8419 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
8420 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8421 | m_errorMonitor->VerifyFound(); |
8422 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8423 | // Cause INFO messages due to disturbing previously bound Sets |
8424 | // First bind sets 0 & 1 | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8425 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
8426 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
8427 | 2, &descriptorSet[0], 0, NULL); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8428 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8429 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8430 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8431 | " previously bound as set #0 was disturbed "); |
8432 | vkCmdBindDescriptorSets( | ||||
8433 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
8434 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8435 | m_errorMonitor->VerifyFound(); |
8436 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8437 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
8438 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
8439 | 2, &descriptorSet[0], 0, NULL); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8440 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8441 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8442 | " newly bound as set #0 so set #1 and " |
8443 | "any subsequent sets were disturbed "); | ||||
8444 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
8445 | VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
8446 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8447 | m_errorMonitor->VerifyFound(); |
8448 | |||||
Tobin Ehlis | 10fad69 | 2016-07-07 12:00:36 -0600 | [diff] [blame] | 8449 | // Now that we're done actively using the pipelineLayout that gfx pipeline |
8450 | // was created with, we should be able to delete it. Do that now to verify | ||||
8451 | // that validation obeys pipelineLayout lifetime | ||||
8452 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); | ||||
8453 | |||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 8454 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8455 | // 1. Error due to not binding required set (we actually use same code as |
8456 | // above to disturb set0) | ||||
8457 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
8458 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
8459 | 2, &descriptorSet[0], 0, NULL); | ||||
8460 | vkCmdBindDescriptorSets( | ||||
8461 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, | ||||
8462 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); | ||||
8463 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8464 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8465 | " uses set #0 but that set is not bound."); | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 8466 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8467 | m_errorMonitor->VerifyFound(); |
8468 | |||||
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 8469 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8470 | // 2. Error due to bound set not being compatible with PSO's |
8471 | // VkPipelineLayout (diff stageFlags in this case) | ||||
8472 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), | ||||
8473 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, | ||||
8474 | 2, &descriptorSet[0], 0, NULL); | ||||
8475 | m_errorMonitor->SetDesiredFailureMsg( | ||||
8476 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8477 | " bound as set #0 is not compatible with "); | ||||
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 8478 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8479 | m_errorMonitor->VerifyFound(); |
8480 | |||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8481 | // Remaining clean-up |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8482 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8483 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
8484 | } | ||||
8485 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); | ||||
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 8486 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
8487 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); | ||||
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 8488 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8489 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
8490 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 8491 | vkFreeMemory(m_device->device(), imageMem, NULL); |
8492 | vkDestroyImage(m_device->device(), image, NULL); | ||||
8493 | vkDestroyImageView(m_device->device(), view, NULL); | ||||
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8494 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 8495 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8496 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8497 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8498 | m_errorMonitor->SetDesiredFailureMsg( |
8499 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8500 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8501 | |
8502 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8503 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8504 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8505 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8506 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8507 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8508 | } |
8509 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8510 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
8511 | VkResult err; | ||||
8512 | VkCommandBuffer draw_cmd; | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8513 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8514 | m_errorMonitor->SetDesiredFailureMsg( |
8515 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 8516 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8517 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 8518 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 8519 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8520 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8521 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 8522 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8523 | cmd.commandPool = m_commandPool; |
8524 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; | ||||
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8525 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 8526 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8527 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8528 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 8529 | |
8530 | // Force the failure by not setting the Renderpass and Framebuffer fields | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8531 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8532 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8533 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 8534 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8535 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
8536 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; | ||||
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8537 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 8538 | |
8539 | // The error should be caught by validation of the BeginCommandBuffer call | ||||
8540 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); | ||||
8541 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8542 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8543 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 8544 | } |
8545 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8546 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 8547 | // Cause error due to Begin while recording CB |
8548 | // Then cause 2 errors for attempting to reset CB w/o having | ||||
8549 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from | ||||
8550 | // which CBs were allocated. Note that this bit is off by default. | ||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8551 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8552 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 8553 | |
8554 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
8555 | |||||
8556 | // Calls AllocateCommandBuffers | ||||
8557 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); | ||||
8558 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8559 | // Force the failure by setting the Renderpass and Framebuffer fields with |
8560 | // (fake) data | ||||
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 8561 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8562 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 8563 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
8564 | cmd_buf_info.pNext = NULL; | ||||
8565 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; | ||||
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8566 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 8567 | |
8568 | // Begin CB to transition to recording state | ||||
8569 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); | ||||
8570 | // Can't re-begin. This should trigger error | ||||
8571 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8572 | m_errorMonitor->VerifyFound(); |
8573 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8574 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
8575 | "Attempt to reset command buffer "); | ||||
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 8576 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
8577 | // Reset attempt will trigger error due to incorrect CommandPool state | ||||
8578 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8579 | m_errorMonitor->VerifyFound(); |
8580 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8581 | m_errorMonitor->SetDesiredFailureMsg( |
8582 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
8583 | " attempts to implicitly reset cmdBuffer created from "); | ||||
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 8584 | // Transition CB to RECORDED state |
8585 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); | ||||
8586 | // Now attempting to Begin will implicitly reset, which triggers error | ||||
8587 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8588 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 8589 | } |
8590 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8591 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8592 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8593 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8594 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8595 | m_errorMonitor->SetDesiredFailureMsg( |
8596 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8597 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
8598 | |||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8599 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8600 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8601 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8602 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8603 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
8604 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8605 | |
8606 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8607 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8608 | ds_pool_ci.pNext = NULL; | ||||
8609 | ds_pool_ci.maxSets = 1; | ||||
8610 | ds_pool_ci.poolSizeCount = 1; | ||||
8611 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8612 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8613 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8614 | err = |
8615 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8616 | ASSERT_VK_SUCCESS(err); |
8617 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8618 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8619 | dsl_binding.binding = 0; |
8620 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8621 | dsl_binding.descriptorCount = 1; | ||||
8622 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
8623 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8624 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8625 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8626 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
8627 | ds_layout_ci.pNext = NULL; | ||||
8628 | ds_layout_ci.bindingCount = 1; | ||||
8629 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8630 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8631 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8632 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8633 | &ds_layout); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8634 | ASSERT_VK_SUCCESS(err); |
8635 | |||||
8636 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8637 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8638 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8639 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8640 | alloc_info.descriptorPool = ds_pool; |
8641 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8642 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
8643 | &descriptorSet); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8644 | ASSERT_VK_SUCCESS(err); |
8645 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8646 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8647 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
8648 | pipeline_layout_ci.setLayoutCount = 1; | ||||
8649 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8650 | |
8651 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8652 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8653 | &pipeline_layout); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8654 | ASSERT_VK_SUCCESS(err); |
8655 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8656 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8657 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8658 | |
8659 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8660 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
8661 | vp_state_ci.scissorCount = 1; | ||||
8662 | vp_state_ci.pScissors = ≻ | ||||
8663 | vp_state_ci.viewportCount = 1; | ||||
8664 | vp_state_ci.pViewports = &vp; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8665 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 8666 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
8667 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
8668 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; | ||||
8669 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; | ||||
8670 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; | ||||
8671 | rs_state_ci.depthClampEnable = VK_FALSE; | ||||
8672 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; | ||||
8673 | rs_state_ci.depthBiasEnable = VK_FALSE; | ||||
8674 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8675 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8676 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
8677 | gp_ci.pViewportState = &vp_state_ci; | ||||
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 8678 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8679 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
8680 | gp_ci.layout = pipeline_layout; | ||||
8681 | gp_ci.renderPass = renderPass(); | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8682 | |
8683 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8684 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
8685 | pc_ci.initialDataSize = 0; | ||||
8686 | pc_ci.pInitialData = 0; | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8687 | |
8688 | VkPipeline pipeline; | ||||
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 8689 | VkPipelineCache pipelineCache; |
8690 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8691 | err = |
8692 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 8693 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8694 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
8695 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 8696 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8697 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8698 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8699 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
8700 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
8701 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8702 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8703 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8704 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
8705 | TEST_F(VkLayerTest, InvalidPatchControlPoints) | ||||
8706 | { | ||||
8707 | // Attempt to Create Gfx Pipeline w/o a VS | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8708 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 8709 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8710 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8711 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
8712 | primitive "); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8713 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8714 | ASSERT_NO_FATAL_FAILURE(InitState()); |
8715 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8716 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8717 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8718 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8719 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8720 | |
8721 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
8722 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
8723 | ds_pool_ci.pNext = NULL; | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8724 | ds_pool_ci.poolSizeCount = 1; |
8725 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8726 | |
8727 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8728 | err = vkCreateDescriptorPool(m_device->device(), |
8729 | 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] | 8730 | ASSERT_VK_SUCCESS(err); |
8731 | |||||
8732 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8733 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8734 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 8735 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8736 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
8737 | dsl_binding.pImmutableSamplers = NULL; | ||||
8738 | |||||
8739 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8740 | ds_layout_ci.sType = |
8741 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8742 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8743 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 8744 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8745 | |
8746 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8747 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8748 | &ds_layout); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8749 | ASSERT_VK_SUCCESS(err); |
8750 | |||||
8751 | VkDescriptorSet descriptorSet; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8752 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
8753 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8754 | ASSERT_VK_SUCCESS(err); |
8755 | |||||
8756 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8757 | pipeline_layout_ci.sType = |
8758 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8759 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 8760 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8761 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
8762 | |||||
8763 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8764 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8765 | &pipeline_layout); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8766 | ASSERT_VK_SUCCESS(err); |
8767 | |||||
8768 | VkPipelineShaderStageCreateInfo shaderStages[3]; | ||||
8769 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); | ||||
8770 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8771 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
8772 | this); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8773 | // 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] | 8774 | VkShaderObj |
8775 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, | ||||
8776 | this); | ||||
8777 | VkShaderObj | ||||
8778 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, | ||||
8779 | this); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8780 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8781 | shaderStages[0].sType = |
8782 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; | ||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8783 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8784 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8785 | shaderStages[1].sType = |
8786 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; | ||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8787 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8788 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8789 | shaderStages[2].sType = |
8790 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; | ||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8791 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8792 | shaderStages[2].shader = te.handle(); |
8793 | |||||
8794 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8795 | iaCI.sType = |
8796 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8797 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8798 | |
8799 | VkPipelineTessellationStateCreateInfo tsCI = {}; | ||||
8800 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; | ||||
8801 | tsCI.patchControlPoints = 0; // This will cause an error | ||||
8802 | |||||
8803 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
8804 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; | ||||
8805 | gp_ci.pNext = NULL; | ||||
8806 | gp_ci.stageCount = 3; | ||||
8807 | gp_ci.pStages = shaderStages; | ||||
8808 | gp_ci.pVertexInputState = NULL; | ||||
8809 | gp_ci.pInputAssemblyState = &iaCI; | ||||
8810 | gp_ci.pTessellationState = &tsCI; | ||||
8811 | gp_ci.pViewportState = NULL; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8812 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8813 | gp_ci.pMultisampleState = NULL; |
8814 | gp_ci.pDepthStencilState = NULL; | ||||
8815 | gp_ci.pColorBlendState = NULL; | ||||
8816 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
8817 | gp_ci.layout = pipeline_layout; | ||||
8818 | gp_ci.renderPass = renderPass(); | ||||
8819 | |||||
8820 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
8821 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; | ||||
8822 | pc_ci.pNext = NULL; | ||||
8823 | pc_ci.initialSize = 0; | ||||
8824 | pc_ci.initialData = 0; | ||||
8825 | pc_ci.maxSize = 0; | ||||
8826 | |||||
8827 | VkPipeline pipeline; | ||||
8828 | VkPipelineCache pipelineCache; | ||||
8829 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8830 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
8831 | &pipelineCache); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8832 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8833 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
8834 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8835 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8836 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8837 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8838 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
8839 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
8840 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8841 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 8842 | } |
8843 | */ | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8844 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8845 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8846 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8847 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8848 | m_errorMonitor->SetDesiredFailureMsg( |
8849 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8850 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
8851 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8852 | ASSERT_NO_FATAL_FAILURE(InitState()); |
8853 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8854 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8855 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8856 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
8857 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8858 | |
8859 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8860 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8861 | ds_pool_ci.maxSets = 1; | ||||
8862 | ds_pool_ci.poolSizeCount = 1; | ||||
8863 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8864 | |
8865 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8866 | err = |
8867 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8868 | ASSERT_VK_SUCCESS(err); |
8869 | |||||
8870 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8871 | dsl_binding.binding = 0; |
8872 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8873 | dsl_binding.descriptorCount = 1; | ||||
8874 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8875 | |
8876 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8877 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
8878 | ds_layout_ci.bindingCount = 1; | ||||
8879 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8880 | |
8881 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8882 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
8883 | &ds_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8884 | ASSERT_VK_SUCCESS(err); |
8885 | |||||
8886 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8887 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8888 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8889 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8890 | alloc_info.descriptorPool = ds_pool; |
8891 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8892 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
8893 | &descriptorSet); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8894 | ASSERT_VK_SUCCESS(err); |
8895 | |||||
8896 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8897 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
8898 | pipeline_layout_ci.setLayoutCount = 1; | ||||
8899 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8900 | |
8901 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8902 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
8903 | &pipeline_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8904 | ASSERT_VK_SUCCESS(err); |
8905 | |||||
8906 | VkViewport vp = {}; // Just need dummy vp to point to | ||||
8907 | |||||
8908 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8909 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
8910 | vp_state_ci.scissorCount = 0; | ||||
8911 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error | ||||
8912 | vp_state_ci.pViewports = &vp; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8913 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 8914 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
8915 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
8916 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; | ||||
8917 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; | ||||
8918 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; | ||||
8919 | rs_state_ci.depthClampEnable = VK_FALSE; | ||||
8920 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; | ||||
8921 | rs_state_ci.depthBiasEnable = VK_FALSE; | ||||
8922 | |||||
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 8923 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8924 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8925 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8926 | VkShaderObj vs(m_device, bindStateVertShaderText, |
8927 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
8928 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
8929 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8930 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8931 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 8932 | shaderStages[0] = vs.GetStageCreateInfo(); |
8933 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8934 | |
8935 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8936 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
8937 | gp_ci.stageCount = 2; | ||||
8938 | gp_ci.pStages = shaderStages; | ||||
8939 | gp_ci.pViewportState = &vp_state_ci; | ||||
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 8940 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8941 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
8942 | gp_ci.layout = pipeline_layout; | ||||
8943 | gp_ci.renderPass = renderPass(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8944 | |
8945 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8946 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8947 | |
8948 | VkPipeline pipeline; | ||||
8949 | VkPipelineCache pipelineCache; | ||||
8950 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8951 | err = |
8952 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8953 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8954 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
8955 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8956 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8957 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8958 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8959 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
8960 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
8961 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
8962 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8963 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8964 | // Don't set viewport state in PSO. This is an error b/c we always need this |
8965 | // state | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8966 | // 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] | 8967 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8968 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8969 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8970 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8971 | m_errorMonitor->SetDesiredFailureMsg( |
8972 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8973 | "Gfx Pipeline pViewportState is null. Even if "); |
8974 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8975 | ASSERT_NO_FATAL_FAILURE(InitState()); |
8976 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8977 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8978 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8979 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
8980 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8981 | |
8982 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8983 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
8984 | ds_pool_ci.maxSets = 1; | ||||
8985 | ds_pool_ci.poolSizeCount = 1; | ||||
8986 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8987 | |
8988 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8989 | err = |
8990 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8991 | ASSERT_VK_SUCCESS(err); |
8992 | |||||
8993 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8994 | dsl_binding.binding = 0; |
8995 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
8996 | dsl_binding.descriptorCount = 1; | ||||
8997 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 8998 | |
8999 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9000 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
9001 | ds_layout_ci.bindingCount = 1; | ||||
9002 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9003 | |
9004 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9005 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
9006 | &ds_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9007 | ASSERT_VK_SUCCESS(err); |
9008 | |||||
9009 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9010 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9011 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9012 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9013 | alloc_info.descriptorPool = ds_pool; |
9014 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9015 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
9016 | &descriptorSet); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9017 | ASSERT_VK_SUCCESS(err); |
9018 | |||||
9019 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9020 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
9021 | pipeline_layout_ci.setLayoutCount = 1; | ||||
9022 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9023 | |
9024 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9025 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
9026 | &pipeline_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9027 | ASSERT_VK_SUCCESS(err); |
9028 | |||||
9029 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; | ||||
9030 | // Set scissor as dynamic to avoid second error | ||||
9031 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9032 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
9033 | dyn_state_ci.dynamicStateCount = 1; | ||||
9034 | dyn_state_ci.pDynamicStates = &sc_state; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9035 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 9036 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9037 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9038 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9039 | VkShaderObj vs(m_device, bindStateVertShaderText, |
9040 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9041 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
9042 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9043 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9044 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 9045 | shaderStages[0] = vs.GetStageCreateInfo(); |
9046 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9047 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 9048 | |
9049 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; | ||||
9050 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
9051 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; | ||||
9052 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; | ||||
9053 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; | ||||
9054 | rs_state_ci.depthClampEnable = VK_FALSE; | ||||
9055 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; | ||||
9056 | rs_state_ci.depthBiasEnable = VK_FALSE; | ||||
9057 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9058 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9059 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
9060 | gp_ci.stageCount = 2; | ||||
9061 | gp_ci.pStages = shaderStages; | ||||
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 9062 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9063 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
9064 | // should cause validation error | ||||
9065 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
9066 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
9067 | gp_ci.layout = pipeline_layout; | ||||
9068 | gp_ci.renderPass = renderPass(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9069 | |
9070 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9071 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9072 | |
9073 | VkPipeline pipeline; | ||||
9074 | VkPipelineCache pipelineCache; | ||||
9075 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9076 | err = |
9077 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9078 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9079 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
9080 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9081 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9082 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9083 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9084 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
9085 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
9086 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
9087 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9088 | } |
9089 | // Create PSO w/o non-zero viewportCount but no viewport data | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9090 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
9091 | // count | ||||
9092 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { | ||||
9093 | VkResult err; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9094 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9095 | m_errorMonitor->SetDesiredFailureMsg( |
9096 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9097 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
9098 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9099 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | c08a6ca | 2016-07-28 14:14:07 +1200 | [diff] [blame] | 9100 | |
9101 | if (!m_device->phy().features().multiViewport) { | ||||
9102 | printf("Device does not support multiple viewports/scissors; skipped.\n"); | ||||
9103 | return; | ||||
9104 | } | ||||
9105 | |||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9106 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9107 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9108 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9109 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
9110 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9111 | |
9112 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9113 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
9114 | ds_pool_ci.maxSets = 1; | ||||
9115 | ds_pool_ci.poolSizeCount = 1; | ||||
9116 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9117 | |
9118 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9119 | err = |
9120 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9121 | ASSERT_VK_SUCCESS(err); |
9122 | |||||
9123 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9124 | dsl_binding.binding = 0; |
9125 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
9126 | dsl_binding.descriptorCount = 1; | ||||
9127 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9128 | |
9129 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9130 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
9131 | ds_layout_ci.bindingCount = 1; | ||||
9132 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9133 | |
9134 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9135 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
9136 | &ds_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9137 | ASSERT_VK_SUCCESS(err); |
9138 | |||||
9139 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9140 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9141 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9142 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 9143 | alloc_info.descriptorPool = ds_pool; |
9144 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9145 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
9146 | &descriptorSet); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9147 | ASSERT_VK_SUCCESS(err); |
9148 | |||||
9149 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9150 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
9151 | pipeline_layout_ci.setLayoutCount = 1; | ||||
9152 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9153 | |
9154 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9155 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
9156 | &pipeline_layout); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9157 | ASSERT_VK_SUCCESS(err); |
9158 | |||||
9159 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9160 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
9161 | vp_state_ci.viewportCount = 1; | ||||
9162 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error | ||||
9163 | vp_state_ci.scissorCount = 1; | ||||
9164 | vp_state_ci.pScissors = | ||||
9165 | NULL; // Scissor is dynamic (below) so this won't cause error | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9166 | |
9167 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; | ||||
9168 | // Set scissor as dynamic to avoid that error | ||||
9169 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9170 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
9171 | dyn_state_ci.dynamicStateCount = 1; | ||||
9172 | dyn_state_ci.pDynamicStates = &sc_state; | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9173 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 9174 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9175 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9176 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9177 | VkShaderObj vs(m_device, bindStateVertShaderText, |
9178 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9179 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
9180 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9181 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9182 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 9183 | shaderStages[0] = vs.GetStageCreateInfo(); |
9184 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9185 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 9186 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
9187 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; | ||||
9188 | vi_ci.pNext = nullptr; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9189 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 9190 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 9191 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 9192 | vi_ci.pVertexAttributeDescriptions = nullptr; |
9193 | |||||
9194 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; | ||||
9195 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
9196 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; | ||||
9197 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9198 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9199 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 9200 | rs_ci.pNext = nullptr; |
9201 | |||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9202 | VkPipelineColorBlendAttachmentState att = {}; |
9203 | att.blendEnable = VK_FALSE; | ||||
9204 | att.colorWriteMask = 0xf; | ||||
9205 | |||||
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 9206 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
9207 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; | ||||
9208 | cb_ci.pNext = nullptr; | ||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9209 | cb_ci.attachmentCount = 1; |
9210 | cb_ci.pAttachments = &att; | ||||
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 9211 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9212 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9213 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
9214 | gp_ci.stageCount = 2; | ||||
9215 | gp_ci.pStages = shaderStages; | ||||
9216 | gp_ci.pVertexInputState = &vi_ci; | ||||
9217 | gp_ci.pInputAssemblyState = &ia_ci; | ||||
9218 | gp_ci.pViewportState = &vp_state_ci; | ||||
9219 | gp_ci.pRasterizationState = &rs_ci; | ||||
9220 | gp_ci.pColorBlendState = &cb_ci; | ||||
9221 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
9222 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
9223 | gp_ci.layout = pipeline_layout; | ||||
9224 | gp_ci.renderPass = renderPass(); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9225 | |
9226 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9227 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9228 | |
9229 | VkPipeline pipeline; | ||||
9230 | VkPipelineCache pipelineCache; | ||||
9231 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9232 | err = |
9233 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9234 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9235 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
9236 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9237 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9238 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9239 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 9240 | // 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] | 9241 | // First need to successfully create the PSO from above by setting |
9242 | // pViewports | ||||
9243 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9244 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Chris Forbes | c08a6ca | 2016-07-28 14:14:07 +1200 | [diff] [blame] | 9245 | "Dynamic scissor(s) 0 are used by PSO, "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9246 | |
9247 | VkViewport vp = {}; // Just need dummy vp to point to | ||||
9248 | vp_state_ci.pViewports = &vp; | ||||
9249 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
9250 | &gp_ci, NULL, &pipeline); | ||||
9251 | ASSERT_VK_SUCCESS(err); | ||||
9252 | BeginCommandBuffer(); | ||||
9253 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
9254 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); | ||||
Chris Forbes | c08a6ca | 2016-07-28 14:14:07 +1200 | [diff] [blame] | 9255 | VkRect2D scissors[1] = {}; // don't care about data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9256 | // Count of 2 doesn't match PSO count of 1 |
Chris Forbes | c08a6ca | 2016-07-28 14:14:07 +1200 | [diff] [blame] | 9257 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 1, 1, scissors); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9258 | Draw(1, 0, 0, 0); |
9259 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9260 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9261 | |
9262 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); | ||||
9263 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
9264 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
9265 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 9266 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9267 | } |
9268 | // Create PSO w/o non-zero scissorCount but no scissor data | ||||
9269 | // Then run second test where dynamic viewportCount doesn't match PSO | ||||
9270 | // viewportCount | ||||
9271 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { | ||||
9272 | VkResult err; | ||||
9273 | |||||
9274 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9275 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9276 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); | ||||
9277 | |||||
9278 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
Chris Forbes | c08a6ca | 2016-07-28 14:14:07 +1200 | [diff] [blame] | 9279 | |
9280 | if (!m_device->phy().features().multiViewport) { | ||||
9281 | printf("Device does not support multiple viewports/scissors; skipped.\n"); | ||||
9282 | return; | ||||
9283 | } | ||||
9284 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9285 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
9286 | |||||
9287 | VkDescriptorPoolSize ds_type_count = {}; | ||||
9288 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
9289 | ds_type_count.descriptorCount = 1; | ||||
9290 | |||||
9291 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
9292 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
9293 | ds_pool_ci.maxSets = 1; | ||||
9294 | ds_pool_ci.poolSizeCount = 1; | ||||
9295 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
9296 | |||||
9297 | VkDescriptorPool ds_pool; | ||||
9298 | err = | ||||
9299 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
9300 | ASSERT_VK_SUCCESS(err); | ||||
9301 | |||||
9302 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
9303 | dsl_binding.binding = 0; | ||||
9304 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
9305 | dsl_binding.descriptorCount = 1; | ||||
9306 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
9307 | |||||
9308 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
9309 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
9310 | ds_layout_ci.bindingCount = 1; | ||||
9311 | ds_layout_ci.pBindings = &dsl_binding; | ||||
9312 | |||||
9313 | VkDescriptorSetLayout ds_layout; | ||||
9314 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
9315 | &ds_layout); | ||||
9316 | ASSERT_VK_SUCCESS(err); | ||||
9317 | |||||
9318 | VkDescriptorSet descriptorSet; | ||||
9319 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
9320 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
9321 | alloc_info.descriptorSetCount = 1; | ||||
9322 | alloc_info.descriptorPool = ds_pool; | ||||
9323 | alloc_info.pSetLayouts = &ds_layout; | ||||
9324 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
9325 | &descriptorSet); | ||||
9326 | ASSERT_VK_SUCCESS(err); | ||||
9327 | |||||
9328 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
9329 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
9330 | pipeline_layout_ci.setLayoutCount = 1; | ||||
9331 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
9332 | |||||
9333 | VkPipelineLayout pipeline_layout; | ||||
9334 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
9335 | &pipeline_layout); | ||||
9336 | ASSERT_VK_SUCCESS(err); | ||||
9337 | |||||
9338 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
9339 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; | ||||
9340 | vp_state_ci.scissorCount = 1; | ||||
9341 | vp_state_ci.pScissors = | ||||
9342 | NULL; // Null scissor w/ count of 1 should cause error | ||||
9343 | vp_state_ci.viewportCount = 1; | ||||
9344 | vp_state_ci.pViewports = | ||||
9345 | NULL; // vp is dynamic (below) so this won't cause error | ||||
9346 | |||||
9347 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; | ||||
9348 | // Set scissor as dynamic to avoid that error | ||||
9349 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
9350 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; | ||||
9351 | dyn_state_ci.dynamicStateCount = 1; | ||||
9352 | dyn_state_ci.pDynamicStates = &vp_state; | ||||
9353 | |||||
9354 | VkPipelineShaderStageCreateInfo shaderStages[2]; | ||||
9355 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); | ||||
9356 | |||||
9357 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
9358 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9359 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
9360 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9361 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9362 | // but add it to be able to run on more devices |
9363 | shaderStages[0] = vs.GetStageCreateInfo(); | ||||
9364 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
9365 | |||||
9366 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; | ||||
9367 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; | ||||
9368 | vi_ci.pNext = nullptr; | ||||
9369 | vi_ci.vertexBindingDescriptionCount = 0; | ||||
9370 | vi_ci.pVertexBindingDescriptions = nullptr; | ||||
9371 | vi_ci.vertexAttributeDescriptionCount = 0; | ||||
9372 | vi_ci.pVertexAttributeDescriptions = nullptr; | ||||
9373 | |||||
9374 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; | ||||
9375 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
9376 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; | ||||
9377 | |||||
9378 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; | ||||
9379 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
9380 | rs_ci.pNext = nullptr; | ||||
9381 | |||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9382 | VkPipelineColorBlendAttachmentState att = {}; |
9383 | att.blendEnable = VK_FALSE; | ||||
9384 | att.colorWriteMask = 0xf; | ||||
9385 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9386 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
9387 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; | ||||
9388 | cb_ci.pNext = nullptr; | ||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 9389 | cb_ci.attachmentCount = 1; |
9390 | cb_ci.pAttachments = &att; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9391 | |
9392 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
9393 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; | ||||
9394 | gp_ci.stageCount = 2; | ||||
9395 | gp_ci.pStages = shaderStages; | ||||
9396 | gp_ci.pVertexInputState = &vi_ci; | ||||
9397 | gp_ci.pInputAssemblyState = &ia_ci; | ||||
9398 | gp_ci.pViewportState = &vp_state_ci; | ||||
9399 | gp_ci.pRasterizationState = &rs_ci; | ||||
9400 | gp_ci.pColorBlendState = &cb_ci; | ||||
9401 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
9402 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
9403 | gp_ci.layout = pipeline_layout; | ||||
9404 | gp_ci.renderPass = renderPass(); | ||||
9405 | |||||
9406 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
9407 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; | ||||
9408 | |||||
9409 | VkPipeline pipeline; | ||||
9410 | VkPipelineCache pipelineCache; | ||||
9411 | |||||
9412 | err = | ||||
9413 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
9414 | ASSERT_VK_SUCCESS(err); | ||||
9415 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
9416 | &gp_ci, NULL, &pipeline); | ||||
9417 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9418 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9419 | |
9420 | // Now hit second fail case where we set scissor w/ different count than PSO | ||||
9421 | // First need to successfully create the PSO from above by setting | ||||
9422 | // pViewports | ||||
9423 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9424 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Chris Forbes | c08a6ca | 2016-07-28 14:14:07 +1200 | [diff] [blame] | 9425 | "Dynamic viewport(s) 0 are used by PSO, "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9426 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 9427 | VkRect2D sc = {}; // Just need dummy vp to point to |
9428 | vp_state_ci.pScissors = ≻ | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9429 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
9430 | &gp_ci, NULL, &pipeline); | ||||
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 9431 | ASSERT_VK_SUCCESS(err); |
9432 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9433 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
9434 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); | ||||
Chris Forbes | c08a6ca | 2016-07-28 14:14:07 +1200 | [diff] [blame] | 9435 | VkViewport viewports[1] = {}; // don't care about data |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 9436 | // Count of 2 doesn't match PSO count of 1 |
Chris Forbes | c08a6ca | 2016-07-28 14:14:07 +1200 | [diff] [blame] | 9437 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 1, 1, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 9438 | Draw(1, 0, 0, 0); |
9439 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9440 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9441 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9442 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
9443 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
9444 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
9445 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 9446 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 9447 | } |
9448 | |||||
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 9449 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
9450 | VkResult err; | ||||
9451 | |||||
9452 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 9453 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 9454 | |
9455 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9456 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9457 | |||||
9458 | VkDescriptorPoolSize ds_type_count = {}; | ||||
9459 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
9460 | ds_type_count.descriptorCount = 1; | ||||
9461 | |||||
9462 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
9463 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
9464 | ds_pool_ci.maxSets = 1; | ||||
9465 | ds_pool_ci.poolSizeCount = 1; | ||||
9466 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
9467 | |||||
9468 | VkDescriptorPool ds_pool; | ||||
9469 | err = | ||||
9470 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
9471 | ASSERT_VK_SUCCESS(err); | ||||
9472 | |||||
9473 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
9474 | dsl_binding.binding = 0; | ||||
9475 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
9476 | dsl_binding.descriptorCount = 1; | ||||
9477 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
9478 | |||||
9479 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
9480 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
9481 | ds_layout_ci.bindingCount = 1; | ||||
9482 | ds_layout_ci.pBindings = &dsl_binding; | ||||
9483 | |||||
9484 | VkDescriptorSetLayout ds_layout; | ||||
9485 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
9486 | &ds_layout); | ||||
9487 | ASSERT_VK_SUCCESS(err); | ||||
9488 | |||||
9489 | VkDescriptorSet descriptorSet; | ||||
9490 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
9491 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
9492 | alloc_info.descriptorSetCount = 1; | ||||
9493 | alloc_info.descriptorPool = ds_pool; | ||||
9494 | alloc_info.pSetLayouts = &ds_layout; | ||||
9495 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
9496 | &descriptorSet); | ||||
9497 | ASSERT_VK_SUCCESS(err); | ||||
9498 | |||||
9499 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
9500 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
9501 | pipeline_layout_ci.setLayoutCount = 1; | ||||
9502 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
9503 | |||||
9504 | VkPipelineLayout pipeline_layout; | ||||
9505 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
9506 | &pipeline_layout); | ||||
9507 | ASSERT_VK_SUCCESS(err); | ||||
9508 | |||||
9509 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; | ||||
9510 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; | ||||
9511 | vp_state_ci.scissorCount = 1; | ||||
9512 | vp_state_ci.pScissors = NULL; | ||||
9513 | vp_state_ci.viewportCount = 1; | ||||
9514 | vp_state_ci.pViewports = NULL; | ||||
9515 | |||||
9516 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, | ||||
9517 | VK_DYNAMIC_STATE_SCISSOR, | ||||
9518 | VK_DYNAMIC_STATE_LINE_WIDTH}; | ||||
9519 | // Set scissor as dynamic to avoid that error | ||||
9520 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; | ||||
9521 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; | ||||
9522 | dyn_state_ci.dynamicStateCount = 2; | ||||
9523 | dyn_state_ci.pDynamicStates = dynamic_states; | ||||
9524 | |||||
9525 | VkPipelineShaderStageCreateInfo shaderStages[2]; | ||||
9526 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); | ||||
9527 | |||||
9528 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
9529 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
9530 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
9531 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
9532 | this); // TODO - We shouldn't need a fragment shader | ||||
9533 | // but add it to be able to run on more devices | ||||
9534 | shaderStages[0] = vs.GetStageCreateInfo(); | ||||
9535 | shaderStages[1] = fs.GetStageCreateInfo(); | ||||
9536 | |||||
9537 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; | ||||
9538 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; | ||||
9539 | vi_ci.pNext = nullptr; | ||||
9540 | vi_ci.vertexBindingDescriptionCount = 0; | ||||
9541 | vi_ci.pVertexBindingDescriptions = nullptr; | ||||
9542 | vi_ci.vertexAttributeDescriptionCount = 0; | ||||
9543 | vi_ci.pVertexAttributeDescriptions = nullptr; | ||||
9544 | |||||
9545 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; | ||||
9546 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; | ||||
9547 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; | ||||
9548 | |||||
9549 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; | ||||
9550 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; | ||||
9551 | rs_ci.pNext = nullptr; | ||||
9552 | |||||
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 9553 | // Check too low (line width of -1.0f). |
9554 | rs_ci.lineWidth = -1.0f; | ||||
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 9555 | |
9556 | VkPipelineColorBlendAttachmentState att = {}; | ||||
9557 | att.blendEnable = VK_FALSE; | ||||
9558 | att.colorWriteMask = 0xf; | ||||
9559 | |||||
9560 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; | ||||
9561 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; | ||||
9562 | cb_ci.pNext = nullptr; | ||||
9563 | cb_ci.attachmentCount = 1; | ||||
9564 | cb_ci.pAttachments = &att; | ||||
9565 | |||||
9566 | VkGraphicsPipelineCreateInfo gp_ci = {}; | ||||
9567 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; | ||||
9568 | gp_ci.stageCount = 2; | ||||
9569 | gp_ci.pStages = shaderStages; | ||||
9570 | gp_ci.pVertexInputState = &vi_ci; | ||||
9571 | gp_ci.pInputAssemblyState = &ia_ci; | ||||
9572 | gp_ci.pViewportState = &vp_state_ci; | ||||
9573 | gp_ci.pRasterizationState = &rs_ci; | ||||
9574 | gp_ci.pColorBlendState = &cb_ci; | ||||
9575 | gp_ci.pDynamicState = &dyn_state_ci; | ||||
9576 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; | ||||
9577 | gp_ci.layout = pipeline_layout; | ||||
9578 | gp_ci.renderPass = renderPass(); | ||||
9579 | |||||
9580 | VkPipelineCacheCreateInfo pc_ci = {}; | ||||
9581 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; | ||||
9582 | |||||
9583 | VkPipeline pipeline; | ||||
9584 | VkPipelineCache pipelineCache; | ||||
9585 | |||||
9586 | err = | ||||
9587 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
9588 | ASSERT_VK_SUCCESS(err); | ||||
9589 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
9590 | &gp_ci, NULL, &pipeline); | ||||
9591 | |||||
9592 | m_errorMonitor->VerifyFound(); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 9593 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 9594 | |
9595 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9596 | "Attempt to set lineWidth to 65536"); | ||||
9597 | |||||
9598 | // Check too high (line width of 65536.0f). | ||||
9599 | rs_ci.lineWidth = 65536.0f; | ||||
9600 | |||||
9601 | err = | ||||
9602 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
9603 | ASSERT_VK_SUCCESS(err); | ||||
9604 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
9605 | &gp_ci, NULL, &pipeline); | ||||
9606 | |||||
9607 | m_errorMonitor->VerifyFound(); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 9608 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 9609 | |
9610 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 9611 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 9612 | |
9613 | dyn_state_ci.dynamicStateCount = 3; | ||||
9614 | |||||
9615 | rs_ci.lineWidth = 1.0f; | ||||
9616 | |||||
9617 | err = | ||||
9618 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); | ||||
9619 | ASSERT_VK_SUCCESS(err); | ||||
9620 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, | ||||
9621 | &gp_ci, NULL, &pipeline); | ||||
9622 | BeginCommandBuffer(); | ||||
9623 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
9624 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); | ||||
9625 | |||||
9626 | // Check too low with dynamic setting. | ||||
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 9627 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 9628 | m_errorMonitor->VerifyFound(); |
9629 | |||||
9630 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9631 | "Attempt to set lineWidth to 65536"); | ||||
9632 | |||||
9633 | // Check too high with dynamic setting. | ||||
9634 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); | ||||
9635 | m_errorMonitor->VerifyFound(); | ||||
9636 | EndCommandBuffer(); | ||||
9637 | |||||
9638 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); | ||||
9639 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
9640 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
9641 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 9642 | vkDestroyPipeline(m_device->device(), pipeline, NULL); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 9643 | } |
9644 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9645 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 9646 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9647 | m_errorMonitor->SetDesiredFailureMsg( |
9648 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9649 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 9650 | |
9651 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9652 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 9653 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 9654 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9655 | // Don't care about RenderPass handle b/c error should be flagged before |
9656 | // that | ||||
9657 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, | ||||
9658 | VK_SUBPASS_CONTENTS_INLINE); | ||||
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 9659 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9660 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 9661 | } |
9662 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9663 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 9664 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9665 | m_errorMonitor->SetDesiredFailureMsg( |
9666 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9667 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 9668 | |
9669 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9670 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 9671 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 9672 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9673 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
9674 | // proper error | ||||
Chris Forbes | 38ae7c4 | 2016-06-21 20:51:44 +1200 | [diff] [blame] | 9675 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9676 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 9677 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9678 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 9679 | } |
9680 | |||||
Chris Forbes | 2eeabe3 | 2016-06-21 20:52:34 +1200 | [diff] [blame] | 9681 | TEST_F(VkLayerTest, RenderPassSecondaryCommandBuffersMultipleTimes) { |
9682 | m_errorMonitor->ExpectSuccess(); | ||||
9683 | |||||
9684 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9685 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9686 | |||||
9687 | BeginCommandBuffer(); // framework implicitly begins the renderpass. | ||||
9688 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); // end implicit. | ||||
9689 | |||||
9690 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, | ||||
9691 | VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS); | ||||
9692 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); | ||||
9693 | m_errorMonitor->VerifyNotFound(); | ||||
9694 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &m_renderPassBeginInfo, | ||||
9695 | VK_SUBPASS_CONTENTS_INLINE); | ||||
9696 | m_errorMonitor->VerifyNotFound(); | ||||
9697 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); | ||||
9698 | m_errorMonitor->VerifyNotFound(); | ||||
9699 | |||||
9700 | m_commandBuffer->EndCommandBuffer(); | ||||
9701 | m_errorMonitor->VerifyNotFound(); | ||||
9702 | } | ||||
9703 | |||||
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 9704 | TEST_F(VkLayerTest, RenderPassClearOpMismatch) { |
9705 | TEST_DESCRIPTION("Begin a renderPass where clearValueCount is less than" | ||||
9706 | "the number of renderPass attachments that use loadOp" | ||||
9707 | "VK_ATTACHMENT_LOAD_OP_CLEAR."); | ||||
9708 | |||||
9709 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9710 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9711 | |||||
9712 | // Create a renderPass with a single attachment that uses loadOp CLEAR | ||||
9713 | VkAttachmentReference attach = {}; | ||||
9714 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
9715 | VkSubpassDescription subpass = {}; | ||||
9716 | subpass.inputAttachmentCount = 1; | ||||
9717 | subpass.pInputAttachments = &attach; | ||||
9718 | VkRenderPassCreateInfo rpci = {}; | ||||
9719 | rpci.subpassCount = 1; | ||||
9720 | rpci.pSubpasses = &subpass; | ||||
9721 | rpci.attachmentCount = 1; | ||||
9722 | VkAttachmentDescription attach_desc = {}; | ||||
9723 | attach_desc.format = VK_FORMAT_UNDEFINED; | ||||
9724 | // Set loadOp to CLEAR | ||||
9725 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; | ||||
9726 | rpci.pAttachments = &attach_desc; | ||||
9727 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; | ||||
9728 | VkRenderPass rp; | ||||
9729 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
9730 | |||||
9731 | VkCommandBufferInheritanceInfo hinfo = {}; | ||||
9732 | hinfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; | ||||
9733 | hinfo.renderPass = VK_NULL_HANDLE; | ||||
9734 | hinfo.subpass = 0; | ||||
9735 | hinfo.framebuffer = VK_NULL_HANDLE; | ||||
9736 | hinfo.occlusionQueryEnable = VK_FALSE; | ||||
9737 | hinfo.queryFlags = 0; | ||||
9738 | hinfo.pipelineStatistics = 0; | ||||
9739 | VkCommandBufferBeginInfo info = {}; | ||||
9740 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; | ||||
9741 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
9742 | info.pInheritanceInfo = &hinfo; | ||||
9743 | |||||
9744 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); | ||||
9745 | VkRenderPassBeginInfo rp_begin = {}; | ||||
9746 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; | ||||
9747 | rp_begin.pNext = NULL; | ||||
9748 | rp_begin.renderPass = renderPass(); | ||||
9749 | rp_begin.framebuffer = framebuffer(); | ||||
9750 | rp_begin.clearValueCount = 0; // Should be 1 | ||||
9751 | |||||
9752 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 7f0416c | 2016-07-15 16:01:13 -0600 | [diff] [blame] | 9753 | " has a clearValueCount of 0 but " |
9754 | "there must be at least 1 entries in " | ||||
9755 | "pClearValues array to account for "); | ||||
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 9756 | |
9757 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, | ||||
9758 | VK_SUBPASS_CONTENTS_INLINE); | ||||
9759 | |||||
9760 | m_errorMonitor->VerifyFound(); | ||||
Mark Lobodzinski | 5c70ebd | 2016-06-09 13:45:00 -0600 | [diff] [blame] | 9761 | |
9762 | vkDestroyRenderPass(m_device->device(), rp, NULL); | ||||
Tobin Ehlis | 5a1c033 | 2016-05-31 13:59:26 -0600 | [diff] [blame] | 9763 | } |
9764 | |||||
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 9765 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
9766 | |||||
9767 | TEST_DESCRIPTION("End a command buffer with an active render pass"); | ||||
9768 | |||||
9769 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9770 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9771 | "It is invalid to issue this call inside an active render pass"); | ||||
9772 | |||||
9773 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9774 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9775 | |||||
9776 | // The framework's BeginCommandBuffer calls CreateRenderPass | ||||
9777 | BeginCommandBuffer(); | ||||
9778 | |||||
9779 | // Call directly into vkEndCommandBuffer instead of the | ||||
9780 | // the framework's EndCommandBuffer, which inserts a | ||||
9781 | // vkEndRenderPass | ||||
9782 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); | ||||
9783 | |||||
9784 | m_errorMonitor->VerifyFound(); | ||||
9785 | |||||
9786 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY | ||||
9787 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT | ||||
9788 | } | ||||
9789 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9790 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9791 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9792 | m_errorMonitor->SetDesiredFailureMsg( |
9793 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9794 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9795 | |
9796 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9797 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9798 | |
9799 | // Renderpass is started here | ||||
9800 | BeginCommandBuffer(); | ||||
9801 | |||||
9802 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9803 | vk_testing::Buffer dstBuffer; |
9804 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9805 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9806 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9807 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9808 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9809 | } |
9810 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9811 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9812 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9813 | m_errorMonitor->SetDesiredFailureMsg( |
9814 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9815 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9816 | |
9817 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9818 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9819 | |
9820 | // Renderpass is started here | ||||
9821 | BeginCommandBuffer(); | ||||
9822 | |||||
9823 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9824 | vk_testing::Buffer dstBuffer; |
9825 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9826 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9827 | VkDeviceSize dstOffset = 0; |
9828 | VkDeviceSize dataSize = 1024; | ||||
Karl Schultz | ee34449 | 2016-07-11 15:09:57 -0600 | [diff] [blame] | 9829 | const void *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9830 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9831 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
9832 | dstOffset, dataSize, pData); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9833 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9834 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9835 | } |
9836 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9837 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9838 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9839 | m_errorMonitor->SetDesiredFailureMsg( |
9840 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9841 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9842 | |
9843 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9844 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9845 | |
9846 | // Renderpass is started here | ||||
9847 | BeginCommandBuffer(); | ||||
9848 | |||||
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 9849 | VkClearColorValue clear_color; |
9850 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9851 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
9852 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
9853 | const int32_t tex_width = 32; | ||||
9854 | const int32_t tex_height = 32; | ||||
9855 | VkImageCreateInfo image_create_info = {}; | ||||
9856 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
9857 | image_create_info.pNext = NULL; | ||||
9858 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
9859 | image_create_info.format = tex_format; | ||||
9860 | image_create_info.extent.width = tex_width; | ||||
9861 | image_create_info.extent.height = tex_height; | ||||
9862 | image_create_info.extent.depth = 1; | ||||
9863 | image_create_info.mipLevels = 1; | ||||
9864 | image_create_info.arrayLayers = 1; | ||||
9865 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
9866 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
9867 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9868 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9869 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9870 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
9871 | reqs); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9872 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9873 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
9874 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9875 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9876 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
9877 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9878 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9879 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9880 | } |
9881 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9882 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9883 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9884 | m_errorMonitor->SetDesiredFailureMsg( |
9885 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9886 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9887 | |
9888 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9889 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9890 | |
9891 | // Renderpass is started here | ||||
9892 | BeginCommandBuffer(); | ||||
9893 | |||||
9894 | VkClearDepthStencilValue clear_value = {0}; | ||||
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 9895 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9896 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
9897 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
9898 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
9899 | image_create_info.extent.width = 64; | ||||
9900 | image_create_info.extent.height = 64; | ||||
9901 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
9902 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9903 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9904 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9905 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
9906 | reqs); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9907 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9908 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
9909 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9910 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9911 | vkCmdClearDepthStencilImage( |
9912 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), | ||||
9913 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, | ||||
9914 | &range); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9915 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9916 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9917 | } |
9918 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9919 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 9920 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9921 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9922 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9923 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 0dcf272 | 2016-07-14 09:54:11 -0600 | [diff] [blame] | 9924 | "vkCmdClearAttachments(): This call " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9925 | "must be issued inside an active " |
9926 | "render pass"); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9927 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9928 | ASSERT_NO_FATAL_FAILURE(InitState()); |
9929 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9930 | |
9931 | // Start no RenderPass | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9932 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9933 | ASSERT_VK_SUCCESS(err); |
9934 | |||||
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 9935 | VkClearAttachment color_attachment; |
9936 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
9937 | color_attachment.clearValue.color.float32[0] = 0; | ||||
9938 | color_attachment.clearValue.color.float32[1] = 0; | ||||
9939 | color_attachment.clearValue.color.float32[2] = 0; | ||||
9940 | color_attachment.clearValue.color.float32[3] = 0; | ||||
9941 | color_attachment.colorAttachment = 0; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9942 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
9943 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, | ||||
9944 | &color_attachment, 1, &clear_rect); | ||||
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9945 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9946 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 9947 | } |
9948 | |||||
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 9949 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
9950 | // Try to add a buffer memory barrier with no buffer. | ||||
9951 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9952 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9953 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); | ||||
9954 | |||||
9955 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9956 | BeginCommandBuffer(); | ||||
9957 | |||||
9958 | VkBufferMemoryBarrier buf_barrier = {}; | ||||
9959 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; | ||||
9960 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
9961 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
9962 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
9963 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
9964 | buf_barrier.buffer = VK_NULL_HANDLE; | ||||
9965 | buf_barrier.offset = 0; | ||||
9966 | buf_barrier.size = VK_WHOLE_SIZE; | ||||
9967 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
9968 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, | ||||
9969 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); | ||||
9970 | |||||
9971 | m_errorMonitor->VerifyFound(); | ||||
9972 | } | ||||
9973 | |||||
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 9974 | TEST_F(VkLayerTest, InvalidBarriers) { |
9975 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); | ||||
9976 | |||||
9977 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9978 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); | ||||
9979 | |||||
9980 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
9981 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
9982 | |||||
9983 | VkMemoryBarrier mem_barrier = {}; | ||||
9984 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; | ||||
9985 | mem_barrier.pNext = NULL; | ||||
9986 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
9987 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
9988 | BeginCommandBuffer(); | ||||
9989 | // BeginCommandBuffer() starts a render pass | ||||
9990 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
9991 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
9992 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, | ||||
9993 | &mem_barrier, 0, nullptr, 0, nullptr); | ||||
9994 | m_errorMonitor->VerifyFound(); | ||||
9995 | |||||
9996 | m_errorMonitor->SetDesiredFailureMsg( | ||||
9997 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
9998 | "Image Layout cannot be transitioned to UNDEFINED"); | ||||
9999 | VkImageObj image(m_device); | ||||
10000 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
10001 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); | ||||
10002 | ASSERT_TRUE(image.initialized()); | ||||
10003 | VkImageMemoryBarrier img_barrier = {}; | ||||
10004 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; | ||||
10005 | img_barrier.pNext = NULL; | ||||
10006 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
10007 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
10008 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
10009 | // New layout can't be UNDEFINED | ||||
10010 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; | ||||
10011 | img_barrier.image = image.handle(); | ||||
10012 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
10013 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
10014 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
10015 | img_barrier.subresourceRange.baseArrayLayer = 0; | ||||
10016 | img_barrier.subresourceRange.baseMipLevel = 0; | ||||
10017 | img_barrier.subresourceRange.layerCount = 1; | ||||
10018 | img_barrier.subresourceRange.levelCount = 1; | ||||
10019 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
10020 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
10021 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
10022 | nullptr, 1, &img_barrier); | ||||
10023 | m_errorMonitor->VerifyFound(); | ||||
10024 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
10025 | |||||
10026 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10027 | "Subresource must have the sum of the " | ||||
10028 | "baseArrayLayer"); | ||||
10029 | // baseArrayLayer + layerCount must be <= image's arrayLayers | ||||
10030 | img_barrier.subresourceRange.baseArrayLayer = 1; | ||||
10031 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
10032 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
10033 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
10034 | nullptr, 1, &img_barrier); | ||||
10035 | m_errorMonitor->VerifyFound(); | ||||
10036 | img_barrier.subresourceRange.baseArrayLayer = 0; | ||||
10037 | |||||
10038 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10039 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10040 | "Subresource must have the sum of the baseMipLevel"); | ||||
10041 | // baseMipLevel + levelCount must be <= image's mipLevels | ||||
10042 | img_barrier.subresourceRange.baseMipLevel = 1; | ||||
10043 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
10044 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
10045 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
10046 | nullptr, 1, &img_barrier); | ||||
10047 | m_errorMonitor->VerifyFound(); | ||||
10048 | img_barrier.subresourceRange.baseMipLevel = 0; | ||||
10049 | |||||
10050 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10051 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10052 | "Buffer Barriers cannot be used during a render pass"); | ||||
10053 | vk_testing::Buffer buffer; | ||||
10054 | buffer.init(*m_device, 256); | ||||
10055 | VkBufferMemoryBarrier buf_barrier = {}; | ||||
10056 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; | ||||
10057 | buf_barrier.pNext = NULL; | ||||
10058 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
10059 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
10060 | buf_barrier.buffer = buffer.handle(); | ||||
10061 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
10062 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
10063 | buf_barrier.offset = 0; | ||||
10064 | buf_barrier.size = VK_WHOLE_SIZE; | ||||
10065 | // Can't send buffer barrier during a render pass | ||||
10066 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
10067 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
10068 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, | ||||
10069 | &buf_barrier, 0, nullptr); | ||||
10070 | m_errorMonitor->VerifyFound(); | ||||
10071 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); | ||||
10072 | |||||
10073 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10074 | "which is not less than total size"); | ||||
10075 | buf_barrier.offset = 257; | ||||
10076 | // Offset greater than total size | ||||
10077 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
10078 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
10079 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, | ||||
10080 | &buf_barrier, 0, nullptr); | ||||
10081 | m_errorMonitor->VerifyFound(); | ||||
10082 | buf_barrier.offset = 0; | ||||
10083 | |||||
10084 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10085 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); | ||||
10086 | buf_barrier.size = 257; | ||||
10087 | // Size greater than total size | ||||
10088 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
10089 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
10090 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, | ||||
10091 | &buf_barrier, 0, nullptr); | ||||
10092 | m_errorMonitor->VerifyFound(); | ||||
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 10093 | |
Tobin Ehlis | 17b2e7b | 2016-07-21 09:43:29 -0600 | [diff] [blame] | 10094 | // Now exercise barrier aspect bit errors, first DS |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 10095 | m_errorMonitor->SetDesiredFailureMsg( |
10096 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10097 | "Image is a depth and stencil format and thus must " | ||||
Tobin Ehlis | 17b2e7b | 2016-07-21 09:43:29 -0600 | [diff] [blame] | 10098 | "have either one or both of VK_IMAGE_ASPECT_DEPTH_BIT and " |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 10099 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
10100 | VkDepthStencilObj ds_image(m_device); | ||||
10101 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); | ||||
10102 | ASSERT_TRUE(ds_image.initialized()); | ||||
Tobin Ehlis | 15684a0 | 2016-07-21 14:55:26 -0600 | [diff] [blame] | 10103 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
10104 | img_barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL; | ||||
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 10105 | img_barrier.image = ds_image.handle(); |
Tobin Ehlis | 15684a0 | 2016-07-21 14:55:26 -0600 | [diff] [blame] | 10106 | // Use of COLOR aspect on DS image is error |
10107 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 10108 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
10109 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
10110 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
10111 | nullptr, 1, &img_barrier); | ||||
10112 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 17b2e7b | 2016-07-21 09:43:29 -0600 | [diff] [blame] | 10113 | // Now test depth-only |
10114 | VkFormatProperties format_props; | ||||
10115 | |||||
10116 | vkGetPhysicalDeviceFormatProperties(m_device->phy().handle(), | ||||
10117 | VK_FORMAT_D16_UNORM, &format_props); | ||||
10118 | if (format_props.optimalTilingFeatures & | ||||
10119 | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { | ||||
10120 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10121 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10122 | "Image is a depth-only format and thus must " | ||||
10123 | "have VK_IMAGE_ASPECT_DEPTH_BIT set."); | ||||
10124 | VkDepthStencilObj d_image(m_device); | ||||
10125 | d_image.Init(m_device, 128, 128, VK_FORMAT_D16_UNORM); | ||||
10126 | ASSERT_TRUE(d_image.initialized()); | ||||
Tobin Ehlis | 15684a0 | 2016-07-21 14:55:26 -0600 | [diff] [blame] | 10127 | img_barrier.oldLayout = |
Tobin Ehlis | 17b2e7b | 2016-07-21 09:43:29 -0600 | [diff] [blame] | 10128 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
Tobin Ehlis | 15684a0 | 2016-07-21 14:55:26 -0600 | [diff] [blame] | 10129 | img_barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL; |
Tobin Ehlis | 17b2e7b | 2016-07-21 09:43:29 -0600 | [diff] [blame] | 10130 | img_barrier.image = d_image.handle(); |
Tobin Ehlis | 15684a0 | 2016-07-21 14:55:26 -0600 | [diff] [blame] | 10131 | // Use of COLOR aspect on depth image is error |
10132 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | 17b2e7b | 2016-07-21 09:43:29 -0600 | [diff] [blame] | 10133 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
10134 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
10135 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, | ||||
10136 | 0, nullptr, 1, &img_barrier); | ||||
10137 | m_errorMonitor->VerifyFound(); | ||||
10138 | } | ||||
10139 | vkGetPhysicalDeviceFormatProperties(m_device->phy().handle(), | ||||
10140 | VK_FORMAT_S8_UINT, &format_props); | ||||
10141 | if (format_props.optimalTilingFeatures & | ||||
10142 | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) { | ||||
10143 | // Now test stencil-only | ||||
10144 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10145 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10146 | "Image is a stencil-only format and thus must " | ||||
10147 | "have VK_IMAGE_ASPECT_STENCIL_BIT set."); | ||||
10148 | VkDepthStencilObj s_image(m_device); | ||||
10149 | s_image.Init(m_device, 128, 128, VK_FORMAT_S8_UINT); | ||||
10150 | ASSERT_TRUE(s_image.initialized()); | ||||
Tobin Ehlis | 15684a0 | 2016-07-21 14:55:26 -0600 | [diff] [blame] | 10151 | img_barrier.oldLayout = |
Tobin Ehlis | 17b2e7b | 2016-07-21 09:43:29 -0600 | [diff] [blame] | 10152 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
Tobin Ehlis | 15684a0 | 2016-07-21 14:55:26 -0600 | [diff] [blame] | 10153 | img_barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL; |
Tobin Ehlis | 17b2e7b | 2016-07-21 09:43:29 -0600 | [diff] [blame] | 10154 | img_barrier.image = s_image.handle(); |
Tobin Ehlis | 15684a0 | 2016-07-21 14:55:26 -0600 | [diff] [blame] | 10155 | // Use of COLOR aspect on depth image is error |
10156 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | 17b2e7b | 2016-07-21 09:43:29 -0600 | [diff] [blame] | 10157 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
10158 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
10159 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, | ||||
10160 | 0, nullptr, 1, &img_barrier); | ||||
10161 | m_errorMonitor->VerifyFound(); | ||||
10162 | } | ||||
10163 | // Finally test color | ||||
10164 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10165 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Image is a color format and thus must " | ||||
10166 | "have VK_IMAGE_ASPECT_COLOR_BIT set."); | ||||
10167 | VkImageObj c_image(m_device); | ||||
10168 | c_image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
10169 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, | ||||
10170 | 0); | ||||
10171 | ASSERT_TRUE(c_image.initialized()); | ||||
10172 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
10173 | img_barrier.newLayout = VK_IMAGE_LAYOUT_GENERAL; | ||||
10174 | img_barrier.image = c_image.handle(); | ||||
10175 | // Set aspect to depth (non-color) | ||||
10176 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; | ||||
10177 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
10178 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
10179 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
10180 | nullptr, 1, &img_barrier); | ||||
10181 | m_errorMonitor->VerifyFound(); | ||||
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 10182 | } |
10183 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10184 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 10185 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10186 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 10187 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10188 | m_errorMonitor->SetDesiredFailureMsg( |
10189 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10190 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
10191 | |||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 10192 | ASSERT_NO_FATAL_FAILURE(InitState()); |
10193 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 10194 | uint32_t qfi = 0; |
10195 | VkBufferCreateInfo buffCI = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10196 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
10197 | buffCI.size = 1024; | ||||
10198 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; | ||||
10199 | buffCI.queueFamilyIndexCount = 1; | ||||
10200 | buffCI.pQueueFamilyIndices = &qfi; | ||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 10201 | |
10202 | VkBuffer ib; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10203 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 10204 | ASSERT_VK_SUCCESS(err); |
10205 | |||||
10206 | BeginCommandBuffer(); | ||||
10207 | ASSERT_VK_SUCCESS(err); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10208 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
10209 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 10210 | // 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] | 10211 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
10212 | VK_INDEX_TYPE_UINT16); | ||||
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 10213 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10214 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 10215 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10216 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 10217 | } |
10218 | |||||
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 10219 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
10220 | // Create an out-of-range queueFamilyIndex | ||||
10221 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10222 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 10223 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
10224 | "of the indices specified when the device was created, via the " | ||||
10225 | "VkDeviceQueueCreateInfo structure."); | ||||
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 10226 | |
10227 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10228 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
10229 | VkBufferCreateInfo buffCI = {}; | ||||
10230 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
10231 | buffCI.size = 1024; | ||||
10232 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; | ||||
10233 | buffCI.queueFamilyIndexCount = 1; | ||||
10234 | // Introduce failure by specifying invalid queue_family_index | ||||
10235 | uint32_t qfi = 777; | ||||
10236 | buffCI.pQueueFamilyIndices = &qfi; | ||||
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 10237 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 10238 | |
10239 | VkBuffer ib; | ||||
10240 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); | ||||
10241 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10242 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 10243 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 10244 | } |
10245 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10246 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
10247 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be | ||||
10248 | // secondary) | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10249 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10250 | m_errorMonitor->SetDesiredFailureMsg( |
10251 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10252 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 10253 | |
10254 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10255 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 10256 | |
10257 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10258 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10259 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
10260 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); | ||||
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 10261 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10262 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 10263 | } |
10264 | |||||
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 10265 | TEST_F(VkLayerTest, DSUsageBitsErrors) { |
10266 | TEST_DESCRIPTION("Attempt to update descriptor sets for images and buffers " | ||||
10267 | "that do not have correct usage bits sets."); | ||||
10268 | VkResult err; | ||||
10269 | |||||
10270 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10271 | VkDescriptorPoolSize ds_type_count[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; | ||||
10272 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { | ||||
10273 | ds_type_count[i].type = VkDescriptorType(i); | ||||
10274 | ds_type_count[i].descriptorCount = 1; | ||||
10275 | } | ||||
10276 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
10277 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
10278 | ds_pool_ci.pNext = NULL; | ||||
10279 | ds_pool_ci.maxSets = VK_DESCRIPTOR_TYPE_RANGE_SIZE; | ||||
10280 | ds_pool_ci.poolSizeCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; | ||||
10281 | ds_pool_ci.pPoolSizes = ds_type_count; | ||||
10282 | |||||
10283 | VkDescriptorPool ds_pool; | ||||
10284 | err = | ||||
10285 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
10286 | ASSERT_VK_SUCCESS(err); | ||||
10287 | |||||
10288 | // Create 10 layouts where each has a single descriptor of different type | ||||
10289 | VkDescriptorSetLayoutBinding dsl_binding[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = | ||||
10290 | {}; | ||||
10291 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { | ||||
10292 | dsl_binding[i].binding = 0; | ||||
10293 | dsl_binding[i].descriptorType = VkDescriptorType(i); | ||||
10294 | dsl_binding[i].descriptorCount = 1; | ||||
10295 | dsl_binding[i].stageFlags = VK_SHADER_STAGE_ALL; | ||||
10296 | dsl_binding[i].pImmutableSamplers = NULL; | ||||
10297 | } | ||||
10298 | |||||
10299 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
10300 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
10301 | ds_layout_ci.pNext = NULL; | ||||
10302 | ds_layout_ci.bindingCount = 1; | ||||
10303 | VkDescriptorSetLayout ds_layouts[VK_DESCRIPTOR_TYPE_RANGE_SIZE]; | ||||
10304 | for (uint32_t i = 0; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { | ||||
10305 | ds_layout_ci.pBindings = dsl_binding + i; | ||||
10306 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, | ||||
10307 | NULL, ds_layouts + i); | ||||
10308 | ASSERT_VK_SUCCESS(err); | ||||
10309 | } | ||||
10310 | VkDescriptorSet descriptor_sets[VK_DESCRIPTOR_TYPE_RANGE_SIZE] = {}; | ||||
10311 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
10312 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
10313 | alloc_info.descriptorSetCount = VK_DESCRIPTOR_TYPE_RANGE_SIZE; | ||||
10314 | alloc_info.descriptorPool = ds_pool; | ||||
10315 | alloc_info.pSetLayouts = ds_layouts; | ||||
10316 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
10317 | descriptor_sets); | ||||
10318 | ASSERT_VK_SUCCESS(err); | ||||
10319 | |||||
10320 | // Create a buffer & bufferView to be used for invalid updates | ||||
10321 | VkBufferCreateInfo buff_ci = {}; | ||||
10322 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
10323 | // This usage is not valid for any descriptor type | ||||
10324 | buff_ci.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; | ||||
10325 | buff_ci.size = 256; | ||||
10326 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
10327 | VkBuffer buffer; | ||||
10328 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); | ||||
10329 | ASSERT_VK_SUCCESS(err); | ||||
10330 | |||||
10331 | VkBufferViewCreateInfo buff_view_ci = {}; | ||||
10332 | buff_view_ci.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO; | ||||
10333 | buff_view_ci.buffer = buffer; | ||||
10334 | buff_view_ci.format = VK_FORMAT_R8_UNORM; | ||||
10335 | buff_view_ci.range = VK_WHOLE_SIZE; | ||||
10336 | VkBufferView buff_view; | ||||
10337 | err = | ||||
10338 | vkCreateBufferView(m_device->device(), &buff_view_ci, NULL, &buff_view); | ||||
10339 | ASSERT_VK_SUCCESS(err); | ||||
10340 | |||||
10341 | // Create an image to be used for invalid updates | ||||
10342 | VkImageCreateInfo image_ci = {}; | ||||
10343 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
10344 | image_ci.imageType = VK_IMAGE_TYPE_2D; | ||||
10345 | image_ci.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
10346 | image_ci.extent.width = 64; | ||||
10347 | image_ci.extent.height = 64; | ||||
10348 | image_ci.extent.depth = 1; | ||||
10349 | image_ci.mipLevels = 1; | ||||
10350 | image_ci.arrayLayers = 1; | ||||
10351 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
10352 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; | ||||
10353 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | ||||
10354 | // This usage is not valid for any descriptor type | ||||
10355 | image_ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
10356 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
10357 | VkImage image; | ||||
10358 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); | ||||
10359 | ASSERT_VK_SUCCESS(err); | ||||
10360 | // Bind memory to image | ||||
10361 | VkMemoryRequirements mem_reqs; | ||||
10362 | VkDeviceMemory image_mem; | ||||
10363 | bool pass; | ||||
10364 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
10365 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
10366 | mem_alloc.pNext = NULL; | ||||
10367 | mem_alloc.allocationSize = 0; | ||||
10368 | mem_alloc.memoryTypeIndex = 0; | ||||
10369 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
10370 | mem_alloc.allocationSize = mem_reqs.size; | ||||
10371 | pass = | ||||
10372 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
10373 | ASSERT_TRUE(pass); | ||||
10374 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); | ||||
10375 | ASSERT_VK_SUCCESS(err); | ||||
10376 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); | ||||
10377 | ASSERT_VK_SUCCESS(err); | ||||
10378 | // Now create view for image | ||||
10379 | VkImageViewCreateInfo image_view_ci = {}; | ||||
10380 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
10381 | image_view_ci.image = image; | ||||
10382 | image_view_ci.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
10383 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
10384 | image_view_ci.subresourceRange.layerCount = 1; | ||||
10385 | image_view_ci.subresourceRange.baseArrayLayer = 0; | ||||
10386 | image_view_ci.subresourceRange.levelCount = 1; | ||||
10387 | image_view_ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
10388 | VkImageView image_view; | ||||
10389 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, | ||||
10390 | &image_view); | ||||
10391 | ASSERT_VK_SUCCESS(err); | ||||
10392 | |||||
10393 | VkDescriptorBufferInfo buff_info = {}; | ||||
10394 | buff_info.buffer = buffer; | ||||
10395 | VkDescriptorImageInfo img_info = {}; | ||||
10396 | img_info.imageView = image_view; | ||||
10397 | VkWriteDescriptorSet descriptor_write = {}; | ||||
10398 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
10399 | descriptor_write.dstBinding = 0; | ||||
10400 | descriptor_write.descriptorCount = 1; | ||||
10401 | descriptor_write.pTexelBufferView = &buff_view; | ||||
10402 | descriptor_write.pBufferInfo = &buff_info; | ||||
10403 | descriptor_write.pImageInfo = &img_info; | ||||
10404 | |||||
10405 | // These error messages align with VkDescriptorType struct | ||||
10406 | const char *error_msgs[] = { | ||||
10407 | "", // placeholder, no error for SAMPLER descriptor | ||||
10408 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", | ||||
10409 | " does not have VK_IMAGE_USAGE_SAMPLED_BIT set.", | ||||
10410 | " does not have VK_IMAGE_USAGE_STORAGE_BIT set.", | ||||
10411 | " does not have VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT set.", | ||||
10412 | " does not have VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT set.", | ||||
10413 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", | ||||
10414 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", | ||||
10415 | " does not have VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT set.", | ||||
10416 | " does not have VK_BUFFER_USAGE_STORAGE_BUFFER_BIT set.", | ||||
10417 | " does not have VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT set."}; | ||||
10418 | // Start loop at 1 as SAMPLER desc type has no usage bit error | ||||
10419 | for (uint32_t i = 1; i < VK_DESCRIPTOR_TYPE_RANGE_SIZE; ++i) { | ||||
10420 | descriptor_write.descriptorType = VkDescriptorType(i); | ||||
10421 | descriptor_write.dstSet = descriptor_sets[i]; | ||||
10422 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10423 | error_msgs[i]); | ||||
10424 | |||||
10425 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, | ||||
10426 | NULL); | ||||
10427 | |||||
10428 | m_errorMonitor->VerifyFound(); | ||||
10429 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[i], NULL); | ||||
10430 | } | ||||
10431 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layouts[0], NULL); | ||||
10432 | vkDestroyImage(m_device->device(), image, NULL); | ||||
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 10433 | vkFreeMemory(m_device->device(), image_mem, NULL); |
Tobin Ehlis | 17826bd | 2016-05-25 11:12:50 -0600 | [diff] [blame] | 10434 | vkDestroyImageView(m_device->device(), image_view, NULL); |
10435 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
10436 | vkDestroyBufferView(m_device->device(), buff_view, NULL); | ||||
10437 | vkFreeDescriptorSets(m_device->device(), ds_pool, | ||||
10438 | VK_DESCRIPTOR_TYPE_RANGE_SIZE, descriptor_sets); | ||||
10439 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
10440 | } | ||||
10441 | |||||
Tobin Ehlis | 585f66d | 2016-07-01 18:23:58 -0600 | [diff] [blame] | 10442 | TEST_F(VkLayerTest, DSBufferInfoErrors) { |
10443 | TEST_DESCRIPTION( | ||||
10444 | "Attempt to update buffer descriptor set that has incorrect " | ||||
10445 | "parameters in VkDescriptorBufferInfo struct. This includes:\n" | ||||
10446 | "1. offset value greater than buffer size\n" | ||||
10447 | "2. range value of 0\n" | ||||
10448 | "3. range value greater than buffer (size - offset)"); | ||||
10449 | VkResult err; | ||||
10450 | |||||
10451 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10452 | VkDescriptorPoolSize ds_type_count = {}; | ||||
10453 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10454 | ds_type_count.descriptorCount = 1; | ||||
10455 | |||||
10456 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
10457 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
10458 | ds_pool_ci.pNext = NULL; | ||||
10459 | ds_pool_ci.maxSets = 1; | ||||
10460 | ds_pool_ci.poolSizeCount = 1; | ||||
10461 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
10462 | |||||
10463 | VkDescriptorPool ds_pool; | ||||
10464 | err = | ||||
10465 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
10466 | ASSERT_VK_SUCCESS(err); | ||||
10467 | |||||
10468 | // Create layout with single uniform buffer descriptor | ||||
10469 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
10470 | dsl_binding.binding = 0; | ||||
10471 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10472 | dsl_binding.descriptorCount = 1; | ||||
10473 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10474 | dsl_binding.pImmutableSamplers = NULL; | ||||
10475 | |||||
10476 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
10477 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
10478 | ds_layout_ci.pNext = NULL; | ||||
10479 | ds_layout_ci.bindingCount = 1; | ||||
10480 | ds_layout_ci.pBindings = &dsl_binding; | ||||
10481 | VkDescriptorSetLayout ds_layout; | ||||
10482 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
10483 | &ds_layout); | ||||
10484 | ASSERT_VK_SUCCESS(err); | ||||
10485 | |||||
10486 | VkDescriptorSet descriptor_set = {}; | ||||
10487 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
10488 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
10489 | alloc_info.descriptorSetCount = 1; | ||||
10490 | alloc_info.descriptorPool = ds_pool; | ||||
10491 | alloc_info.pSetLayouts = &ds_layout; | ||||
10492 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
10493 | &descriptor_set); | ||||
10494 | ASSERT_VK_SUCCESS(err); | ||||
10495 | |||||
10496 | // Create a buffer to be used for invalid updates | ||||
10497 | VkBufferCreateInfo buff_ci = {}; | ||||
10498 | buff_ci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; | ||||
10499 | buff_ci.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; | ||||
10500 | buff_ci.size = 256; | ||||
10501 | buff_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
10502 | VkBuffer buffer; | ||||
10503 | err = vkCreateBuffer(m_device->device(), &buff_ci, NULL, &buffer); | ||||
10504 | ASSERT_VK_SUCCESS(err); | ||||
10505 | // Have to bind memory to buffer before descriptor update | ||||
10506 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
10507 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
10508 | mem_alloc.pNext = NULL; | ||||
10509 | mem_alloc.allocationSize = 256; | ||||
10510 | mem_alloc.memoryTypeIndex = 0; | ||||
10511 | |||||
10512 | VkMemoryRequirements mem_reqs; | ||||
10513 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); | ||||
10514 | bool pass = | ||||
10515 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
10516 | if (!pass) { | ||||
10517 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
10518 | return; | ||||
10519 | } | ||||
10520 | |||||
10521 | VkDeviceMemory mem; | ||||
10522 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); | ||||
10523 | ASSERT_VK_SUCCESS(err); | ||||
10524 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); | ||||
10525 | ASSERT_VK_SUCCESS(err); | ||||
10526 | |||||
10527 | VkDescriptorBufferInfo buff_info = {}; | ||||
10528 | buff_info.buffer = buffer; | ||||
10529 | // First make offset 1 larger than buffer size | ||||
10530 | buff_info.offset = 257; | ||||
10531 | buff_info.range = VK_WHOLE_SIZE; | ||||
10532 | VkWriteDescriptorSet descriptor_write = {}; | ||||
10533 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
10534 | descriptor_write.dstBinding = 0; | ||||
10535 | descriptor_write.descriptorCount = 1; | ||||
10536 | descriptor_write.pTexelBufferView = nullptr; | ||||
10537 | descriptor_write.pBufferInfo = &buff_info; | ||||
10538 | descriptor_write.pImageInfo = nullptr; | ||||
10539 | |||||
10540 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10541 | descriptor_write.dstSet = descriptor_set; | ||||
10542 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10543 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10544 | " offset of 257 is greater than buffer "); | ||||
10545 | |||||
10546 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10547 | |||||
10548 | m_errorMonitor->VerifyFound(); | ||||
10549 | // Now cause error due to range of 0 | ||||
10550 | buff_info.offset = 0; | ||||
10551 | buff_info.range = 0; | ||||
10552 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10553 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10554 | " range is not VK_WHOLE_SIZE and is zero, which is not allowed."); | ||||
10555 | |||||
10556 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10557 | |||||
10558 | m_errorMonitor->VerifyFound(); | ||||
10559 | // Now cause error due to range exceeding buffer size - offset | ||||
10560 | buff_info.offset = 128; | ||||
10561 | buff_info.range = 200; | ||||
10562 | m_errorMonitor->SetDesiredFailureMsg( | ||||
10563 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10564 | " range is 200 which is greater than buffer size "); | ||||
10565 | |||||
10566 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10567 | |||||
10568 | m_errorMonitor->VerifyFound(); | ||||
Mark Lobodzinski | 4bb5409 | 2016-07-06 14:27:19 -0600 | [diff] [blame] | 10569 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 585f66d | 2016-07-01 18:23:58 -0600 | [diff] [blame] | 10570 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
10571 | vkDestroyBuffer(m_device->device(), buffer, NULL); | ||||
10572 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set); | ||||
10573 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
10574 | } | ||||
10575 | |||||
Tobin Ehlis | 2fc296b | 2016-06-15 14:05:27 -0600 | [diff] [blame] | 10576 | TEST_F(VkLayerTest, DSAspectBitsErrors) { |
10577 | // TODO : Initially only catching case where DEPTH & STENCIL aspect bits | ||||
10578 | // are set, but could expand this test to hit more cases. | ||||
10579 | TEST_DESCRIPTION("Attempt to update descriptor sets for images " | ||||
10580 | "that do not have correct aspect bits sets."); | ||||
10581 | VkResult err; | ||||
10582 | |||||
10583 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
10584 | VkDescriptorPoolSize ds_type_count = {}; | ||||
10585 | ds_type_count.type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; | ||||
10586 | ds_type_count.descriptorCount = 1; | ||||
10587 | |||||
10588 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
10589 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
10590 | ds_pool_ci.pNext = NULL; | ||||
10591 | ds_pool_ci.maxSets = 5; | ||||
10592 | ds_pool_ci.poolSizeCount = 1; | ||||
10593 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
10594 | |||||
10595 | VkDescriptorPool ds_pool; | ||||
10596 | err = | ||||
10597 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
10598 | ASSERT_VK_SUCCESS(err); | ||||
10599 | |||||
10600 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
10601 | dsl_binding.binding = 0; | ||||
10602 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; | ||||
10603 | dsl_binding.descriptorCount = 1; | ||||
10604 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10605 | dsl_binding.pImmutableSamplers = NULL; | ||||
10606 | |||||
10607 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
10608 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
10609 | ds_layout_ci.pNext = NULL; | ||||
10610 | ds_layout_ci.bindingCount = 1; | ||||
10611 | ds_layout_ci.pBindings = &dsl_binding; | ||||
10612 | VkDescriptorSetLayout ds_layout; | ||||
10613 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
10614 | &ds_layout); | ||||
10615 | ASSERT_VK_SUCCESS(err); | ||||
10616 | |||||
10617 | VkDescriptorSet descriptor_set = {}; | ||||
10618 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
10619 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
10620 | alloc_info.descriptorSetCount = 1; | ||||
10621 | alloc_info.descriptorPool = ds_pool; | ||||
10622 | alloc_info.pSetLayouts = &ds_layout; | ||||
10623 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
10624 | &descriptor_set); | ||||
10625 | ASSERT_VK_SUCCESS(err); | ||||
10626 | |||||
10627 | // Create an image to be used for invalid updates | ||||
10628 | VkImageCreateInfo image_ci = {}; | ||||
10629 | image_ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
10630 | image_ci.imageType = VK_IMAGE_TYPE_2D; | ||||
10631 | image_ci.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
10632 | image_ci.extent.width = 64; | ||||
10633 | image_ci.extent.height = 64; | ||||
10634 | image_ci.extent.depth = 1; | ||||
10635 | image_ci.mipLevels = 1; | ||||
10636 | image_ci.arrayLayers = 1; | ||||
10637 | image_ci.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
10638 | image_ci.tiling = VK_IMAGE_TILING_LINEAR; | ||||
10639 | image_ci.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; | ||||
10640 | image_ci.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
10641 | image_ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE; | ||||
10642 | VkImage image; | ||||
10643 | err = vkCreateImage(m_device->device(), &image_ci, NULL, &image); | ||||
10644 | ASSERT_VK_SUCCESS(err); | ||||
10645 | // Bind memory to image | ||||
10646 | VkMemoryRequirements mem_reqs; | ||||
10647 | VkDeviceMemory image_mem; | ||||
10648 | bool pass; | ||||
10649 | VkMemoryAllocateInfo mem_alloc = {}; | ||||
10650 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
10651 | mem_alloc.pNext = NULL; | ||||
10652 | mem_alloc.allocationSize = 0; | ||||
10653 | mem_alloc.memoryTypeIndex = 0; | ||||
10654 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); | ||||
10655 | mem_alloc.allocationSize = mem_reqs.size; | ||||
10656 | pass = | ||||
10657 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); | ||||
10658 | ASSERT_TRUE(pass); | ||||
10659 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &image_mem); | ||||
10660 | ASSERT_VK_SUCCESS(err); | ||||
10661 | err = vkBindImageMemory(m_device->device(), image, image_mem, 0); | ||||
10662 | ASSERT_VK_SUCCESS(err); | ||||
10663 | // Now create view for image | ||||
10664 | VkImageViewCreateInfo image_view_ci = {}; | ||||
10665 | image_view_ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
10666 | image_view_ci.image = image; | ||||
10667 | image_view_ci.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
10668 | image_view_ci.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
10669 | image_view_ci.subresourceRange.layerCount = 1; | ||||
10670 | image_view_ci.subresourceRange.baseArrayLayer = 0; | ||||
10671 | image_view_ci.subresourceRange.levelCount = 1; | ||||
10672 | // Setting both depth & stencil aspect bits is illegal for descriptor | ||||
10673 | image_view_ci.subresourceRange.aspectMask = | ||||
10674 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; | ||||
10675 | |||||
10676 | VkImageView image_view; | ||||
10677 | err = vkCreateImageView(m_device->device(), &image_view_ci, NULL, | ||||
10678 | &image_view); | ||||
10679 | ASSERT_VK_SUCCESS(err); | ||||
10680 | |||||
10681 | VkDescriptorImageInfo img_info = {}; | ||||
10682 | img_info.imageView = image_view; | ||||
10683 | VkWriteDescriptorSet descriptor_write = {}; | ||||
10684 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
10685 | descriptor_write.dstBinding = 0; | ||||
10686 | descriptor_write.descriptorCount = 1; | ||||
10687 | descriptor_write.pTexelBufferView = NULL; | ||||
10688 | descriptor_write.pBufferInfo = NULL; | ||||
10689 | descriptor_write.pImageInfo = &img_info; | ||||
10690 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; | ||||
10691 | descriptor_write.dstSet = descriptor_set; | ||||
10692 | const char *error_msg = " please only set either VK_IMAGE_ASPECT_DEPTH_BIT " | ||||
10693 | "or VK_IMAGE_ASPECT_STENCIL_BIT "; | ||||
10694 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
10695 | error_msg); | ||||
10696 | |||||
10697 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10698 | |||||
10699 | m_errorMonitor->VerifyFound(); | ||||
10700 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
10701 | vkDestroyImage(m_device->device(), image, NULL); | ||||
10702 | vkFreeMemory(m_device->device(), image_mem, NULL); | ||||
10703 | vkDestroyImageView(m_device->device(), image_view, NULL); | ||||
10704 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptor_set); | ||||
10705 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
10706 | } | ||||
10707 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10708 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 10709 | // 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] | 10710 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10711 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10712 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 10713 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
10714 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " | ||||
10715 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10716 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10717 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10718 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10719 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10720 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
10721 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10722 | |
10723 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10724 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
10725 | ds_pool_ci.pNext = NULL; | ||||
10726 | ds_pool_ci.maxSets = 1; | ||||
10727 | ds_pool_ci.poolSizeCount = 1; | ||||
10728 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10729 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10730 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10731 | err = |
10732 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10733 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10734 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10735 | dsl_binding.binding = 0; |
10736 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10737 | dsl_binding.descriptorCount = 1; | ||||
10738 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10739 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10740 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10741 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10742 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
10743 | ds_layout_ci.pNext = NULL; | ||||
10744 | ds_layout_ci.bindingCount = 1; | ||||
10745 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10746 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10747 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10748 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
10749 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10750 | ASSERT_VK_SUCCESS(err); |
10751 | |||||
10752 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10753 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10754 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10755 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 10756 | alloc_info.descriptorPool = ds_pool; |
10757 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10758 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
10759 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10760 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10761 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 10762 | VkSamplerCreateInfo sampler_ci = {}; |
10763 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; | ||||
10764 | sampler_ci.pNext = NULL; | ||||
10765 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
10766 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
10767 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
10768 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10769 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10770 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10771 | sampler_ci.mipLodBias = 1.0; | ||||
10772 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
10773 | sampler_ci.maxAnisotropy = 1; | ||||
10774 | sampler_ci.compareEnable = VK_FALSE; | ||||
10775 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
10776 | sampler_ci.minLod = 1.0; | ||||
10777 | sampler_ci.maxLod = 1.0; | ||||
10778 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
10779 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
10780 | VkSampler sampler; | ||||
10781 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); | ||||
10782 | ASSERT_VK_SUCCESS(err); | ||||
10783 | |||||
10784 | VkDescriptorImageInfo info = {}; | ||||
10785 | info.sampler = sampler; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10786 | |
10787 | VkWriteDescriptorSet descriptor_write; | ||||
10788 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
10789 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10790 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 10791 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10792 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10793 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 10794 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10795 | |
10796 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10797 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10798 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 10799 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10800 | vkDestroySampler(m_device->device(), sampler, NULL); |
10801 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
10802 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 10803 | } |
10804 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10805 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 10806 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10807 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10808 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10809 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 10810 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
10811 | " binding #0 with 1 total descriptors but update of 1 descriptors " | ||||
10812 | "starting at binding offset of 0 combined with update array element " | ||||
10813 | "offset of 1 oversteps the size of this descriptor set."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10814 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10815 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10816 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10817 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10818 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
10819 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10820 | |
10821 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10822 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
10823 | ds_pool_ci.pNext = NULL; | ||||
10824 | ds_pool_ci.maxSets = 1; | ||||
10825 | ds_pool_ci.poolSizeCount = 1; | ||||
10826 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10827 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10828 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10829 | err = |
10830 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10831 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10832 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10833 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10834 | dsl_binding.binding = 0; |
10835 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10836 | dsl_binding.descriptorCount = 1; | ||||
10837 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10838 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10839 | |
10840 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10841 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
10842 | ds_layout_ci.pNext = NULL; | ||||
10843 | ds_layout_ci.bindingCount = 1; | ||||
10844 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10845 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10846 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10847 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
10848 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10849 | ASSERT_VK_SUCCESS(err); |
10850 | |||||
10851 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10852 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10853 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10854 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 10855 | alloc_info.descriptorPool = ds_pool; |
10856 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10857 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
10858 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10859 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10860 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 10861 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
10862 | VkDescriptorBufferInfo buff_info = {}; | ||||
10863 | buff_info.buffer = | ||||
10864 | VkBuffer(0); // Don't care about buffer handle for this test | ||||
10865 | buff_info.offset = 0; | ||||
10866 | buff_info.range = 1024; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10867 | |
10868 | VkWriteDescriptorSet descriptor_write; | ||||
10869 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
10870 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10871 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10872 | descriptor_write.dstArrayElement = |
10873 | 1; /* This index out of bounds for the update */ | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 10874 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 10875 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
10876 | descriptor_write.pBufferInfo = &buff_info; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10877 | |
10878 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10879 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10880 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 10881 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10882 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
10883 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 10884 | } |
10885 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10886 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
10887 | // Create layout w/ count of 1 and attempt update to that layout w/ binding | ||||
10888 | // index 2 | ||||
10889 | VkResult err; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10890 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 10891 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
10892 | " does not have binding 2."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10893 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10894 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10895 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10896 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10897 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
10898 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10899 | |
10900 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10901 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
10902 | ds_pool_ci.pNext = NULL; | ||||
10903 | ds_pool_ci.maxSets = 1; | ||||
10904 | ds_pool_ci.poolSizeCount = 1; | ||||
10905 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 10906 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10907 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10908 | err = |
10909 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10910 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10911 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10912 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10913 | dsl_binding.binding = 0; |
10914 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
10915 | dsl_binding.descriptorCount = 1; | ||||
10916 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
10917 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10918 | |
10919 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10920 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
10921 | ds_layout_ci.pNext = NULL; | ||||
10922 | ds_layout_ci.bindingCount = 1; | ||||
10923 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10924 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10925 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
10926 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10927 | ASSERT_VK_SUCCESS(err); |
10928 | |||||
10929 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10930 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10931 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10932 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 10933 | alloc_info.descriptorPool = ds_pool; |
10934 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10935 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
10936 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10937 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10938 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10939 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10940 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
10941 | sampler_ci.pNext = NULL; | ||||
10942 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
10943 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
10944 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
10945 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10946 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10947 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
10948 | sampler_ci.mipLodBias = 1.0; | ||||
10949 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
10950 | sampler_ci.maxAnisotropy = 1; | ||||
10951 | sampler_ci.compareEnable = VK_FALSE; | ||||
10952 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
10953 | sampler_ci.minLod = 1.0; | ||||
10954 | sampler_ci.maxLod = 1.0; | ||||
10955 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
10956 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10957 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10958 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10959 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10960 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10961 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 10962 | VkDescriptorImageInfo info = {}; |
10963 | info.sampler = sampler; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10964 | |
10965 | VkWriteDescriptorSet descriptor_write; | ||||
10966 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
10967 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10968 | descriptor_write.dstSet = descriptorSet; |
10969 | descriptor_write.dstBinding = 2; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 10970 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10971 | // 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] | 10972 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 10973 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 10974 | |
10975 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
10976 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10977 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 10978 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10979 | vkDestroySampler(m_device->device(), sampler, NULL); |
10980 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
10981 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 10982 | } |
10983 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10984 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
10985 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* | ||||
10986 | // types | ||||
10987 | VkResult err; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10988 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10989 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 10990 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10991 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 10992 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10993 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10994 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10995 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
10996 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 10997 | |
10998 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10999 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
11000 | ds_pool_ci.pNext = NULL; | ||||
11001 | ds_pool_ci.maxSets = 1; | ||||
11002 | ds_pool_ci.poolSizeCount = 1; | ||||
11003 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 11004 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11005 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11006 | err = |
11007 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11008 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11009 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11010 | dsl_binding.binding = 0; |
11011 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
11012 | dsl_binding.descriptorCount = 1; | ||||
11013 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
11014 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11015 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11016 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11017 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
11018 | ds_layout_ci.pNext = NULL; | ||||
11019 | ds_layout_ci.bindingCount = 1; | ||||
11020 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11021 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11022 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11023 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
11024 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11025 | ASSERT_VK_SUCCESS(err); |
11026 | |||||
11027 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11028 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11029 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11030 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 11031 | alloc_info.descriptorPool = ds_pool; |
11032 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11033 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
11034 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11035 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11036 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11037 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11038 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
11039 | sampler_ci.pNext = NULL; | ||||
11040 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
11041 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
11042 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
11043 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
11044 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
11045 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
11046 | sampler_ci.mipLodBias = 1.0; | ||||
11047 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
11048 | sampler_ci.maxAnisotropy = 1; | ||||
11049 | sampler_ci.compareEnable = VK_FALSE; | ||||
11050 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
11051 | sampler_ci.minLod = 1.0; | ||||
11052 | sampler_ci.maxLod = 1.0; | ||||
11053 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
11054 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11055 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11056 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11057 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 11058 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 11059 | VkDescriptorImageInfo info = {}; |
11060 | info.sampler = sampler; | ||||
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 11061 | |
11062 | VkWriteDescriptorSet descriptor_write; | ||||
11063 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11064 | descriptor_write.sType = |
11065 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11066 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 11067 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11068 | // 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] | 11069 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 11070 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 11071 | |
11072 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
11073 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11074 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 11075 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11076 | vkDestroySampler(m_device->device(), sampler, NULL); |
11077 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
11078 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 11079 | } |
11080 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11081 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11082 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11083 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11084 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11085 | m_errorMonitor->SetDesiredFailureMsg( |
11086 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 11087 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11088 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11089 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11090 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
11091 | // code | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11092 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11093 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
11094 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11095 | |
11096 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11097 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
11098 | ds_pool_ci.pNext = NULL; | ||||
11099 | ds_pool_ci.maxSets = 1; | ||||
11100 | ds_pool_ci.poolSizeCount = 1; | ||||
11101 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11102 | |
11103 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11104 | err = |
11105 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11106 | ASSERT_VK_SUCCESS(err); |
11107 | |||||
11108 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11109 | dsl_binding.binding = 0; |
11110 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
11111 | dsl_binding.descriptorCount = 1; | ||||
11112 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
11113 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11114 | |
11115 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11116 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
11117 | ds_layout_ci.pNext = NULL; | ||||
11118 | ds_layout_ci.bindingCount = 1; | ||||
11119 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11120 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11121 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
11122 | &ds_layout); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11123 | ASSERT_VK_SUCCESS(err); |
11124 | |||||
11125 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11126 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11127 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11128 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11129 | alloc_info.descriptorPool = ds_pool; |
11130 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11131 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
11132 | &descriptorSet); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11133 | ASSERT_VK_SUCCESS(err); |
11134 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11135 | VkSampler sampler = |
11136 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11137 | |
11138 | VkDescriptorImageInfo descriptor_info; | ||||
11139 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); | ||||
11140 | descriptor_info.sampler = sampler; | ||||
11141 | |||||
11142 | VkWriteDescriptorSet descriptor_write; | ||||
11143 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
11144 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11145 | descriptor_write.dstSet = descriptorSet; |
11146 | descriptor_write.dstBinding = 0; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 11147 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11148 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
11149 | descriptor_write.pImageInfo = &descriptor_info; | ||||
11150 | |||||
11151 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
11152 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11153 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11154 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11155 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
11156 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11157 | } |
11158 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11159 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
11160 | // Create a single combined Image/Sampler descriptor and send it an invalid | ||||
11161 | // imageView | ||||
11162 | VkResult err; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11163 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 11164 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
11165 | "Attempted write update to combined " | ||||
11166 | "image sampler descriptor failed due " | ||||
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 11167 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11168 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11169 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11170 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11171 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
11172 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11173 | |
11174 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11175 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
11176 | ds_pool_ci.pNext = NULL; | ||||
11177 | ds_pool_ci.maxSets = 1; | ||||
11178 | ds_pool_ci.poolSizeCount = 1; | ||||
11179 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11180 | |
11181 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11182 | err = |
11183 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11184 | ASSERT_VK_SUCCESS(err); |
11185 | |||||
11186 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11187 | dsl_binding.binding = 0; |
11188 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; | ||||
11189 | dsl_binding.descriptorCount = 1; | ||||
11190 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
11191 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11192 | |
11193 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11194 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
11195 | ds_layout_ci.pNext = NULL; | ||||
11196 | ds_layout_ci.bindingCount = 1; | ||||
11197 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11198 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11199 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
11200 | &ds_layout); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11201 | ASSERT_VK_SUCCESS(err); |
11202 | |||||
11203 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11204 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11205 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11206 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11207 | alloc_info.descriptorPool = ds_pool; |
11208 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11209 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
11210 | &descriptorSet); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11211 | ASSERT_VK_SUCCESS(err); |
11212 | |||||
11213 | VkSamplerCreateInfo sampler_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11214 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
11215 | sampler_ci.pNext = NULL; | ||||
11216 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
11217 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
11218 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
11219 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
11220 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
11221 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
11222 | sampler_ci.mipLodBias = 1.0; | ||||
11223 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
11224 | sampler_ci.maxAnisotropy = 1; | ||||
11225 | sampler_ci.compareEnable = VK_FALSE; | ||||
11226 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
11227 | sampler_ci.minLod = 1.0; | ||||
11228 | sampler_ci.maxLod = 1.0; | ||||
11229 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
11230 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11231 | |
11232 | VkSampler sampler; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11233 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11234 | ASSERT_VK_SUCCESS(err); |
11235 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11236 | VkImageView view = |
11237 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11238 | |
11239 | VkDescriptorImageInfo descriptor_info; | ||||
11240 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); | ||||
11241 | descriptor_info.sampler = sampler; | ||||
11242 | descriptor_info.imageView = view; | ||||
11243 | |||||
11244 | VkWriteDescriptorSet descriptor_write; | ||||
11245 | memset(&descriptor_write, 0, sizeof(descriptor_write)); | ||||
11246 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11247 | descriptor_write.dstSet = descriptorSet; |
11248 | descriptor_write.dstBinding = 0; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 11249 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11250 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
11251 | descriptor_write.pImageInfo = &descriptor_info; | ||||
11252 | |||||
11253 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
11254 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11255 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11256 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11257 | vkDestroySampler(m_device->device(), sampler, NULL); |
11258 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
11259 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11260 | } |
11261 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11262 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
11263 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update | ||||
11264 | // into the other | ||||
11265 | VkResult err; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11266 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 11267 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
11268 | " binding #1 with type " | ||||
11269 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " | ||||
11270 | "not match."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11271 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11272 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11273 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11274 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11275 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
11276 | ds_type_count[0].descriptorCount = 1; | ||||
11277 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
11278 | ds_type_count[1].descriptorCount = 1; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11279 | |
11280 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11281 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
11282 | ds_pool_ci.pNext = NULL; | ||||
11283 | ds_pool_ci.maxSets = 1; | ||||
11284 | ds_pool_ci.poolSizeCount = 2; | ||||
11285 | ds_pool_ci.pPoolSizes = ds_type_count; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11286 | |
11287 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11288 | err = |
11289 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11290 | ASSERT_VK_SUCCESS(err); |
11291 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11292 | dsl_binding[0].binding = 0; |
11293 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
11294 | dsl_binding[0].descriptorCount = 1; | ||||
11295 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; | ||||
11296 | dsl_binding[0].pImmutableSamplers = NULL; | ||||
11297 | dsl_binding[1].binding = 1; | ||||
11298 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; | ||||
11299 | dsl_binding[1].descriptorCount = 1; | ||||
11300 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; | ||||
11301 | dsl_binding[1].pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11302 | |
11303 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11304 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
11305 | ds_layout_ci.pNext = NULL; | ||||
11306 | ds_layout_ci.bindingCount = 2; | ||||
11307 | ds_layout_ci.pBindings = dsl_binding; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11308 | |
11309 | VkDescriptorSetLayout ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11310 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
11311 | &ds_layout); | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11312 | ASSERT_VK_SUCCESS(err); |
11313 | |||||
11314 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11315 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11316 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11317 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11318 | alloc_info.descriptorPool = ds_pool; |
11319 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11320 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
11321 | &descriptorSet); | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11322 | ASSERT_VK_SUCCESS(err); |
11323 | |||||
11324 | VkSamplerCreateInfo sampler_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11325 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
11326 | sampler_ci.pNext = NULL; | ||||
11327 | sampler_ci.magFilter = VK_FILTER_NEAREST; | ||||
11328 | sampler_ci.minFilter = VK_FILTER_NEAREST; | ||||
11329 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; | ||||
11330 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
11331 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
11332 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; | ||||
11333 | sampler_ci.mipLodBias = 1.0; | ||||
11334 | sampler_ci.anisotropyEnable = VK_FALSE; | ||||
11335 | sampler_ci.maxAnisotropy = 1; | ||||
11336 | sampler_ci.compareEnable = VK_FALSE; | ||||
11337 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; | ||||
11338 | sampler_ci.minLod = 1.0; | ||||
11339 | sampler_ci.maxLod = 1.0; | ||||
11340 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; | ||||
11341 | sampler_ci.unnormalizedCoordinates = VK_FALSE; | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11342 | |
11343 | VkSampler sampler; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11344 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11345 | ASSERT_VK_SUCCESS(err); |
11346 | |||||
11347 | VkDescriptorImageInfo info = {}; | ||||
11348 | info.sampler = sampler; | ||||
11349 | |||||
11350 | VkWriteDescriptorSet descriptor_write; | ||||
11351 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); | ||||
11352 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11353 | descriptor_write.dstSet = descriptorSet; |
11354 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 11355 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11356 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
11357 | descriptor_write.pImageInfo = &info; | ||||
11358 | // This write update should succeed | ||||
11359 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); | ||||
11360 | // Now perform a copy update that fails due to type mismatch | ||||
11361 | VkCopyDescriptorSet copy_ds_update; | ||||
11362 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); | ||||
11363 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; | ||||
11364 | copy_ds_update.srcSet = descriptorSet; | ||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 11365 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11366 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11367 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 11368 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11369 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
11370 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11371 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11372 | // 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] | 11373 | m_errorMonitor->SetDesiredFailureMsg( |
11374 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 11375 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11376 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
11377 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; | ||||
11378 | copy_ds_update.srcSet = descriptorSet; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11379 | copy_ds_update.srcBinding = |
11380 | 3; // ERROR : Invalid binding for matching layout | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11381 | copy_ds_update.dstSet = descriptorSet; |
11382 | copy_ds_update.dstBinding = 0; | ||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 11383 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11384 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
11385 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11386 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11387 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11388 | // 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] | 11389 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 11390 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
11391 | "update array offset of 0 and update of " | ||||
11392 | "5 descriptors oversteps total number " | ||||
11393 | "of descriptors in set: 2."); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11394 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11395 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
11396 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; | ||||
11397 | copy_ds_update.srcSet = descriptorSet; | ||||
11398 | copy_ds_update.srcBinding = 1; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11399 | copy_ds_update.dstSet = descriptorSet; |
11400 | copy_ds_update.dstBinding = 0; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11401 | copy_ds_update.descriptorCount = |
11402 | 5; // ERROR copy 5 descriptors (out of bounds for layout) | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11403 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
11404 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11405 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11406 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11407 | vkDestroySampler(m_device->device(), sampler, NULL); |
11408 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
11409 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 11410 | } |
11411 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11412 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
11413 | // Create CommandBuffer where MSAA samples doesn't match RenderPass | ||||
11414 | // sampleCount | ||||
11415 | VkResult err; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11416 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 11417 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11418 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11419 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11420 | ASSERT_NO_FATAL_FAILURE(InitState()); |
11421 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11422 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11423 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 11424 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11425 | |
11426 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11427 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
11428 | ds_pool_ci.pNext = NULL; | ||||
11429 | ds_pool_ci.maxSets = 1; | ||||
11430 | ds_pool_ci.poolSizeCount = 1; | ||||
11431 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 11432 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11433 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11434 | err = |
11435 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11436 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11437 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11438 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 11439 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11440 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 11441 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11442 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
11443 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11444 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11445 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
11446 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
11447 | ds_layout_ci.pNext = NULL; | ||||
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 11448 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 11449 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11450 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11451 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11452 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
11453 | &ds_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11454 | ASSERT_VK_SUCCESS(err); |
11455 | |||||
11456 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11457 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11458 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11459 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 11460 | alloc_info.descriptorPool = ds_pool; |
11461 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11462 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
11463 | &descriptorSet); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11464 | ASSERT_VK_SUCCESS(err); |
11465 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11466 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11467 | pipe_ms_state_ci.sType = |
11468 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
11469 | pipe_ms_state_ci.pNext = NULL; | ||||
11470 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; | ||||
11471 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
11472 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
11473 | pipe_ms_state_ci.pSampleMask = NULL; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11474 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11475 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11476 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
11477 | pipeline_layout_ci.pNext = NULL; | ||||
11478 | pipeline_layout_ci.setLayoutCount = 1; | ||||
11479 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11480 | |
11481 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11482 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
11483 | &pipeline_layout); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11484 | ASSERT_VK_SUCCESS(err); |
11485 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11486 | VkShaderObj vs(m_device, bindStateVertShaderText, |
11487 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
11488 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
11489 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11490 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11491 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 11492 | VkPipelineObj pipe(m_device); |
11493 | pipe.AddShader(&vs); | ||||
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 11494 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 11495 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 11496 | pipe.SetMSAA(&pipe_ms_state_ci); |
11497 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11498 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 11499 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11500 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
11501 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 11502 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 11503 | // Render triangle (the error should trigger on the attempt to draw). |
11504 | Draw(3, 1, 0, 0); | ||||
11505 | |||||
11506 | // Finalize recording of the command buffer | ||||
11507 | EndCommandBuffer(); | ||||
11508 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11509 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 11510 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11511 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
11512 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
11513 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 11514 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 11515 | |
Tobin Ehlis | 85aa15a | 2016-06-15 10:52:37 -0600 | [diff] [blame] | 11516 | TEST_F(VkLayerTest, RenderPassIncompatible) { |
11517 | TEST_DESCRIPTION("Hit RenderPass incompatible cases. " | ||||
11518 | "Initial case is drawing with an active renderpass that's " | ||||
11519 | "not compatible with the bound PSO's creation renderpass"); | ||||
11520 | VkResult err; | ||||
11521 | |||||
11522 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
11523 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11524 | |||||
11525 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
11526 | dsl_binding.binding = 0; | ||||
11527 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
11528 | dsl_binding.descriptorCount = 1; | ||||
11529 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
11530 | dsl_binding.pImmutableSamplers = NULL; | ||||
11531 | |||||
11532 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
11533 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
11534 | ds_layout_ci.pNext = NULL; | ||||
11535 | ds_layout_ci.bindingCount = 1; | ||||
11536 | ds_layout_ci.pBindings = &dsl_binding; | ||||
11537 | |||||
11538 | VkDescriptorSetLayout ds_layout; | ||||
11539 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
11540 | &ds_layout); | ||||
11541 | ASSERT_VK_SUCCESS(err); | ||||
11542 | |||||
11543 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
11544 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
11545 | pipeline_layout_ci.pNext = NULL; | ||||
11546 | pipeline_layout_ci.setLayoutCount = 1; | ||||
11547 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
11548 | |||||
11549 | VkPipelineLayout pipeline_layout; | ||||
11550 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
11551 | &pipeline_layout); | ||||
11552 | ASSERT_VK_SUCCESS(err); | ||||
11553 | |||||
11554 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
11555 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
11556 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
11557 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
11558 | this); // We shouldn't need a fragment shader | ||||
11559 | // but add it to be able to run on more devices | ||||
11560 | // Create a renderpass that will be incompatible with default renderpass | ||||
11561 | VkAttachmentReference attach = {}; | ||||
11562 | attach.layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | ||||
11563 | VkAttachmentReference color_att = {}; | ||||
11564 | color_att.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
11565 | VkSubpassDescription subpass = {}; | ||||
11566 | subpass.inputAttachmentCount = 1; | ||||
11567 | subpass.pInputAttachments = &attach; | ||||
11568 | subpass.colorAttachmentCount = 1; | ||||
11569 | subpass.pColorAttachments = &color_att; | ||||
11570 | VkRenderPassCreateInfo rpci = {}; | ||||
11571 | rpci.subpassCount = 1; | ||||
11572 | rpci.pSubpasses = &subpass; | ||||
11573 | rpci.attachmentCount = 1; | ||||
11574 | VkAttachmentDescription attach_desc = {}; | ||||
11575 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
Cody Northrop | bd16af1 | 2016-06-21 09:25:48 -0600 | [diff] [blame] | 11576 | // Format incompatible with PSO RP color attach format B8G8R8A8_UNORM |
11577 | attach_desc.format = VK_FORMAT_R8G8B8A8_UNORM; | ||||
Tobin Ehlis | 85aa15a | 2016-06-15 10:52:37 -0600 | [diff] [blame] | 11578 | rpci.pAttachments = &attach_desc; |
11579 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; | ||||
11580 | VkRenderPass rp; | ||||
11581 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
11582 | VkPipelineObj pipe(m_device); | ||||
11583 | pipe.AddShader(&vs); | ||||
11584 | pipe.AddShader(&fs); | ||||
11585 | pipe.AddColorAttachment(); | ||||
11586 | VkViewport view_port = {}; | ||||
11587 | m_viewports.push_back(view_port); | ||||
11588 | pipe.SetViewport(m_viewports); | ||||
11589 | VkRect2D rect = {}; | ||||
11590 | m_scissors.push_back(rect); | ||||
11591 | pipe.SetScissor(m_scissors); | ||||
11592 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
11593 | |||||
11594 | VkCommandBufferInheritanceInfo cbii = {}; | ||||
11595 | cbii.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO; | ||||
11596 | cbii.renderPass = rp; | ||||
11597 | cbii.subpass = 0; | ||||
11598 | VkCommandBufferBeginInfo cbbi = {}; | ||||
11599 | cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; | ||||
11600 | cbbi.pInheritanceInfo = &cbii; | ||||
11601 | vkBeginCommandBuffer(m_commandBuffer->handle(), &cbbi); | ||||
11602 | VkRenderPassBeginInfo rpbi = {}; | ||||
11603 | rpbi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; | ||||
11604 | rpbi.framebuffer = m_framebuffer; | ||||
11605 | rpbi.renderPass = rp; | ||||
11606 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rpbi, | ||||
11607 | VK_SUBPASS_CONTENTS_INLINE); | ||||
11608 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
11609 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
11610 | |||||
11611 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11612 | " is incompatible w/ gfx pipeline "); | ||||
11613 | // Render triangle (the error should trigger on the attempt to draw). | ||||
11614 | Draw(3, 1, 0, 0); | ||||
11615 | |||||
11616 | // Finalize recording of the command buffer | ||||
11617 | EndCommandBuffer(); | ||||
11618 | |||||
11619 | m_errorMonitor->VerifyFound(); | ||||
11620 | |||||
11621 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
11622 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
11623 | vkDestroyRenderPass(m_device->device(), rp, NULL); | ||||
11624 | } | ||||
11625 | |||||
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 11626 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
11627 | // Create Pipeline where the number of blend attachments doesn't match the | ||||
11628 | // number of color attachments. In this case, we don't add any color | ||||
11629 | // blend attachments even though we have a color attachment. | ||||
11630 | VkResult err; | ||||
11631 | |||||
11632 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 11633 | "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] | 11634 | |
11635 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
11636 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11637 | VkDescriptorPoolSize ds_type_count = {}; | ||||
11638 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
11639 | ds_type_count.descriptorCount = 1; | ||||
11640 | |||||
11641 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
11642 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | ||||
11643 | ds_pool_ci.pNext = NULL; | ||||
11644 | ds_pool_ci.maxSets = 1; | ||||
11645 | ds_pool_ci.poolSizeCount = 1; | ||||
11646 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
11647 | |||||
11648 | VkDescriptorPool ds_pool; | ||||
11649 | err = | ||||
11650 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
11651 | ASSERT_VK_SUCCESS(err); | ||||
11652 | |||||
11653 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
11654 | dsl_binding.binding = 0; | ||||
11655 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
11656 | dsl_binding.descriptorCount = 1; | ||||
11657 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
11658 | dsl_binding.pImmutableSamplers = NULL; | ||||
11659 | |||||
11660 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
11661 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; | ||||
11662 | ds_layout_ci.pNext = NULL; | ||||
11663 | ds_layout_ci.bindingCount = 1; | ||||
11664 | ds_layout_ci.pBindings = &dsl_binding; | ||||
11665 | |||||
11666 | VkDescriptorSetLayout ds_layout; | ||||
11667 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, | ||||
11668 | &ds_layout); | ||||
11669 | ASSERT_VK_SUCCESS(err); | ||||
11670 | |||||
11671 | VkDescriptorSet descriptorSet; | ||||
11672 | VkDescriptorSetAllocateInfo alloc_info = {}; | ||||
11673 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | ||||
11674 | alloc_info.descriptorSetCount = 1; | ||||
11675 | alloc_info.descriptorPool = ds_pool; | ||||
11676 | alloc_info.pSetLayouts = &ds_layout; | ||||
11677 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, | ||||
11678 | &descriptorSet); | ||||
11679 | ASSERT_VK_SUCCESS(err); | ||||
11680 | |||||
11681 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; | ||||
11682 | pipe_ms_state_ci.sType = | ||||
11683 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
11684 | pipe_ms_state_ci.pNext = NULL; | ||||
11685 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; | ||||
11686 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
11687 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
11688 | pipe_ms_state_ci.pSampleMask = NULL; | ||||
11689 | |||||
11690 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
11691 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
11692 | pipeline_layout_ci.pNext = NULL; | ||||
11693 | pipeline_layout_ci.setLayoutCount = 1; | ||||
11694 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
11695 | |||||
11696 | VkPipelineLayout pipeline_layout; | ||||
11697 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, | ||||
11698 | &pipeline_layout); | ||||
11699 | ASSERT_VK_SUCCESS(err); | ||||
11700 | |||||
11701 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
11702 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
11703 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
11704 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11705 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 11706 | // but add it to be able to run on more devices |
11707 | VkPipelineObj pipe(m_device); | ||||
11708 | pipe.AddShader(&vs); | ||||
11709 | pipe.AddShader(&fs); | ||||
11710 | pipe.SetMSAA(&pipe_ms_state_ci); | ||||
11711 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
11712 | |||||
11713 | BeginCommandBuffer(); | ||||
11714 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
11715 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
11716 | |||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 11717 | // Render triangle (the error should trigger on the attempt to draw). |
11718 | Draw(3, 1, 0, 0); | ||||
11719 | |||||
11720 | // Finalize recording of the command buffer | ||||
11721 | EndCommandBuffer(); | ||||
11722 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11723 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 11724 | |
11725 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
11726 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
11727 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
11728 | } | ||||
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 11729 | |
Mark Mueller | d491441 | 2016-06-13 17:52:06 -0600 | [diff] [blame] | 11730 | TEST_F(VkLayerTest, MissingClearAttachment) { |
11731 | TEST_DESCRIPTION("Points to a wrong colorAttachment index in a VkClearAttachment " | ||||
11732 | "structure passed to vkCmdClearAttachments"); | ||||
11733 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
11734 | "vkCmdClearAttachments() attachment index 1 not found in attachment " | ||||
11735 | "reference array of active subpass 0"); | ||||
11736 | |||||
11737 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailCmdClearAttachments); | ||||
11738 | m_errorMonitor->VerifyFound(); | ||||
11739 | } | ||||
11740 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11741 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
11742 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior | ||||
11743 | // to issuing a Draw | ||||
11744 | VkResult err; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11745 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11746 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 11747 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11748 | "vkCmdClearAttachments() issued on CB object "); |
11749 | |||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11750 | ASSERT_NO_FATAL_FAILURE(InitState()); |
11751 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11752 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11753 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11754 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
11755 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11756 | |
11757 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11758 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
11759 | ds_pool_ci.pNext = NULL; | ||||
11760 | ds_pool_ci.maxSets = 1; | ||||
11761 | ds_pool_ci.poolSizeCount = 1; | ||||
11762 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11763 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11764 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11765 | err = |
11766 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11767 | ASSERT_VK_SUCCESS(err); |
11768 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11769 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11770 | dsl_binding.binding = 0; |
11771 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
11772 | dsl_binding.descriptorCount = 1; | ||||
11773 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
11774 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11775 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11776 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11777 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
11778 | ds_layout_ci.pNext = NULL; | ||||
11779 | ds_layout_ci.bindingCount = 1; | ||||
11780 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 11781 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11782 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11783 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
11784 | &ds_layout); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11785 | ASSERT_VK_SUCCESS(err); |
11786 | |||||
11787 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11788 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11789 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11790 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 11791 | alloc_info.descriptorPool = ds_pool; |
11792 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11793 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
11794 | &descriptorSet); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11795 | ASSERT_VK_SUCCESS(err); |
11796 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11797 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11798 | pipe_ms_state_ci.sType = |
11799 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
11800 | pipe_ms_state_ci.pNext = NULL; | ||||
11801 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; | ||||
11802 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
11803 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
11804 | pipe_ms_state_ci.pSampleMask = NULL; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11805 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11806 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11807 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
11808 | pipeline_layout_ci.pNext = NULL; | ||||
11809 | pipeline_layout_ci.setLayoutCount = 1; | ||||
11810 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11811 | |
11812 | VkPipelineLayout pipeline_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11813 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
11814 | &pipeline_layout); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11815 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 11816 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11817 | VkShaderObj vs(m_device, bindStateVertShaderText, |
11818 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11819 | // 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] | 11820 | // on more devices |
11821 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
11822 | VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11823 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 11824 | VkPipelineObj pipe(m_device); |
11825 | pipe.AddShader(&vs); | ||||
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 11826 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 11827 | pipe.SetMSAA(&pipe_ms_state_ci); |
11828 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 11829 | |
11830 | BeginCommandBuffer(); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11831 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11832 | // Main thing we care about for this test is that the VkImage obj we're |
11833 | // clearing matches Color Attachment of FB | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11834 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 11835 | VkClearAttachment color_attachment; |
11836 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
11837 | color_attachment.clearValue.color.float32[0] = 1.0; | ||||
11838 | color_attachment.clearValue.color.float32[1] = 1.0; | ||||
11839 | color_attachment.clearValue.color.float32[2] = 1.0; | ||||
11840 | color_attachment.clearValue.color.float32[3] = 1.0; | ||||
11841 | color_attachment.colorAttachment = 0; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11842 | VkClearRect clear_rect = { |
11843 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11844 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11845 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
11846 | &color_attachment, 1, &clear_rect); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11847 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11848 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 11849 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11850 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
11851 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
11852 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 11853 | } |
11854 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11855 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
11856 | VkResult err; | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11857 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11858 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 11859 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 11860 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11861 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11862 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 11863 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11864 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11865 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11866 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11867 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
11868 | ds_type_count.descriptorCount = 1; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11869 | |
11870 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11871 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
11872 | ds_pool_ci.pNext = NULL; | ||||
11873 | ds_pool_ci.maxSets = 1; | ||||
11874 | ds_pool_ci.poolSizeCount = 1; | ||||
11875 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11876 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 11877 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11878 | err = |
11879 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11880 | ASSERT_VK_SUCCESS(err); |
11881 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11882 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11883 | dsl_binding.binding = 0; |
11884 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | ||||
11885 | dsl_binding.descriptorCount = 1; | ||||
11886 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
11887 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11888 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11889 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11890 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
11891 | ds_layout_ci.pNext = NULL; | ||||
11892 | ds_layout_ci.bindingCount = 1; | ||||
11893 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11894 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11895 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11896 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
11897 | &ds_layout); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11898 | ASSERT_VK_SUCCESS(err); |
11899 | |||||
11900 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11901 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11902 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11903 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 11904 | alloc_info.descriptorPool = ds_pool; |
11905 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11906 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
11907 | &descriptorSet); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11908 | ASSERT_VK_SUCCESS(err); |
11909 | |||||
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11910 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11911 | pipe_ms_state_ci.sType = |
11912 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
11913 | pipe_ms_state_ci.pNext = NULL; | ||||
11914 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; | ||||
11915 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
11916 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
11917 | pipe_ms_state_ci.pSampleMask = NULL; | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11918 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 11919 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11920 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
11921 | pipeline_layout_ci.pNext = NULL; | ||||
11922 | pipeline_layout_ci.setLayoutCount = 1; | ||||
11923 | pipeline_layout_ci.pSetLayouts = &ds_layout; | ||||
11924 | VkPipelineLayout pipeline_layout; | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11925 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11926 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
11927 | &pipeline_layout); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11928 | ASSERT_VK_SUCCESS(err); |
11929 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11930 | VkShaderObj vs(m_device, bindStateVertShaderText, |
11931 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
11932 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
11933 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 11934 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11935 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 11936 | VkPipelineObj pipe(m_device); |
11937 | pipe.AddShader(&vs); | ||||
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 11938 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 11939 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 11940 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 11941 | pipe.SetViewport(m_viewports); |
11942 | pipe.SetScissor(m_scissors); | ||||
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 11943 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 11944 | |
11945 | BeginCommandBuffer(); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11946 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
11947 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 11948 | // Don't care about actual data, just need to get to draw to flag error |
11949 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11950 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
11951 | (const void *)&vbo_data); | ||||
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 11952 | 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] | 11953 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11954 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11955 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 11956 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11957 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
11958 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); | ||||
11959 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 11960 | } |
Mark Mueller | dfe3755 | 2016-07-07 14:47:42 -0600 | [diff] [blame] | 11961 | |
11962 | TEST_F(VkLayerTest, VertexBufferInvalid) { | ||||
11963 | TEST_DESCRIPTION("Submit a command buffer using deleted vertex buffer, " | ||||
11964 | "delete a buffer twice, use an invalid offset for each " | ||||
11965 | "buffer type, and attempt to bind a null buffer"); | ||||
11966 | |||||
11967 | const char *deleted_buffer_in_command_buffer = "Cannot submit cmd buffer " | ||||
11968 | "using deleted buffer "; | ||||
11969 | const char *double_destroy_message = "Cannot free buffer 0x"; | ||||
11970 | const char *invalid_offset_message = "vkBindBufferMemory(): " | ||||
11971 | "memoryOffset is 0x"; | ||||
11972 | const char *invalid_storage_buffer_offset_message = "vkBindBufferMemory(): " | ||||
11973 | "storage memoryOffset " | ||||
11974 | "is 0x"; | ||||
11975 | const char *invalid_texel_buffer_offset_message = "vkBindBufferMemory(): " | ||||
11976 | "texel memoryOffset " | ||||
11977 | "is 0x"; | ||||
11978 | const char *invalid_uniform_buffer_offset_message = "vkBindBufferMemory(): " | ||||
11979 | "uniform memoryOffset " | ||||
11980 | "is 0x"; | ||||
11981 | const char *bind_null_buffer_message = "In vkBindBufferMemory, attempting" | ||||
11982 | " to Bind Obj(0x"; | ||||
11983 | const char *free_invalid_buffer_message = "Request to delete memory " | ||||
11984 | "object 0x"; | ||||
11985 | |||||
11986 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
11987 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
11988 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
11989 | |||||
11990 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; | ||||
11991 | pipe_ms_state_ci.sType = | ||||
11992 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; | ||||
11993 | pipe_ms_state_ci.pNext = NULL; | ||||
11994 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; | ||||
11995 | pipe_ms_state_ci.sampleShadingEnable = 0; | ||||
11996 | pipe_ms_state_ci.minSampleShading = 1.0; | ||||
11997 | pipe_ms_state_ci.pSampleMask = nullptr; | ||||
11998 | |||||
11999 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; | ||||
12000 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | ||||
12001 | VkPipelineLayout pipeline_layout; | ||||
12002 | |||||
12003 | VkResult err = vkCreatePipelineLayout(m_device->device(), | ||||
12004 | &pipeline_layout_ci, nullptr, | ||||
12005 | &pipeline_layout); | ||||
12006 | ASSERT_VK_SUCCESS(err); | ||||
12007 | |||||
12008 | VkShaderObj vs(m_device, bindStateVertShaderText, | ||||
12009 | VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12010 | VkShaderObj fs(m_device, bindStateFragShaderText, | ||||
12011 | VK_SHADER_STAGE_FRAGMENT_BIT, | ||||
12012 | this); | ||||
12013 | VkPipelineObj pipe(m_device); | ||||
12014 | pipe.AddShader(&vs); | ||||
12015 | pipe.AddShader(&fs); | ||||
12016 | pipe.AddColorAttachment(); | ||||
12017 | pipe.SetMSAA(&pipe_ms_state_ci); | ||||
12018 | pipe.SetViewport(m_viewports); | ||||
12019 | pipe.SetScissor(m_scissors); | ||||
12020 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); | ||||
12021 | |||||
12022 | BeginCommandBuffer(); | ||||
12023 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), | ||||
12024 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); | ||||
12025 | |||||
12026 | { | ||||
12027 | // Create and bind a vertex buffer in a reduced scope, which will cause | ||||
12028 | // it to be deleted upon leaving this scope | ||||
12029 | const float vbo_data[3] = {1.f, 0.f, 1.f}; | ||||
12030 | VkVerticesObj draw_verticies(m_device, 1, 1, sizeof(vbo_data), | ||||
12031 | 3, vbo_data); | ||||
12032 | draw_verticies.BindVertexBuffers(m_commandBuffer->handle()); | ||||
12033 | draw_verticies.AddVertexInputToPipe(pipe); | ||||
12034 | } | ||||
12035 | |||||
12036 | Draw(1, 0, 0, 0); | ||||
12037 | |||||
12038 | EndCommandBuffer(); | ||||
12039 | |||||
12040 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12041 | deleted_buffer_in_command_buffer); | ||||
12042 | QueueCommandBuffer(false); | ||||
12043 | m_errorMonitor->VerifyFound(); | ||||
12044 | |||||
12045 | { | ||||
12046 | // Create and bind a vertex buffer in a reduced scope, and delete it | ||||
12047 | // twice, the second through the destructor | ||||
12048 | VkBufferTest buffer_test(m_device, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, | ||||
12049 | VkBufferTest::eDoubleDelete); | ||||
12050 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12051 | double_destroy_message); | ||||
12052 | buffer_test.TestDoubleDestroy(); | ||||
12053 | } | ||||
12054 | m_errorMonitor->VerifyFound(); | ||||
12055 | |||||
12056 | if (VkBufferTest:: | ||||
12057 | GetTestConditionValid(m_device, | ||||
12058 | VkBufferTest::eInvalidMemoryOffset)) { | ||||
12059 | // Create and bind a memory buffer with an invalid offset. | ||||
12060 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12061 | invalid_offset_message); | ||||
12062 | VkBufferTest buffer_test(m_device, | ||||
12063 | VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, | ||||
12064 | VkBufferTest::eInvalidMemoryOffset); | ||||
12065 | (void) buffer_test; | ||||
12066 | m_errorMonitor->VerifyFound(); | ||||
12067 | } | ||||
12068 | |||||
12069 | if (VkBufferTest:: | ||||
12070 | GetTestConditionValid(m_device, | ||||
12071 | VkBufferTest::eInvalidDeviceOffset, | ||||
12072 | VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT)) { | ||||
12073 | // Create and bind a memory buffer with an invalid offset again, | ||||
12074 | // but look for a texel buffer message. | ||||
12075 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12076 | invalid_texel_buffer_offset_message); | ||||
12077 | VkBufferTest buffer_test(m_device, | ||||
12078 | VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, | ||||
12079 | VkBufferTest::eInvalidDeviceOffset); | ||||
12080 | (void) buffer_test; | ||||
12081 | m_errorMonitor->VerifyFound(); | ||||
12082 | } | ||||
12083 | |||||
12084 | if (VkBufferTest:: | ||||
12085 | GetTestConditionValid(m_device, | ||||
12086 | VkBufferTest::eInvalidDeviceOffset, | ||||
12087 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) { | ||||
12088 | // Create and bind a memory buffer with an invalid offset again, but | ||||
12089 | // look for a uniform buffer message. | ||||
12090 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12091 | invalid_uniform_buffer_offset_message); | ||||
12092 | VkBufferTest buffer_test(m_device, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, | ||||
12093 | VkBufferTest::eInvalidDeviceOffset); | ||||
12094 | (void) buffer_test; | ||||
12095 | m_errorMonitor->VerifyFound(); | ||||
12096 | } | ||||
12097 | |||||
12098 | if (VkBufferTest:: | ||||
12099 | GetTestConditionValid(m_device, | ||||
12100 | VkBufferTest::eInvalidDeviceOffset, | ||||
12101 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT)) { | ||||
12102 | // Create and bind a memory buffer with an invalid offset again, but | ||||
12103 | // look for a storage buffer message. | ||||
12104 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12105 | invalid_storage_buffer_offset_message); | ||||
12106 | VkBufferTest buffer_test(m_device, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, | ||||
12107 | VkBufferTest::eInvalidDeviceOffset); | ||||
12108 | (void) buffer_test; | ||||
12109 | m_errorMonitor->VerifyFound(); | ||||
12110 | } | ||||
12111 | |||||
12112 | { | ||||
12113 | // Attempt to bind a null buffer. | ||||
12114 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12115 | bind_null_buffer_message); | ||||
12116 | VkBufferTest buffer_test(m_device, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, | ||||
12117 | VkBufferTest::eBindNullBuffer); | ||||
12118 | (void) buffer_test; | ||||
12119 | m_errorMonitor->VerifyFound(); | ||||
12120 | } | ||||
12121 | |||||
12122 | { | ||||
12123 | // Attempt to use an invalid handle to delete a buffer. | ||||
12124 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12125 | free_invalid_buffer_message); | ||||
12126 | VkBufferTest buffer_test(m_device, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, | ||||
12127 | VkBufferTest::eFreeInvalidHandle); | ||||
12128 | (void) buffer_test; | ||||
12129 | } | ||||
12130 | m_errorMonitor->VerifyFound(); | ||||
12131 | |||||
12132 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); | ||||
12133 | } | ||||
12134 | |||||
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 12135 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
12136 | TEST_F(VkLayerTest, InvalidImageLayout) { | ||||
12137 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " | ||||
12138 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" | ||||
12139 | "images in the wrong layout when they're copied or transitioned."); | ||||
12140 | // 3 in ValidateCmdBufImageLayouts | ||||
12141 | // * -1 Attempt to submit cmd buf w/ deleted image | ||||
12142 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource | ||||
12143 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource | ||||
12144 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12145 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
12146 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); | ||||
12147 | |||||
12148 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12149 | // Create src & dst images to use for copy operations | ||||
12150 | VkImage src_image; | ||||
12151 | VkImage dst_image; | ||||
12152 | |||||
12153 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
12154 | const int32_t tex_width = 32; | ||||
12155 | const int32_t tex_height = 32; | ||||
12156 | |||||
12157 | VkImageCreateInfo image_create_info = {}; | ||||
12158 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
12159 | image_create_info.pNext = NULL; | ||||
12160 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
12161 | image_create_info.format = tex_format; | ||||
12162 | image_create_info.extent.width = tex_width; | ||||
12163 | image_create_info.extent.height = tex_height; | ||||
12164 | image_create_info.extent.depth = 1; | ||||
12165 | image_create_info.mipLevels = 1; | ||||
12166 | image_create_info.arrayLayers = 4; | ||||
12167 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
12168 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
12169 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
12170 | image_create_info.flags = 0; | ||||
12171 | |||||
12172 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); | ||||
12173 | ASSERT_VK_SUCCESS(err); | ||||
12174 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); | ||||
12175 | ASSERT_VK_SUCCESS(err); | ||||
12176 | |||||
12177 | BeginCommandBuffer(); | ||||
12178 | VkImageCopy copyRegion; | ||||
12179 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
12180 | copyRegion.srcSubresource.mipLevel = 0; | ||||
12181 | copyRegion.srcSubresource.baseArrayLayer = 0; | ||||
12182 | copyRegion.srcSubresource.layerCount = 1; | ||||
12183 | copyRegion.srcOffset.x = 0; | ||||
12184 | copyRegion.srcOffset.y = 0; | ||||
12185 | copyRegion.srcOffset.z = 0; | ||||
12186 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
12187 | copyRegion.dstSubresource.mipLevel = 0; | ||||
12188 | copyRegion.dstSubresource.baseArrayLayer = 0; | ||||
12189 | copyRegion.dstSubresource.layerCount = 1; | ||||
12190 | copyRegion.dstOffset.x = 0; | ||||
12191 | copyRegion.dstOffset.y = 0; | ||||
12192 | copyRegion.dstOffset.z = 0; | ||||
12193 | copyRegion.extent.width = 1; | ||||
12194 | copyRegion.extent.height = 1; | ||||
12195 | copyRegion.extent.depth = 1; | ||||
12196 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
12197 | m_errorMonitor->VerifyFound(); | ||||
12198 | // Now cause error due to src image layout changing | ||||
12199 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12200 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12201 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); | ||||
12202 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
12203 | m_errorMonitor->VerifyFound(); | ||||
12204 | // Final src error is due to bad layout type | ||||
12205 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12206 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12207 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); | ||||
12208 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
12209 | m_errorMonitor->VerifyFound(); | ||||
12210 | // Now verify same checks for dst | ||||
12211 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12212 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
12213 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); | ||||
12214 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
12215 | m_errorMonitor->VerifyFound(); | ||||
12216 | // Now cause error due to src image layout changing | ||||
12217 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12218 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12219 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); | ||||
12220 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); | ||||
12221 | m_errorMonitor->VerifyFound(); | ||||
12222 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12223 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12224 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); | ||||
12225 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); | ||||
12226 | m_errorMonitor->VerifyFound(); | ||||
12227 | // Now cause error due to bad image layout transition in PipelineBarrier | ||||
12228 | VkImageMemoryBarrier image_barrier[1] = {}; | ||||
12229 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; | ||||
12230 | image_barrier[0].image = src_image; | ||||
12231 | image_barrier[0].subresourceRange.layerCount = 2; | ||||
12232 | image_barrier[0].subresourceRange.levelCount = 2; | ||||
12233 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
12234 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12235 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12236 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); | ||||
12237 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); | ||||
12238 | m_errorMonitor->VerifyFound(); | ||||
12239 | |||||
12240 | // Finally some layout errors at RenderPass create time | ||||
12241 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. | ||||
12242 | VkAttachmentReference attach = {}; | ||||
12243 | // perf warning for GENERAL layout w/ non-DS input attachment | ||||
12244 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
12245 | VkSubpassDescription subpass = {}; | ||||
12246 | subpass.inputAttachmentCount = 1; | ||||
12247 | subpass.pInputAttachments = &attach; | ||||
12248 | VkRenderPassCreateInfo rpci = {}; | ||||
12249 | rpci.subpassCount = 1; | ||||
12250 | rpci.pSubpasses = &subpass; | ||||
12251 | rpci.attachmentCount = 1; | ||||
12252 | VkAttachmentDescription attach_desc = {}; | ||||
12253 | attach_desc.format = VK_FORMAT_UNDEFINED; | ||||
12254 | rpci.pAttachments = &attach_desc; | ||||
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 12255 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 12256 | VkRenderPass rp; |
12257 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12258 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
12259 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); | ||||
12260 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
12261 | m_errorMonitor->VerifyFound(); | ||||
12262 | // error w/ non-general layout | ||||
12263 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; | ||||
12264 | |||||
12265 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12266 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12267 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); | ||||
12268 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
12269 | m_errorMonitor->VerifyFound(); | ||||
12270 | subpass.inputAttachmentCount = 0; | ||||
12271 | subpass.colorAttachmentCount = 1; | ||||
12272 | subpass.pColorAttachments = &attach; | ||||
12273 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
12274 | // perf warning for GENERAL layout on color attachment | ||||
12275 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12276 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
12277 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); | ||||
12278 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
12279 | m_errorMonitor->VerifyFound(); | ||||
12280 | // error w/ non-color opt or GENERAL layout for color attachment | ||||
12281 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; | ||||
12282 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12283 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12284 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); | ||||
12285 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
12286 | m_errorMonitor->VerifyFound(); | ||||
12287 | subpass.colorAttachmentCount = 0; | ||||
12288 | subpass.pDepthStencilAttachment = &attach; | ||||
12289 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; | ||||
12290 | // perf warning for GENERAL layout on DS attachment | ||||
12291 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12292 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, | ||||
12293 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); | ||||
12294 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
12295 | m_errorMonitor->VerifyFound(); | ||||
12296 | // error w/ non-ds opt or GENERAL layout for color attachment | ||||
12297 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; | ||||
12298 | m_errorMonitor->SetDesiredFailureMsg( | ||||
12299 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12300 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); | ||||
12301 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
12302 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 12303 | // For this error we need a valid renderpass so create default one |
12304 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; | ||||
12305 | attach.attachment = 0; | ||||
12306 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
12307 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
12308 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; | ||||
12309 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; | ||||
12310 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; | ||||
12311 | // Can't do a CLEAR load on READ_ONLY initialLayout | ||||
12312 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; | ||||
12313 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; | ||||
12314 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
12315 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
12316 | " with invalid first layout " | ||||
12317 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" | ||||
12318 | "ONLY_OPTIMAL"); | ||||
12319 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
12320 | m_errorMonitor->VerifyFound(); | ||||
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 12321 | |
12322 | vkDestroyImage(m_device->device(), src_image, NULL); | ||||
12323 | vkDestroyImage(m_device->device(), dst_image, NULL); | ||||
12324 | } | ||||
Tobin Ehlis | d8d8918 | 2016-07-18 20:13:11 -0600 | [diff] [blame] | 12325 | |
12326 | TEST_F(VkLayerTest, ValidRenderPassAttachmentLayoutWithLoadOp) { | ||||
12327 | TEST_DESCRIPTION("Positive test where we create a renderpass with an " | ||||
12328 | "attachment that uses LOAD_OP_CLEAR, the first subpass " | ||||
12329 | "has a valid layout, and a second subpass then uses a " | ||||
12330 | "valid *READ_ONLY* layout."); | ||||
12331 | m_errorMonitor->ExpectSuccess(); | ||||
12332 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12333 | |||||
12334 | VkAttachmentReference attach[2] = {}; | ||||
12335 | attach[0].attachment = 0; | ||||
12336 | attach[0].layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
12337 | attach[1].attachment = 0; | ||||
12338 | attach[1].layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; | ||||
12339 | VkSubpassDescription subpasses[2] = {}; | ||||
12340 | // First subpass clears DS attach on load | ||||
12341 | subpasses[0].pDepthStencilAttachment = &attach[0]; | ||||
12342 | // 2nd subpass reads in DS as input attachment | ||||
12343 | subpasses[1].inputAttachmentCount = 1; | ||||
12344 | subpasses[1].pInputAttachments = &attach[1]; | ||||
12345 | VkAttachmentDescription attach_desc = {}; | ||||
12346 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
12347 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
12348 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; | ||||
12349 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; | ||||
12350 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; | ||||
12351 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; | ||||
12352 | attach_desc.initialLayout = | ||||
12353 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; | ||||
12354 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; | ||||
12355 | VkRenderPassCreateInfo rpci = {}; | ||||
12356 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; | ||||
12357 | rpci.attachmentCount = 1; | ||||
12358 | rpci.pAttachments = &attach_desc; | ||||
12359 | rpci.subpassCount = 2; | ||||
12360 | rpci.pSubpasses = subpasses; | ||||
12361 | |||||
12362 | // Now create RenderPass and verify no errors | ||||
12363 | VkRenderPass rp; | ||||
12364 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); | ||||
12365 | m_errorMonitor->VerifyNotFound(); | ||||
12366 | |||||
12367 | vkDestroyRenderPass(m_device->device(), rp, NULL); | ||||
12368 | } | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 12369 | #endif // DRAW_STATE_TESTS |
12370 | |||||
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 12371 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12372 | #if GTEST_IS_THREADSAFE |
12373 | struct thread_data_struct { | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12374 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12375 | VkEvent event; |
12376 | bool bailout; | ||||
12377 | }; | ||||
12378 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12379 | extern "C" void *AddToCommandBuffer(void *arg) { |
12380 | struct thread_data_struct *data = (struct thread_data_struct *)arg; | ||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12381 | |
Mike Stroyan | a6d1494 | 2016-07-13 15:10:05 -0600 | [diff] [blame] | 12382 | for (int i = 0; i < 80000; i++) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12383 | vkCmdSetEvent(data->commandBuffer, data->event, |
12384 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); | ||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12385 | if (data->bailout) { |
12386 | break; | ||||
12387 | } | ||||
12388 | } | ||||
12389 | return NULL; | ||||
12390 | } | ||||
12391 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12392 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 12393 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12394 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12395 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
12396 | "THREADING ERROR"); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12397 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12398 | ASSERT_NO_FATAL_FAILURE(InitState()); |
12399 | ASSERT_NO_FATAL_FAILURE(InitViewport()); | ||||
12400 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12401 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12402 | // Calls AllocateCommandBuffers |
12403 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); | ||||
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 12404 | |
12405 | // Avoid creating RenderPass | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12406 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12407 | |
12408 | VkEventCreateInfo event_info; | ||||
12409 | VkEvent event; | ||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12410 | VkResult err; |
12411 | |||||
12412 | memset(&event_info, 0, sizeof(event_info)); | ||||
12413 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; | ||||
12414 | |||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12415 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12416 | ASSERT_VK_SUCCESS(err); |
12417 | |||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12418 | err = vkResetEvent(device(), event); |
12419 | ASSERT_VK_SUCCESS(err); | ||||
12420 | |||||
12421 | struct thread_data_struct data; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12422 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12423 | data.event = event; |
12424 | data.bailout = false; | ||||
12425 | m_errorMonitor->SetBailout(&data.bailout); | ||||
Mike Stroyan | a6d1494 | 2016-07-13 15:10:05 -0600 | [diff] [blame] | 12426 | |
12427 | // First do some correct operations using multiple threads. | ||||
12428 | // Add many entries to command buffer from another thread. | ||||
12429 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); | ||||
12430 | // Make non-conflicting calls from this thread at the same time. | ||||
12431 | for (int i = 0; i < 80000; i++) { | ||||
Mike Stroyan | d634390 | 2016-07-14 08:56:16 -0600 | [diff] [blame] | 12432 | uint32_t count; |
12433 | vkEnumeratePhysicalDevices(instance(), &count, NULL); | ||||
Mike Stroyan | a6d1494 | 2016-07-13 15:10:05 -0600 | [diff] [blame] | 12434 | } |
12435 | test_platform_thread_join(thread, NULL); | ||||
12436 | |||||
12437 | // Then do some incorrect operations using multiple threads. | ||||
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12438 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 12439 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12440 | // Add many entries to command buffer from this thread at the same time. |
12441 | AddToCommandBuffer(&data); | ||||
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 12442 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 12443 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12444 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12445 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 12446 | m_errorMonitor->SetBailout(NULL); |
12447 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12448 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12449 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12450 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 12451 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 12452 | #endif // GTEST_IS_THREADSAFE |
12453 | #endif // THREADING_TESTS | ||||
12454 | |||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12455 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12456 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 12457 | TEST_DESCRIPTION("Test that an error is produced for a spirv module " |
12458 | "with an impossible code size"); | ||||
12459 | |||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 12460 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 12461 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12462 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12463 | ASSERT_NO_FATAL_FAILURE(InitState()); |
12464 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12465 | |||||
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12466 | VkShaderModule module; |
12467 | VkShaderModuleCreateInfo moduleCreateInfo; | ||||
12468 | struct icd_spv_header spv; | ||||
12469 | |||||
12470 | spv.magic = ICD_SPV_MAGIC; | ||||
12471 | spv.version = ICD_SPV_VERSION; | ||||
12472 | spv.gen_magic = 0; | ||||
12473 | |||||
12474 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; | ||||
12475 | moduleCreateInfo.pNext = NULL; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12476 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12477 | moduleCreateInfo.codeSize = 4; |
12478 | moduleCreateInfo.flags = 0; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12479 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12480 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12481 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12482 | } |
12483 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12484 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 12485 | TEST_DESCRIPTION("Test that an error is produced for a spirv module " |
12486 | "with a bad magic number"); | ||||
12487 | |||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 12488 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 12489 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12490 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12491 | ASSERT_NO_FATAL_FAILURE(InitState()); |
12492 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12493 | |||||
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12494 | VkShaderModule module; |
12495 | VkShaderModuleCreateInfo moduleCreateInfo; | ||||
12496 | struct icd_spv_header spv; | ||||
12497 | |||||
12498 | spv.magic = ~ICD_SPV_MAGIC; | ||||
12499 | spv.version = ICD_SPV_VERSION; | ||||
12500 | spv.gen_magic = 0; | ||||
12501 | |||||
12502 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; | ||||
12503 | moduleCreateInfo.pNext = NULL; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12504 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12505 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
12506 | moduleCreateInfo.flags = 0; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12507 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12508 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12509 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12510 | } |
12511 | |||||
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 12512 | #if 0 |
12513 | // Not currently covered by SPIRV-Tools validator | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12514 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 12515 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 12516 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12517 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12518 | ASSERT_NO_FATAL_FAILURE(InitState()); |
12519 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12520 | |||||
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12521 | VkShaderModule module; |
12522 | VkShaderModuleCreateInfo moduleCreateInfo; | ||||
12523 | struct icd_spv_header spv; | ||||
12524 | |||||
12525 | spv.magic = ICD_SPV_MAGIC; | ||||
12526 | spv.version = ~ICD_SPV_VERSION; | ||||
12527 | spv.gen_magic = 0; | ||||
12528 | |||||
12529 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; | ||||
12530 | moduleCreateInfo.pNext = NULL; | ||||
12531 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12532 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12533 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
12534 | moduleCreateInfo.flags = 0; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 12535 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12536 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12537 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12538 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 12539 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 12540 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12541 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 12542 | TEST_DESCRIPTION("Test that a warning is produced for a vertex output that " |
12543 | "is not consumed by the fragment stage"); | ||||
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 12544 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12545 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12546 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12547 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 12548 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12549 | |
12550 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12551 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12552 | "\n" |
12553 | "layout(location=0) out float x;\n" | ||||
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12554 | "out gl_PerVertex {\n" |
12555 | " vec4 gl_Position;\n" | ||||
12556 | "};\n" | ||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12557 | "void main(){\n" |
12558 | " gl_Position = vec4(1);\n" | ||||
12559 | " x = 0;\n" | ||||
12560 | "}\n"; | ||||
12561 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12562 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12563 | "\n" |
12564 | "layout(location=0) out vec4 color;\n" | ||||
12565 | "void main(){\n" | ||||
12566 | " color = vec4(1);\n" | ||||
12567 | "}\n"; | ||||
12568 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 12569 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
12570 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12571 | |
12572 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 12573 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12574 | pipe.AddShader(&vs); |
12575 | pipe.AddShader(&fs); | ||||
12576 | |||||
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12577 | VkDescriptorSetObj descriptorSet(m_device); |
12578 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12579 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12580 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 12581 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12582 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12583 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12584 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 12585 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12586 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 12587 | TEST_DESCRIPTION("Test that an error is produced for a fragment shader input " |
12588 | "which is not present in the outputs of the previous stage"); | ||||
12589 | |||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 12590 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12591 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12592 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 12593 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 12594 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 12595 | |
12596 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12597 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 12598 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12599 | "out gl_PerVertex {\n" |
12600 | " vec4 gl_Position;\n" | ||||
12601 | "};\n" | ||||
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 12602 | "void main(){\n" |
12603 | " gl_Position = vec4(1);\n" | ||||
12604 | "}\n"; | ||||
12605 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12606 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 12607 | "\n" |
12608 | "layout(location=0) in float x;\n" | ||||
12609 | "layout(location=0) out vec4 color;\n" | ||||
12610 | "void main(){\n" | ||||
12611 | " color = vec4(x);\n" | ||||
12612 | "}\n"; | ||||
12613 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 12614 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
12615 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 12616 | |
12617 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 12618 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 12619 | pipe.AddShader(&vs); |
12620 | pipe.AddShader(&fs); | ||||
12621 | |||||
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 12622 | VkDescriptorSetObj descriptorSet(m_device); |
12623 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12624 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 12625 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 12626 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 12627 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12628 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 12629 | } |
12630 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12631 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 12632 | TEST_DESCRIPTION("Test that an error is produced for a fragment shader input " |
12633 | "within an interace block, which is not present in the outputs " | ||||
12634 | "of the previous stage."); | ||||
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 12635 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12636 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 12637 | |
12638 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12639 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12640 | |||||
12641 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12642 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 12643 | "\n" |
12644 | "out gl_PerVertex {\n" | ||||
12645 | " vec4 gl_Position;\n" | ||||
12646 | "};\n" | ||||
12647 | "void main(){\n" | ||||
12648 | " gl_Position = vec4(1);\n" | ||||
12649 | "}\n"; | ||||
12650 | char const *fsSource = | ||||
12651 | "#version 450\n" | ||||
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 12652 | "\n" |
12653 | "in block { layout(location=0) float x; } ins;\n" | ||||
12654 | "layout(location=0) out vec4 color;\n" | ||||
12655 | "void main(){\n" | ||||
12656 | " color = vec4(ins.x);\n" | ||||
12657 | "}\n"; | ||||
12658 | |||||
12659 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12660 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12661 | |||||
12662 | VkPipelineObj pipe(m_device); | ||||
12663 | pipe.AddColorAttachment(); | ||||
12664 | pipe.AddShader(&vs); | ||||
12665 | pipe.AddShader(&fs); | ||||
12666 | |||||
12667 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12668 | descriptorSet.AppendDummy(); | ||||
12669 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12670 | |||||
12671 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12672 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12673 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 12674 | } |
12675 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12676 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 12677 | TEST_DESCRIPTION("Test that an error is produced for mismatched array sizes " |
12678 | "across the VS->FS interface"); | ||||
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 12679 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 12680 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12681 | "output arr[2] of float32' vs 'ptr to " |
12682 | "input arr[3] of float32'"); | ||||
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 12683 | |
12684 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12685 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12686 | |||||
12687 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12688 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 12689 | "\n" |
12690 | "layout(location=0) out float x[2];\n" | ||||
12691 | "out gl_PerVertex {\n" | ||||
12692 | " vec4 gl_Position;\n" | ||||
12693 | "};\n" | ||||
12694 | "void main(){\n" | ||||
12695 | " x[0] = 0; x[1] = 0;\n" | ||||
12696 | " gl_Position = vec4(1);\n" | ||||
12697 | "}\n"; | ||||
12698 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12699 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 12700 | "\n" |
12701 | "layout(location=0) in float x[3];\n" | ||||
12702 | "layout(location=0) out vec4 color;\n" | ||||
12703 | "void main(){\n" | ||||
12704 | " color = vec4(x[0] + x[1] + x[2]);\n" | ||||
12705 | "}\n"; | ||||
12706 | |||||
12707 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12708 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12709 | |||||
12710 | VkPipelineObj pipe(m_device); | ||||
12711 | pipe.AddColorAttachment(); | ||||
12712 | pipe.AddShader(&vs); | ||||
12713 | pipe.AddShader(&fs); | ||||
12714 | |||||
12715 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12716 | descriptorSet.AppendDummy(); | ||||
12717 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12718 | |||||
12719 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12720 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12721 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 12722 | } |
12723 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12724 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 12725 | TEST_DESCRIPTION("Test that an error is produced for mismatched types across " |
12726 | "the VS->FS interface"); | ||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 12727 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12728 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12729 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 12730 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 12731 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 12732 | |
12733 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12734 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 12735 | "\n" |
12736 | "layout(location=0) out int x;\n" | ||||
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12737 | "out gl_PerVertex {\n" |
12738 | " vec4 gl_Position;\n" | ||||
12739 | "};\n" | ||||
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 12740 | "void main(){\n" |
12741 | " x = 0;\n" | ||||
12742 | " gl_Position = vec4(1);\n" | ||||
12743 | "}\n"; | ||||
12744 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12745 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 12746 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12747 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 12748 | "layout(location=0) out vec4 color;\n" |
12749 | "void main(){\n" | ||||
12750 | " color = vec4(x);\n" | ||||
12751 | "}\n"; | ||||
12752 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 12753 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
12754 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 12755 | |
12756 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 12757 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 12758 | pipe.AddShader(&vs); |
12759 | pipe.AddShader(&fs); | ||||
12760 | |||||
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 12761 | VkDescriptorSetObj descriptorSet(m_device); |
12762 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12763 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 12764 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 12765 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 12766 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12767 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 12768 | } |
12769 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12770 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 12771 | TEST_DESCRIPTION("Test that an error is produced for mismatched types across " |
12772 | "the VS->FS interface, when the variable is contained within " | ||||
12773 | "an interface block"); | ||||
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 12774 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12775 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 12776 | |
12777 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12778 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12779 | |||||
12780 | char const *vsSource = | ||||
12781 | "#version 450\n" | ||||
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 12782 | "\n" |
12783 | "out block { layout(location=0) int x; } outs;\n" | ||||
12784 | "out gl_PerVertex {\n" | ||||
12785 | " vec4 gl_Position;\n" | ||||
12786 | "};\n" | ||||
12787 | "void main(){\n" | ||||
12788 | " outs.x = 0;\n" | ||||
12789 | " gl_Position = vec4(1);\n" | ||||
12790 | "}\n"; | ||||
12791 | char const *fsSource = | ||||
12792 | "#version 450\n" | ||||
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 12793 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12794 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 12795 | "layout(location=0) out vec4 color;\n" |
12796 | "void main(){\n" | ||||
12797 | " color = vec4(ins.x);\n" | ||||
12798 | "}\n"; | ||||
12799 | |||||
12800 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12801 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12802 | |||||
12803 | VkPipelineObj pipe(m_device); | ||||
12804 | pipe.AddColorAttachment(); | ||||
12805 | pipe.AddShader(&vs); | ||||
12806 | pipe.AddShader(&fs); | ||||
12807 | |||||
12808 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12809 | descriptorSet.AppendDummy(); | ||||
12810 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12811 | |||||
12812 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12813 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12814 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 12815 | } |
12816 | |||||
12817 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { | ||||
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 12818 | TEST_DESCRIPTION("Test that an error is produced for location mismatches across " |
12819 | "the VS->FS interface; This should manifest as a not-written/not-consumed " | ||||
12820 | "pair, but flushes out broken walking of the interfaces"); | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 12821 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
12822 | "location 0.0 which is not written by vertex shader"); | ||||
12823 | |||||
12824 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12825 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12826 | |||||
12827 | char const *vsSource = | ||||
12828 | "#version 450\n" | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 12829 | "\n" |
12830 | "out block { layout(location=1) float x; } outs;\n" | ||||
12831 | "out gl_PerVertex {\n" | ||||
12832 | " vec4 gl_Position;\n" | ||||
12833 | "};\n" | ||||
12834 | "void main(){\n" | ||||
12835 | " outs.x = 0;\n" | ||||
12836 | " gl_Position = vec4(1);\n" | ||||
12837 | "}\n"; | ||||
12838 | char const *fsSource = | ||||
12839 | "#version 450\n" | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 12840 | "\n" |
12841 | "in block { layout(location=0) float x; } ins;\n" | ||||
12842 | "layout(location=0) out vec4 color;\n" | ||||
12843 | "void main(){\n" | ||||
12844 | " color = vec4(ins.x);\n" | ||||
12845 | "}\n"; | ||||
12846 | |||||
12847 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12848 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12849 | |||||
12850 | VkPipelineObj pipe(m_device); | ||||
12851 | pipe.AddColorAttachment(); | ||||
12852 | pipe.AddShader(&vs); | ||||
12853 | pipe.AddShader(&fs); | ||||
12854 | |||||
12855 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12856 | descriptorSet.AppendDummy(); | ||||
12857 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12858 | |||||
12859 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12860 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12861 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 12862 | } |
12863 | |||||
12864 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { | ||||
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 12865 | TEST_DESCRIPTION("Test that an error is produced for component mismatches across the " |
12866 | "VS->FS interface. It's not enough to have the same set of locations in " | ||||
12867 | "use; matching is defined in terms of spirv variables."); | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 12868 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
12869 | "location 0.1 which is not written by vertex shader"); | ||||
12870 | |||||
12871 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12872 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12873 | |||||
12874 | char const *vsSource = | ||||
12875 | "#version 450\n" | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 12876 | "\n" |
12877 | "out block { layout(location=0, component=0) float x; } outs;\n" | ||||
12878 | "out gl_PerVertex {\n" | ||||
12879 | " vec4 gl_Position;\n" | ||||
12880 | "};\n" | ||||
12881 | "void main(){\n" | ||||
12882 | " outs.x = 0;\n" | ||||
12883 | " gl_Position = vec4(1);\n" | ||||
12884 | "}\n"; | ||||
12885 | char const *fsSource = | ||||
12886 | "#version 450\n" | ||||
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 12887 | "\n" |
12888 | "in block { layout(location=0, component=1) float x; } ins;\n" | ||||
12889 | "layout(location=0) out vec4 color;\n" | ||||
12890 | "void main(){\n" | ||||
12891 | " color = vec4(ins.x);\n" | ||||
12892 | "}\n"; | ||||
12893 | |||||
12894 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12895 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
12896 | |||||
12897 | VkPipelineObj pipe(m_device); | ||||
12898 | pipe.AddColorAttachment(); | ||||
12899 | pipe.AddShader(&vs); | ||||
12900 | pipe.AddShader(&fs); | ||||
12901 | |||||
12902 | VkDescriptorSetObj descriptorSet(m_device); | ||||
12903 | descriptorSet.AppendDummy(); | ||||
12904 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
12905 | |||||
12906 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
12907 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12908 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 12909 | } |
12910 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12911 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 12912 | TEST_DESCRIPTION("Test that a warning is produced for a vertex attribute which is " |
12913 | "not consumed by the vertex shader"); | ||||
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 12914 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12915 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 12916 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12917 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 12918 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12919 | |
12920 | VkVertexInputBindingDescription input_binding; | ||||
12921 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
12922 | |||||
12923 | VkVertexInputAttributeDescription input_attrib; | ||||
12924 | memset(&input_attrib, 0, sizeof(input_attrib)); | ||||
12925 | input_attrib.format = VK_FORMAT_R32_SFLOAT; | ||||
12926 | |||||
12927 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12928 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12929 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 12930 | "out gl_PerVertex {\n" |
12931 | " vec4 gl_Position;\n" | ||||
12932 | "};\n" | ||||
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12933 | "void main(){\n" |
12934 | " gl_Position = vec4(1);\n" | ||||
12935 | "}\n"; | ||||
12936 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12937 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12938 | "\n" |
12939 | "layout(location=0) out vec4 color;\n" | ||||
12940 | "void main(){\n" | ||||
12941 | " color = vec4(1);\n" | ||||
12942 | "}\n"; | ||||
12943 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 12944 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
12945 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12946 | |
12947 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 12948 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12949 | pipe.AddShader(&vs); |
12950 | pipe.AddShader(&fs); | ||||
12951 | |||||
12952 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
12953 | pipe.AddVertexInputAttribs(&input_attrib, 1); | ||||
12954 | |||||
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12955 | VkDescriptorSetObj descriptorSet(m_device); |
12956 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 12957 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12958 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 12959 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12960 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 12961 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 12962 | } |
12963 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12964 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 12965 | TEST_DESCRIPTION("Test that a warning is produced for a location mismatch on " |
12966 | "vertex attributes. This flushes out bad behavior in the interface walker"); | ||||
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 12967 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12968 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 12969 | |
12970 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
12971 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
12972 | |||||
12973 | VkVertexInputBindingDescription input_binding; | ||||
12974 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
12975 | |||||
12976 | VkVertexInputAttributeDescription input_attrib; | ||||
12977 | memset(&input_attrib, 0, sizeof(input_attrib)); | ||||
12978 | input_attrib.format = VK_FORMAT_R32_SFLOAT; | ||||
12979 | |||||
12980 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12981 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 12982 | "\n" |
12983 | "layout(location=1) in float x;\n" | ||||
12984 | "out gl_PerVertex {\n" | ||||
12985 | " vec4 gl_Position;\n" | ||||
12986 | "};\n" | ||||
12987 | "void main(){\n" | ||||
12988 | " gl_Position = vec4(x);\n" | ||||
12989 | "}\n"; | ||||
12990 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 12991 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 12992 | "\n" |
12993 | "layout(location=0) out vec4 color;\n" | ||||
12994 | "void main(){\n" | ||||
12995 | " color = vec4(1);\n" | ||||
12996 | "}\n"; | ||||
12997 | |||||
12998 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
12999 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13000 | |||||
13001 | VkPipelineObj pipe(m_device); | ||||
13002 | pipe.AddColorAttachment(); | ||||
13003 | pipe.AddShader(&vs); | ||||
13004 | pipe.AddShader(&fs); | ||||
13005 | |||||
13006 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
13007 | pipe.AddVertexInputAttribs(&input_attrib, 1); | ||||
13008 | |||||
13009 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13010 | descriptorSet.AppendDummy(); | ||||
13011 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13012 | |||||
13013 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13014 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13015 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 13016 | } |
13017 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13018 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13019 | TEST_DESCRIPTION("Test that an error is produced for a VS input which is not " |
13020 | "provided by a vertex attribute"); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13021 | m_errorMonitor->SetDesiredFailureMsg( |
13022 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13023 | "VS consumes input at location 0 but not provided"); |
13024 | |||||
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 13025 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 13026 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 13027 | |
13028 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13029 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 13030 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13031 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 13032 | "out gl_PerVertex {\n" |
13033 | " vec4 gl_Position;\n" | ||||
13034 | "};\n" | ||||
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 13035 | "void main(){\n" |
13036 | " gl_Position = x;\n" | ||||
13037 | "}\n"; | ||||
13038 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13039 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 13040 | "\n" |
13041 | "layout(location=0) out vec4 color;\n" | ||||
13042 | "void main(){\n" | ||||
13043 | " color = vec4(1);\n" | ||||
13044 | "}\n"; | ||||
13045 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 13046 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
13047 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 13048 | |
13049 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 13050 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 13051 | pipe.AddShader(&vs); |
13052 | pipe.AddShader(&fs); | ||||
13053 | |||||
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 13054 | VkDescriptorSetObj descriptorSet(m_device); |
13055 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13056 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 13057 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 13058 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 13059 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13060 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 13061 | } |
13062 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13063 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13064 | TEST_DESCRIPTION("Test that an error is produced for a mismatch between the " |
13065 | "fundamental type (float/int/uint) of an attribute and the " | ||||
13066 | "VS input that consumes it"); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13067 | m_errorMonitor->SetDesiredFailureMsg( |
13068 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13069 | "location 0 does not match VS input type"); |
13070 | |||||
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 13071 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 13072 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 13073 | |
13074 | VkVertexInputBindingDescription input_binding; | ||||
13075 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
13076 | |||||
13077 | VkVertexInputAttributeDescription input_attrib; | ||||
13078 | memset(&input_attrib, 0, sizeof(input_attrib)); | ||||
13079 | input_attrib.format = VK_FORMAT_R32_SFLOAT; | ||||
13080 | |||||
13081 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13082 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 13083 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13084 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 13085 | "out gl_PerVertex {\n" |
13086 | " vec4 gl_Position;\n" | ||||
13087 | "};\n" | ||||
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 13088 | "void main(){\n" |
13089 | " gl_Position = vec4(x);\n" | ||||
13090 | "}\n"; | ||||
13091 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13092 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 13093 | "\n" |
13094 | "layout(location=0) out vec4 color;\n" | ||||
13095 | "void main(){\n" | ||||
13096 | " color = vec4(1);\n" | ||||
13097 | "}\n"; | ||||
13098 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 13099 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
13100 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 13101 | |
13102 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 13103 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 13104 | pipe.AddShader(&vs); |
13105 | pipe.AddShader(&fs); | ||||
13106 | |||||
13107 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
13108 | pipe.AddVertexInputAttribs(&input_attrib, 1); | ||||
13109 | |||||
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 13110 | VkDescriptorSetObj descriptorSet(m_device); |
13111 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13112 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 13113 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 13114 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 13115 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13116 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 13117 | } |
13118 | |||||
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 13119 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13120 | TEST_DESCRIPTION("Test that an error is produced for a pipeline containing multiple " |
13121 | "shaders for the same stage"); | ||||
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 13122 | m_errorMonitor->SetDesiredFailureMsg( |
13123 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
13124 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); | ||||
13125 | |||||
13126 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13127 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13128 | |||||
13129 | char const *vsSource = | ||||
13130 | "#version 450\n" | ||||
13131 | "\n" | ||||
13132 | "out gl_PerVertex {\n" | ||||
13133 | " vec4 gl_Position;\n" | ||||
13134 | "};\n" | ||||
13135 | "void main(){\n" | ||||
13136 | " gl_Position = vec4(1);\n" | ||||
13137 | "}\n"; | ||||
13138 | char const *fsSource = | ||||
13139 | "#version 450\n" | ||||
13140 | "\n" | ||||
13141 | "layout(location=0) out vec4 color;\n" | ||||
13142 | "void main(){\n" | ||||
13143 | " color = vec4(1);\n" | ||||
13144 | "}\n"; | ||||
13145 | |||||
13146 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
13147 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13148 | |||||
13149 | VkPipelineObj pipe(m_device); | ||||
13150 | pipe.AddColorAttachment(); | ||||
13151 | pipe.AddShader(&vs); | ||||
13152 | pipe.AddShader(&vs); | ||||
13153 | pipe.AddShader(&fs); | ||||
13154 | |||||
13155 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13156 | descriptorSet.AppendDummy(); | ||||
13157 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13158 | |||||
13159 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13160 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13161 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 13162 | } |
13163 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13164 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13165 | TEST_DESCRIPTION("Test that pipeline validation accepts matrices passed " |
13166 | "as vertex attributes"); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13167 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 13168 | |
13169 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13170 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13171 | |||||
13172 | VkVertexInputBindingDescription input_binding; | ||||
13173 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
13174 | |||||
13175 | VkVertexInputAttributeDescription input_attribs[2]; | ||||
13176 | memset(input_attribs, 0, sizeof(input_attribs)); | ||||
13177 | |||||
13178 | for (int i = 0; i < 2; i++) { | ||||
13179 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; | ||||
13180 | input_attribs[i].location = i; | ||||
13181 | } | ||||
13182 | |||||
13183 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13184 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 13185 | "\n" |
13186 | "layout(location=0) in mat2x4 x;\n" | ||||
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 13187 | "out gl_PerVertex {\n" |
13188 | " vec4 gl_Position;\n" | ||||
13189 | "};\n" | ||||
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 13190 | "void main(){\n" |
13191 | " gl_Position = x[0] + x[1];\n" | ||||
13192 | "}\n"; | ||||
13193 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13194 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 13195 | "\n" |
13196 | "layout(location=0) out vec4 color;\n" | ||||
13197 | "void main(){\n" | ||||
13198 | " color = vec4(1);\n" | ||||
13199 | "}\n"; | ||||
13200 | |||||
13201 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
13202 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13203 | |||||
13204 | VkPipelineObj pipe(m_device); | ||||
13205 | pipe.AddColorAttachment(); | ||||
13206 | pipe.AddShader(&vs); | ||||
13207 | pipe.AddShader(&fs); | ||||
13208 | |||||
13209 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
13210 | pipe.AddVertexInputAttribs(input_attribs, 2); | ||||
13211 | |||||
13212 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13213 | descriptorSet.AppendDummy(); | ||||
13214 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13215 | |||||
13216 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13217 | |||||
13218 | /* expect success */ | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13219 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 13220 | } |
13221 | |||||
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 13222 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
13223 | { | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13224 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 13225 | |
13226 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13227 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13228 | |||||
13229 | VkVertexInputBindingDescription input_binding; | ||||
13230 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
13231 | |||||
13232 | VkVertexInputAttributeDescription input_attribs[2]; | ||||
13233 | memset(input_attribs, 0, sizeof(input_attribs)); | ||||
13234 | |||||
13235 | for (int i = 0; i < 2; i++) { | ||||
13236 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; | ||||
13237 | input_attribs[i].location = i; | ||||
13238 | } | ||||
13239 | |||||
13240 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13241 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 13242 | "\n" |
13243 | "layout(location=0) in vec4 x[2];\n" | ||||
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 13244 | "out gl_PerVertex {\n" |
13245 | " vec4 gl_Position;\n" | ||||
13246 | "};\n" | ||||
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 13247 | "void main(){\n" |
13248 | " gl_Position = x[0] + x[1];\n" | ||||
13249 | "}\n"; | ||||
13250 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13251 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 13252 | "\n" |
13253 | "layout(location=0) out vec4 color;\n" | ||||
13254 | "void main(){\n" | ||||
13255 | " color = vec4(1);\n" | ||||
13256 | "}\n"; | ||||
13257 | |||||
13258 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
13259 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13260 | |||||
13261 | VkPipelineObj pipe(m_device); | ||||
13262 | pipe.AddColorAttachment(); | ||||
13263 | pipe.AddShader(&vs); | ||||
13264 | pipe.AddShader(&fs); | ||||
13265 | |||||
13266 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
13267 | pipe.AddVertexInputAttribs(input_attribs, 2); | ||||
13268 | |||||
13269 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13270 | descriptorSet.AppendDummy(); | ||||
13271 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13272 | |||||
13273 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13274 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13275 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 13276 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 13277 | |
Chris Forbes | bc290ce | 2016-07-06 12:01:49 +1200 | [diff] [blame] | 13278 | TEST_F(VkLayerTest, CreatePipelineAttribComponents) |
13279 | { | ||||
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13280 | TEST_DESCRIPTION("Test that pipeline validation accepts consuming a vertex attribute " |
13281 | "through multiple VS inputs, each consuming a different subset of the " | ||||
13282 | "components."); | ||||
Chris Forbes | bc290ce | 2016-07-06 12:01:49 +1200 | [diff] [blame] | 13283 | m_errorMonitor->ExpectSuccess(); |
13284 | |||||
13285 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13286 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13287 | |||||
13288 | VkVertexInputBindingDescription input_binding; | ||||
13289 | memset(&input_binding, 0, sizeof(input_binding)); | ||||
13290 | |||||
13291 | VkVertexInputAttributeDescription input_attribs[3]; | ||||
13292 | memset(input_attribs, 0, sizeof(input_attribs)); | ||||
13293 | |||||
13294 | for (int i = 0; i < 3; i++) { | ||||
13295 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; | ||||
13296 | input_attribs[i].location = i; | ||||
13297 | } | ||||
13298 | |||||
13299 | char const *vsSource = | ||||
13300 | "#version 450\n" | ||||
13301 | "\n" | ||||
13302 | "layout(location=0) in vec4 x;\n" | ||||
13303 | "layout(location=1) in vec3 y1;\n" | ||||
13304 | "layout(location=1, component=3) in float y2;\n" | ||||
13305 | "layout(location=2) in vec4 z;\n" | ||||
13306 | "out gl_PerVertex {\n" | ||||
13307 | " vec4 gl_Position;\n" | ||||
13308 | "};\n" | ||||
13309 | "void main(){\n" | ||||
13310 | " gl_Position = x + vec4(y1, y2) + z;\n" | ||||
13311 | "}\n"; | ||||
13312 | char const *fsSource = | ||||
13313 | "#version 450\n" | ||||
13314 | "\n" | ||||
13315 | "layout(location=0) out vec4 color;\n" | ||||
13316 | "void main(){\n" | ||||
13317 | " color = vec4(1);\n" | ||||
13318 | "}\n"; | ||||
13319 | |||||
13320 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
13321 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13322 | |||||
13323 | VkPipelineObj pipe(m_device); | ||||
13324 | pipe.AddColorAttachment(); | ||||
13325 | pipe.AddShader(&vs); | ||||
13326 | pipe.AddShader(&fs); | ||||
13327 | |||||
13328 | pipe.AddVertexInputBindings(&input_binding, 1); | ||||
13329 | pipe.AddVertexInputAttribs(input_attribs, 3); | ||||
13330 | |||||
13331 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13332 | descriptorSet.AppendDummy(); | ||||
13333 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13334 | |||||
13335 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13336 | |||||
13337 | m_errorMonitor->VerifyNotFound(); | ||||
13338 | } | ||||
13339 | |||||
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 13340 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
13341 | { | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13342 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 13343 | |
13344 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13345 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13346 | |||||
13347 | char const *vsSource = | ||||
13348 | "#version 450\n" | ||||
13349 | "out gl_PerVertex {\n" | ||||
13350 | " vec4 gl_Position;\n" | ||||
13351 | "};\n" | ||||
13352 | "void main(){\n" | ||||
13353 | " gl_Position = vec4(0);\n" | ||||
13354 | "}\n"; | ||||
13355 | char const *fsSource = | ||||
13356 | "#version 450\n" | ||||
13357 | "\n" | ||||
13358 | "layout(location=0) out vec4 color;\n" | ||||
13359 | "void main(){\n" | ||||
13360 | " color = vec4(1);\n" | ||||
13361 | "}\n"; | ||||
13362 | |||||
13363 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
13364 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13365 | |||||
13366 | VkPipelineObj pipe(m_device); | ||||
13367 | pipe.AddColorAttachment(); | ||||
13368 | pipe.AddShader(&vs); | ||||
13369 | pipe.AddShader(&fs); | ||||
13370 | |||||
13371 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13372 | descriptorSet.AppendDummy(); | ||||
13373 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13374 | |||||
13375 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13376 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13377 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 13378 | } |
13379 | |||||
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 13380 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
13381 | { | ||||
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13382 | TEST_DESCRIPTION("Test that pipeline validation accepts the relaxed type matching rules " |
13383 | "set out in 14.1.3: fundamental type must match, and producer side must " | ||||
13384 | "have at least as many components"); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13385 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 13386 | |
13387 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block | ||||
13388 | |||||
13389 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13390 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13391 | |||||
13392 | char const *vsSource = | ||||
13393 | "#version 450\n" | ||||
13394 | "out gl_PerVertex {\n" | ||||
13395 | " vec4 gl_Position;\n" | ||||
13396 | "};\n" | ||||
13397 | "layout(location=0) out vec3 x;\n" | ||||
13398 | "layout(location=1) out ivec3 y;\n" | ||||
13399 | "layout(location=2) out vec3 z;\n" | ||||
13400 | "void main(){\n" | ||||
13401 | " gl_Position = vec4(0);\n" | ||||
13402 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" | ||||
13403 | "}\n"; | ||||
13404 | char const *fsSource = | ||||
13405 | "#version 450\n" | ||||
13406 | "\n" | ||||
13407 | "layout(location=0) out vec4 color;\n" | ||||
13408 | "layout(location=0) in float x;\n" | ||||
13409 | "layout(location=1) flat in int y;\n" | ||||
13410 | "layout(location=2) in vec2 z;\n" | ||||
13411 | "void main(){\n" | ||||
13412 | " color = vec4(1 + x + y + z.x);\n" | ||||
13413 | "}\n"; | ||||
13414 | |||||
13415 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
13416 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13417 | |||||
13418 | VkPipelineObj pipe(m_device); | ||||
13419 | pipe.AddColorAttachment(); | ||||
13420 | pipe.AddShader(&vs); | ||||
13421 | pipe.AddShader(&fs); | ||||
13422 | |||||
13423 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13424 | descriptorSet.AppendDummy(); | ||||
13425 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13426 | |||||
Mike Stroyan | 255e958 | 2016-06-24 09:49:32 -0600 | [diff] [blame] | 13427 | VkResult err = VK_SUCCESS; |
13428 | err = | ||||
13429 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13430 | ASSERT_VK_SUCCESS(err); | ||||
13431 | |||||
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 13432 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13433 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 13434 | } |
13435 | |||||
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 13436 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
13437 | { | ||||
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13438 | TEST_DESCRIPTION("Test that pipeline validation accepts per-vertex variables " |
13439 | "passed between the TCS and TES stages"); | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13440 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 13441 | |
13442 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13443 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13444 | |||||
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 13445 | if (!m_device->phy().features().tessellationShader) { |
13446 | printf("Device does not support tessellation shaders; skipped.\n"); | ||||
13447 | return; | ||||
13448 | } | ||||
13449 | |||||
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 13450 | char const *vsSource = |
13451 | "#version 450\n" | ||||
13452 | "void main(){}\n"; | ||||
13453 | char const *tcsSource = | ||||
13454 | "#version 450\n" | ||||
13455 | "layout(location=0) out int x[];\n" | ||||
13456 | "layout(vertices=3) out;\n" | ||||
13457 | "void main(){\n" | ||||
13458 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" | ||||
13459 | " gl_TessLevelInner[0] = 1;\n" | ||||
13460 | " x[gl_InvocationID] = gl_InvocationID;\n" | ||||
13461 | "}\n"; | ||||
13462 | char const *tesSource = | ||||
13463 | "#version 450\n" | ||||
13464 | "layout(triangles, equal_spacing, cw) in;\n" | ||||
13465 | "layout(location=0) in int x[];\n" | ||||
13466 | "out gl_PerVertex { vec4 gl_Position; };\n" | ||||
13467 | "void main(){\n" | ||||
13468 | " gl_Position.xyz = gl_TessCoord;\n" | ||||
13469 | " gl_Position.w = x[0] + x[1] + x[2];\n" | ||||
13470 | "}\n"; | ||||
13471 | char const *fsSource = | ||||
13472 | "#version 450\n" | ||||
13473 | "layout(location=0) out vec4 color;\n" | ||||
13474 | "void main(){\n" | ||||
13475 | " color = vec4(1);\n" | ||||
13476 | "}\n"; | ||||
13477 | |||||
13478 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
13479 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); | ||||
13480 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); | ||||
13481 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13482 | |||||
13483 | VkPipelineInputAssemblyStateCreateInfo iasci{ | ||||
13484 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, | ||||
13485 | nullptr, | ||||
13486 | 0, | ||||
13487 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, | ||||
13488 | VK_FALSE}; | ||||
13489 | |||||
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 13490 | VkPipelineTessellationStateCreateInfo tsci{ |
13491 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, | ||||
13492 | nullptr, | ||||
13493 | 0, | ||||
13494 | 3}; | ||||
13495 | |||||
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 13496 | VkPipelineObj pipe(m_device); |
13497 | pipe.SetInputAssembly(&iasci); | ||||
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 13498 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 13499 | pipe.AddColorAttachment(); |
13500 | pipe.AddShader(&vs); | ||||
13501 | pipe.AddShader(&tcs); | ||||
13502 | pipe.AddShader(&tes); | ||||
13503 | pipe.AddShader(&fs); | ||||
13504 | |||||
13505 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13506 | descriptorSet.AppendDummy(); | ||||
13507 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13508 | |||||
13509 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13510 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13511 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 13512 | } |
13513 | |||||
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 13514 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
13515 | { | ||||
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13516 | TEST_DESCRIPTION("Test that pipeline validation accepts a user-defined " |
13517 | "interface block passed into the geometry shader. This " | ||||
13518 | "is interesting because the 'extra' array level is not " | ||||
13519 | "present on the member type, but on the block instance."); | ||||
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 13520 | m_errorMonitor->ExpectSuccess(); |
13521 | |||||
13522 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13523 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13524 | |||||
13525 | if (!m_device->phy().features().geometryShader) { | ||||
13526 | printf("Device does not support geometry shaders; skipped.\n"); | ||||
13527 | return; | ||||
13528 | } | ||||
13529 | |||||
13530 | char const *vsSource = | ||||
13531 | "#version 450\n" | ||||
13532 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" | ||||
13533 | "void main(){\n" | ||||
13534 | " vs_out.x = vec4(1);\n" | ||||
13535 | "}\n"; | ||||
13536 | char const *gsSource = | ||||
13537 | "#version 450\n" | ||||
13538 | "layout(triangles) in;\n" | ||||
13539 | "layout(triangle_strip, max_vertices=3) out;\n" | ||||
13540 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" | ||||
13541 | "out gl_PerVertex { vec4 gl_Position; };\n" | ||||
13542 | "void main() {\n" | ||||
13543 | " gl_Position = gs_in[0].x;\n" | ||||
13544 | " EmitVertex();\n" | ||||
13545 | "}\n"; | ||||
13546 | char const *fsSource = | ||||
13547 | "#version 450\n" | ||||
13548 | "layout(location=0) out vec4 color;\n" | ||||
13549 | "void main(){\n" | ||||
13550 | " color = vec4(1);\n" | ||||
13551 | "}\n"; | ||||
13552 | |||||
13553 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
13554 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); | ||||
13555 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13556 | |||||
13557 | VkPipelineObj pipe(m_device); | ||||
13558 | pipe.AddColorAttachment(); | ||||
13559 | pipe.AddShader(&vs); | ||||
13560 | pipe.AddShader(&gs); | ||||
13561 | pipe.AddShader(&fs); | ||||
13562 | |||||
13563 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13564 | descriptorSet.AppendDummy(); | ||||
13565 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13566 | |||||
13567 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13568 | |||||
13569 | m_errorMonitor->VerifyNotFound(); | ||||
13570 | } | ||||
13571 | |||||
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 13572 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
13573 | { | ||||
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13574 | TEST_DESCRIPTION("Test that an error is produced for a variable output from " |
13575 | "the TCS without the patch decoration, but consumed in the TES " | ||||
13576 | "with the decoration."); | ||||
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 13577 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
13578 | "is per-vertex in tessellation control shader stage " | ||||
13579 | "but per-patch in tessellation evaluation shader stage"); | ||||
13580 | |||||
13581 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13582 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13583 | |||||
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 13584 | if (!m_device->phy().features().tessellationShader) { |
13585 | printf("Device does not support tessellation shaders; skipped.\n"); | ||||
13586 | return; | ||||
13587 | } | ||||
13588 | |||||
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 13589 | char const *vsSource = |
13590 | "#version 450\n" | ||||
13591 | "void main(){}\n"; | ||||
13592 | char const *tcsSource = | ||||
13593 | "#version 450\n" | ||||
13594 | "layout(location=0) out int x[];\n" | ||||
13595 | "layout(vertices=3) out;\n" | ||||
13596 | "void main(){\n" | ||||
13597 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" | ||||
13598 | " gl_TessLevelInner[0] = 1;\n" | ||||
13599 | " x[gl_InvocationID] = gl_InvocationID;\n" | ||||
13600 | "}\n"; | ||||
13601 | char const *tesSource = | ||||
13602 | "#version 450\n" | ||||
13603 | "layout(triangles, equal_spacing, cw) in;\n" | ||||
13604 | "layout(location=0) patch in int x;\n" | ||||
13605 | "out gl_PerVertex { vec4 gl_Position; };\n" | ||||
13606 | "void main(){\n" | ||||
13607 | " gl_Position.xyz = gl_TessCoord;\n" | ||||
13608 | " gl_Position.w = x;\n" | ||||
13609 | "}\n"; | ||||
13610 | char const *fsSource = | ||||
13611 | "#version 450\n" | ||||
13612 | "layout(location=0) out vec4 color;\n" | ||||
13613 | "void main(){\n" | ||||
13614 | " color = vec4(1);\n" | ||||
13615 | "}\n"; | ||||
13616 | |||||
13617 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
13618 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); | ||||
13619 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); | ||||
13620 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13621 | |||||
13622 | VkPipelineInputAssemblyStateCreateInfo iasci{ | ||||
13623 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, | ||||
13624 | nullptr, | ||||
13625 | 0, | ||||
13626 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, | ||||
13627 | VK_FALSE}; | ||||
13628 | |||||
13629 | VkPipelineTessellationStateCreateInfo tsci{ | ||||
13630 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, | ||||
13631 | nullptr, | ||||
13632 | 0, | ||||
13633 | 3}; | ||||
13634 | |||||
13635 | VkPipelineObj pipe(m_device); | ||||
13636 | pipe.SetInputAssembly(&iasci); | ||||
13637 | pipe.SetTessellation(&tsci); | ||||
13638 | pipe.AddColorAttachment(); | ||||
13639 | pipe.AddShader(&vs); | ||||
13640 | pipe.AddShader(&tcs); | ||||
13641 | pipe.AddShader(&tes); | ||||
13642 | pipe.AddShader(&fs); | ||||
13643 | |||||
13644 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13645 | descriptorSet.AppendDummy(); | ||||
13646 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13647 | |||||
13648 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13649 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13650 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 13651 | } |
13652 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13653 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13654 | TEST_DESCRIPTION("Test that an error is produced for a vertex attribute setup where multiple " |
13655 | "bindings provide the same location"); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13656 | m_errorMonitor->SetDesiredFailureMsg( |
13657 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13658 | "Duplicate vertex input binding descriptions for binding 0"); |
13659 | |||||
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 13660 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 13661 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 13662 | |
13663 | /* Two binding descriptions for binding 0 */ | ||||
13664 | VkVertexInputBindingDescription input_bindings[2]; | ||||
13665 | memset(input_bindings, 0, sizeof(input_bindings)); | ||||
13666 | |||||
13667 | VkVertexInputAttributeDescription input_attrib; | ||||
13668 | memset(&input_attrib, 0, sizeof(input_attrib)); | ||||
13669 | input_attrib.format = VK_FORMAT_R32_SFLOAT; | ||||
13670 | |||||
13671 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13672 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 13673 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13674 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 13675 | "out gl_PerVertex {\n" |
13676 | " vec4 gl_Position;\n" | ||||
13677 | "};\n" | ||||
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 13678 | "void main(){\n" |
13679 | " gl_Position = vec4(x);\n" | ||||
13680 | "}\n"; | ||||
13681 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13682 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 13683 | "\n" |
13684 | "layout(location=0) out vec4 color;\n" | ||||
13685 | "void main(){\n" | ||||
13686 | " color = vec4(1);\n" | ||||
13687 | "}\n"; | ||||
13688 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 13689 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
13690 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 13691 | |
13692 | VkPipelineObj pipe(m_device); | ||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 13693 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 13694 | pipe.AddShader(&vs); |
13695 | pipe.AddShader(&fs); | ||||
13696 | |||||
13697 | pipe.AddVertexInputBindings(input_bindings, 2); | ||||
13698 | pipe.AddVertexInputAttribs(&input_attrib, 1); | ||||
13699 | |||||
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 13700 | VkDescriptorSetObj descriptorSet(m_device); |
13701 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13702 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 13703 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 13704 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 13705 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13706 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 13707 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 13708 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 13709 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13710 | TEST_DESCRIPTION("Test that pipeline validation accepts basic use of 64bit vertex " |
13711 | "attributes. This is interesting because they consume multiple " | ||||
13712 | "locations."); | ||||
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 13713 | m_errorMonitor->ExpectSuccess(); |
13714 | |||||
13715 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13716 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13717 | |||||
Chris Forbes | 91cf3a8 | 2016-06-28 17:51:35 +1200 | [diff] [blame] | 13718 | if (!m_device->phy().features().shaderFloat64) { |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 13719 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
13720 | return; | ||||
13721 | } | ||||
13722 | |||||
13723 | VkVertexInputBindingDescription input_bindings[1]; | ||||
13724 | memset(input_bindings, 0, sizeof(input_bindings)); | ||||
13725 | |||||
13726 | VkVertexInputAttributeDescription input_attribs[4]; | ||||
13727 | memset(input_attribs, 0, sizeof(input_attribs)); | ||||
13728 | input_attribs[0].location = 0; | ||||
13729 | input_attribs[0].offset = 0; | ||||
13730 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; | ||||
13731 | input_attribs[1].location = 2; | ||||
13732 | input_attribs[1].offset = 32; | ||||
13733 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; | ||||
13734 | input_attribs[2].location = 4; | ||||
13735 | input_attribs[2].offset = 64; | ||||
13736 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; | ||||
13737 | input_attribs[3].location = 6; | ||||
13738 | input_attribs[3].offset = 96; | ||||
13739 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; | ||||
13740 | |||||
13741 | char const *vsSource = | ||||
13742 | "#version 450\n" | ||||
13743 | "\n" | ||||
13744 | "layout(location=0) in dmat4 x;\n" | ||||
13745 | "out gl_PerVertex {\n" | ||||
13746 | " vec4 gl_Position;\n" | ||||
13747 | "};\n" | ||||
13748 | "void main(){\n" | ||||
13749 | " gl_Position = vec4(x[0][0]);\n" | ||||
13750 | "}\n"; | ||||
13751 | char const *fsSource = | ||||
13752 | "#version 450\n" | ||||
13753 | "\n" | ||||
13754 | "layout(location=0) out vec4 color;\n" | ||||
13755 | "void main(){\n" | ||||
13756 | " color = vec4(1);\n" | ||||
13757 | "}\n"; | ||||
13758 | |||||
13759 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
13760 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13761 | |||||
13762 | VkPipelineObj pipe(m_device); | ||||
13763 | pipe.AddColorAttachment(); | ||||
13764 | pipe.AddShader(&vs); | ||||
13765 | pipe.AddShader(&fs); | ||||
13766 | |||||
13767 | pipe.AddVertexInputBindings(input_bindings, 1); | ||||
13768 | pipe.AddVertexInputAttribs(input_attribs, 4); | ||||
13769 | |||||
13770 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13771 | descriptorSet.AppendDummy(); | ||||
13772 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
13773 | |||||
13774 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13775 | |||||
13776 | m_errorMonitor->VerifyNotFound(); | ||||
13777 | } | ||||
13778 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13779 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13780 | TEST_DESCRIPTION("Test that an error is produced for a FS which does not " |
13781 | "provide an output for one of the pipeline's color attachments"); | ||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 13782 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13783 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13784 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 13785 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 13786 | |
13787 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13788 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 13789 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 13790 | "out gl_PerVertex {\n" |
13791 | " vec4 gl_Position;\n" | ||||
13792 | "};\n" | ||||
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 13793 | "void main(){\n" |
13794 | " gl_Position = vec4(1);\n" | ||||
13795 | "}\n"; | ||||
13796 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13797 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 13798 | "\n" |
13799 | "void main(){\n" | ||||
13800 | "}\n"; | ||||
13801 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 13802 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
13803 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 13804 | |
13805 | VkPipelineObj pipe(m_device); | ||||
13806 | pipe.AddShader(&vs); | ||||
13807 | pipe.AddShader(&fs); | ||||
13808 | |||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 13809 | /* set up CB 0, not written */ |
13810 | pipe.AddColorAttachment(); | ||||
13811 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 13812 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 13813 | VkDescriptorSetObj descriptorSet(m_device); |
13814 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13815 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 13816 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 13817 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 13818 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13819 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 13820 | } |
13821 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13822 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13823 | TEST_DESCRIPTION("Test that a warning is produced for a FS which provides a spurious " |
13824 | "output with no matching attachment"); | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13825 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 13826 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13827 | "FS writes to output location 1 with no matching attachment"); |
13828 | |||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 13829 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 13830 | |
13831 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13832 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 13833 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 13834 | "out gl_PerVertex {\n" |
13835 | " vec4 gl_Position;\n" | ||||
13836 | "};\n" | ||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 13837 | "void main(){\n" |
13838 | " gl_Position = vec4(1);\n" | ||||
13839 | "}\n"; | ||||
13840 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13841 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 13842 | "\n" |
13843 | "layout(location=0) out vec4 x;\n" | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13844 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 13845 | "void main(){\n" |
13846 | " x = vec4(1);\n" | ||||
13847 | " y = vec4(1);\n" | ||||
13848 | "}\n"; | ||||
13849 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 13850 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
13851 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 13852 | |
13853 | VkPipelineObj pipe(m_device); | ||||
13854 | pipe.AddShader(&vs); | ||||
13855 | pipe.AddShader(&fs); | ||||
13856 | |||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 13857 | /* set up CB 0, not written */ |
13858 | pipe.AddColorAttachment(); | ||||
13859 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 13860 | /* FS writes CB 1, but we don't configure it */ |
13861 | |||||
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 13862 | VkDescriptorSetObj descriptorSet(m_device); |
13863 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13864 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 13865 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 13866 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 13867 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13868 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 13869 | } |
13870 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13871 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13872 | TEST_DESCRIPTION("Test that an error is produced for a mismatch between the fundamental " |
13873 | "type of an FS output variable, and the format of the corresponding attachment"); | ||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 13874 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13875 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13876 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13877 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13878 | |
13879 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13880 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13881 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 13882 | "out gl_PerVertex {\n" |
13883 | " vec4 gl_Position;\n" | ||||
13884 | "};\n" | ||||
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13885 | "void main(){\n" |
13886 | " gl_Position = vec4(1);\n" | ||||
13887 | "}\n"; | ||||
13888 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13889 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13890 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13891 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13892 | "void main(){\n" |
13893 | " x = ivec4(1);\n" | ||||
13894 | "}\n"; | ||||
13895 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 13896 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
13897 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13898 | |
13899 | VkPipelineObj pipe(m_device); | ||||
13900 | pipe.AddShader(&vs); | ||||
13901 | pipe.AddShader(&fs); | ||||
13902 | |||||
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 13903 | /* set up CB 0; type is UNORM by default */ |
13904 | pipe.AddColorAttachment(); | ||||
13905 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13906 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13907 | VkDescriptorSetObj descriptorSet(m_device); |
13908 | descriptorSet.AppendDummy(); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13909 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13910 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 13911 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13912 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13913 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 13914 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 13915 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13916 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13917 | TEST_DESCRIPTION("Test that an error is produced for a shader consuming a uniform " |
13918 | "block which has no corresponding binding in the pipeline layout"); | ||||
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 13919 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 13920 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13921 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13922 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13923 | |
13924 | char const *vsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13925 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13926 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 13927 | "out gl_PerVertex {\n" |
13928 | " vec4 gl_Position;\n" | ||||
13929 | "};\n" | ||||
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13930 | "void main(){\n" |
13931 | " gl_Position = vec4(1);\n" | ||||
13932 | "}\n"; | ||||
13933 | char const *fsSource = | ||||
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 13934 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13935 | "\n" |
13936 | "layout(location=0) out vec4 x;\n" | ||||
13937 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" | ||||
13938 | "void main(){\n" | ||||
13939 | " x = vec4(bar.y);\n" | ||||
13940 | "}\n"; | ||||
13941 | |||||
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 13942 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
13943 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13944 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13945 | VkPipelineObj pipe(m_device); |
13946 | pipe.AddShader(&vs); | ||||
13947 | pipe.AddShader(&fs); | ||||
13948 | |||||
13949 | /* set up CB 0; type is UNORM by default */ | ||||
13950 | pipe.AddColorAttachment(); | ||||
13951 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13952 | |||||
13953 | VkDescriptorSetObj descriptorSet(m_device); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 13954 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13955 | |
13956 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
13957 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 13958 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 13959 | } |
13960 | |||||
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 13961 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 13962 | TEST_DESCRIPTION("Test that an error is produced for a shader consuming push constants " |
13963 | "which are not provided in the pipeline layout"); | ||||
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 13964 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
13965 | "not declared in layout"); | ||||
13966 | |||||
13967 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
13968 | |||||
13969 | char const *vsSource = | ||||
13970 | "#version 450\n" | ||||
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 13971 | "\n" |
13972 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" | ||||
13973 | "out gl_PerVertex {\n" | ||||
13974 | " vec4 gl_Position;\n" | ||||
13975 | "};\n" | ||||
13976 | "void main(){\n" | ||||
13977 | " gl_Position = vec4(consts.x);\n" | ||||
13978 | "}\n"; | ||||
13979 | char const *fsSource = | ||||
13980 | "#version 450\n" | ||||
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 13981 | "\n" |
13982 | "layout(location=0) out vec4 x;\n" | ||||
13983 | "void main(){\n" | ||||
13984 | " x = vec4(1);\n" | ||||
13985 | "}\n"; | ||||
13986 | |||||
13987 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
13988 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
13989 | |||||
13990 | VkPipelineObj pipe(m_device); | ||||
13991 | pipe.AddShader(&vs); | ||||
13992 | pipe.AddShader(&fs); | ||||
13993 | |||||
13994 | /* set up CB 0; type is UNORM by default */ | ||||
13995 | pipe.AddColorAttachment(); | ||||
13996 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
13997 | |||||
13998 | VkDescriptorSetObj descriptorSet(m_device); | ||||
13999 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
14000 | |||||
14001 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
14002 | |||||
14003 | /* should have generated an error -- no push constant ranges provided! */ | ||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 14004 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 14005 | } |
14006 | |||||
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 14007 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 14008 | TEST_DESCRIPTION("Test that an error is produced for a compute pipeline consuming a " |
14009 | "descriptor which is not provided in the pipeline layout"); | ||||
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 14010 | m_errorMonitor->SetDesiredFailureMsg( |
14011 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14012 | "Shader uses descriptor slot 0.0"); | ||||
14013 | |||||
14014 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14015 | |||||
14016 | char const *csSource = | ||||
14017 | "#version 450\n" | ||||
14018 | "\n" | ||||
14019 | "layout(local_size_x=1) in;\n" | ||||
14020 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" | ||||
14021 | "void main(){\n" | ||||
14022 | " x = vec4(1);\n" | ||||
14023 | "}\n"; | ||||
14024 | |||||
14025 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); | ||||
14026 | |||||
14027 | VkDescriptorSetObj descriptorSet(m_device); | ||||
14028 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
14029 | |||||
14030 | VkComputePipelineCreateInfo cpci = { | ||||
14031 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, | ||||
14032 | nullptr, 0, { | ||||
14033 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, | ||||
14034 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, | ||||
14035 | cs.handle(), "main", nullptr | ||||
14036 | }, | ||||
14037 | descriptorSet.GetPipelineLayout(), | ||||
14038 | VK_NULL_HANDLE, -1 | ||||
14039 | }; | ||||
14040 | |||||
14041 | VkPipeline pipe; | ||||
14042 | VkResult err = vkCreateComputePipelines( | ||||
14043 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); | ||||
14044 | |||||
14045 | m_errorMonitor->VerifyFound(); | ||||
14046 | |||||
14047 | if (err == VK_SUCCESS) { | ||||
14048 | vkDestroyPipeline(m_device->device(), pipe, nullptr); | ||||
14049 | } | ||||
14050 | } | ||||
14051 | |||||
14052 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { | ||||
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 14053 | TEST_DESCRIPTION("Test that pipeline validation accepts a compute pipeline which declares a " |
14054 | "descriptor-backed resource which is not provided, but the shader does not " | ||||
14055 | "statically use it. This is interesting because it requires compute pipelines " | ||||
14056 | "to have a proper descriptor use walk, which they didn't for some time."); | ||||
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 14057 | m_errorMonitor->ExpectSuccess(); |
14058 | |||||
14059 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14060 | |||||
14061 | char const *csSource = | ||||
14062 | "#version 450\n" | ||||
14063 | "\n" | ||||
14064 | "layout(local_size_x=1) in;\n" | ||||
14065 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" | ||||
14066 | "void main(){\n" | ||||
14067 | " // x is not used.\n" | ||||
14068 | "}\n"; | ||||
14069 | |||||
14070 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); | ||||
14071 | |||||
14072 | VkDescriptorSetObj descriptorSet(m_device); | ||||
14073 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
14074 | |||||
14075 | VkComputePipelineCreateInfo cpci = { | ||||
14076 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, | ||||
14077 | nullptr, 0, { | ||||
14078 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, | ||||
14079 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, | ||||
14080 | cs.handle(), "main", nullptr | ||||
14081 | }, | ||||
14082 | descriptorSet.GetPipelineLayout(), | ||||
14083 | VK_NULL_HANDLE, -1 | ||||
14084 | }; | ||||
14085 | |||||
14086 | VkPipeline pipe; | ||||
14087 | VkResult err = vkCreateComputePipelines( | ||||
14088 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); | ||||
14089 | |||||
14090 | m_errorMonitor->VerifyNotFound(); | ||||
14091 | |||||
14092 | if (err == VK_SUCCESS) { | ||||
14093 | vkDestroyPipeline(m_device->device(), pipe, nullptr); | ||||
14094 | } | ||||
14095 | } | ||||
14096 | |||||
Chris Forbes | 22a9b09 | 2016-07-19 14:34:05 +1200 | [diff] [blame] | 14097 | TEST_F(VkLayerTest, CreateComputePipelineDescriptorTypeMismatch) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 14098 | TEST_DESCRIPTION("Test that an error is produced for a pipeline consuming a " |
14099 | "descriptor-backed resource of a mismatched type"); | ||||
Chris Forbes | 22a9b09 | 2016-07-19 14:34:05 +1200 | [diff] [blame] | 14100 | m_errorMonitor->SetDesiredFailureMsg( |
14101 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14102 | "but descriptor of type VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER"); | ||||
14103 | |||||
14104 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14105 | |||||
14106 | VkDescriptorSetLayoutBinding binding = { | ||||
14107 | 0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, | ||||
14108 | 1, VK_SHADER_STAGE_COMPUTE_BIT, nullptr | ||||
14109 | }; | ||||
14110 | VkDescriptorSetLayoutCreateInfo dslci = { | ||||
14111 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, | ||||
14112 | 0, 1, &binding | ||||
14113 | }; | ||||
14114 | VkDescriptorSetLayout dsl; | ||||
14115 | VkResult err = vkCreateDescriptorSetLayout(m_device->device(), &dslci, | ||||
14116 | nullptr, &dsl); | ||||
14117 | ASSERT_VK_SUCCESS(err); | ||||
14118 | |||||
14119 | VkPipelineLayoutCreateInfo plci = { | ||||
14120 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, nullptr, | ||||
14121 | 0, 1, &dsl, 0, nullptr | ||||
14122 | }; | ||||
14123 | VkPipelineLayout pl; | ||||
14124 | err = vkCreatePipelineLayout(m_device->device(), &plci, | ||||
14125 | nullptr, &pl); | ||||
14126 | ASSERT_VK_SUCCESS(err); | ||||
14127 | |||||
14128 | char const *csSource = | ||||
14129 | "#version 450\n" | ||||
14130 | "\n" | ||||
14131 | "layout(local_size_x=1) in;\n" | ||||
14132 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" | ||||
14133 | "void main() {\n" | ||||
14134 | " x.x = 1.0f;\n" | ||||
14135 | "}\n"; | ||||
14136 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); | ||||
14137 | |||||
14138 | VkComputePipelineCreateInfo cpci = { | ||||
14139 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, nullptr, | ||||
14140 | 0, { | ||||
14141 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, | ||||
14142 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, | ||||
14143 | cs.handle(), "main", nullptr | ||||
14144 | }, | ||||
14145 | pl, VK_NULL_HANDLE, -1 | ||||
14146 | }; | ||||
14147 | |||||
14148 | VkPipeline pipe; | ||||
14149 | err = vkCreateComputePipelines( | ||||
14150 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); | ||||
14151 | |||||
14152 | m_errorMonitor->VerifyFound(); | ||||
14153 | |||||
14154 | if (err == VK_SUCCESS) { | ||||
14155 | vkDestroyPipeline(m_device->device(), pipe, nullptr); | ||||
14156 | } | ||||
14157 | |||||
14158 | vkDestroyPipelineLayout(m_device->device(), pl, nullptr); | ||||
14159 | vkDestroyDescriptorSetLayout(m_device->device(), dsl, nullptr); | ||||
14160 | } | ||||
14161 | |||||
Chris Forbes | e10a51f | 2016-07-19 14:42:51 +1200 | [diff] [blame] | 14162 | TEST_F(VkLayerTest, CreateComputePipelineCombinedImageSamplerConsumedAsSampler) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 14163 | TEST_DESCRIPTION("Test that pipeline validation accepts a shader consuming only the " |
14164 | "sampler portion of a combined image + sampler"); | ||||
Chris Forbes | e10a51f | 2016-07-19 14:42:51 +1200 | [diff] [blame] | 14165 | m_errorMonitor->ExpectSuccess(); |
14166 | |||||
14167 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14168 | |||||
14169 | VkDescriptorSetLayoutBinding bindings[] = { | ||||
14170 | { | ||||
14171 | 0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, | ||||
14172 | 1, VK_SHADER_STAGE_COMPUTE_BIT, nullptr | ||||
14173 | }, | ||||
14174 | { | ||||
14175 | 1, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, | ||||
14176 | 1, VK_SHADER_STAGE_COMPUTE_BIT, nullptr | ||||
14177 | }, | ||||
14178 | { | ||||
14179 | 2, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, | ||||
14180 | 1, VK_SHADER_STAGE_COMPUTE_BIT, nullptr | ||||
14181 | }, | ||||
14182 | }; | ||||
14183 | VkDescriptorSetLayoutCreateInfo dslci = { | ||||
14184 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, | ||||
14185 | 0, 3, bindings | ||||
14186 | }; | ||||
14187 | VkDescriptorSetLayout dsl; | ||||
14188 | VkResult err = vkCreateDescriptorSetLayout(m_device->device(), &dslci, | ||||
14189 | nullptr, &dsl); | ||||
14190 | ASSERT_VK_SUCCESS(err); | ||||
14191 | |||||
14192 | VkPipelineLayoutCreateInfo plci = { | ||||
14193 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, nullptr, | ||||
14194 | 0, 1, &dsl, 0, nullptr | ||||
14195 | }; | ||||
14196 | VkPipelineLayout pl; | ||||
14197 | err = vkCreatePipelineLayout(m_device->device(), &plci, | ||||
14198 | nullptr, &pl); | ||||
14199 | ASSERT_VK_SUCCESS(err); | ||||
14200 | |||||
14201 | char const *csSource = | ||||
14202 | "#version 450\n" | ||||
14203 | "\n" | ||||
14204 | "layout(local_size_x=1) in;\n" | ||||
14205 | "layout(set=0, binding=0) uniform sampler s;\n" | ||||
14206 | "layout(set=0, binding=1) uniform texture2D t;\n" | ||||
14207 | "layout(set=0, binding=2) buffer block { vec4 x; };\n" | ||||
14208 | "void main() {\n" | ||||
14209 | " x = texture(sampler2D(t, s), vec2(0));\n" | ||||
14210 | "}\n"; | ||||
14211 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); | ||||
14212 | |||||
14213 | VkComputePipelineCreateInfo cpci = { | ||||
14214 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, nullptr, | ||||
14215 | 0, { | ||||
14216 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, | ||||
14217 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, | ||||
14218 | cs.handle(), "main", nullptr | ||||
14219 | }, | ||||
14220 | pl, VK_NULL_HANDLE, -1 | ||||
14221 | }; | ||||
14222 | |||||
14223 | VkPipeline pipe; | ||||
14224 | err = vkCreateComputePipelines( | ||||
14225 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); | ||||
14226 | |||||
14227 | m_errorMonitor->VerifyNotFound(); | ||||
14228 | |||||
14229 | if (err == VK_SUCCESS) { | ||||
14230 | vkDestroyPipeline(m_device->device(), pipe, nullptr); | ||||
14231 | } | ||||
14232 | |||||
14233 | vkDestroyPipelineLayout(m_device->device(), pl, nullptr); | ||||
14234 | vkDestroyDescriptorSetLayout(m_device->device(), dsl, nullptr); | ||||
14235 | } | ||||
14236 | |||||
Chris Forbes | 91c3b2a | 2016-07-19 14:46:38 +1200 | [diff] [blame] | 14237 | TEST_F(VkLayerTest, CreateComputePipelineCombinedImageSamplerConsumedAsImage) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 14238 | TEST_DESCRIPTION("Test that pipeline validation accepts a shader consuming only the " |
14239 | "image portion of a combined image + sampler"); | ||||
Chris Forbes | 91c3b2a | 2016-07-19 14:46:38 +1200 | [diff] [blame] | 14240 | m_errorMonitor->ExpectSuccess(); |
14241 | |||||
14242 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14243 | |||||
14244 | VkDescriptorSetLayoutBinding bindings[] = { | ||||
14245 | { | ||||
14246 | 0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, | ||||
14247 | 1, VK_SHADER_STAGE_COMPUTE_BIT, nullptr | ||||
14248 | }, | ||||
14249 | { | ||||
14250 | 1, VK_DESCRIPTOR_TYPE_SAMPLER, | ||||
14251 | 1, VK_SHADER_STAGE_COMPUTE_BIT, nullptr | ||||
14252 | }, | ||||
14253 | { | ||||
14254 | 2, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, | ||||
14255 | 1, VK_SHADER_STAGE_COMPUTE_BIT, nullptr | ||||
14256 | }, | ||||
14257 | }; | ||||
14258 | VkDescriptorSetLayoutCreateInfo dslci = { | ||||
14259 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, | ||||
14260 | 0, 3, bindings | ||||
14261 | }; | ||||
14262 | VkDescriptorSetLayout dsl; | ||||
14263 | VkResult err = vkCreateDescriptorSetLayout(m_device->device(), &dslci, | ||||
14264 | nullptr, &dsl); | ||||
14265 | ASSERT_VK_SUCCESS(err); | ||||
14266 | |||||
14267 | VkPipelineLayoutCreateInfo plci = { | ||||
14268 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, nullptr, | ||||
14269 | 0, 1, &dsl, 0, nullptr | ||||
14270 | }; | ||||
14271 | VkPipelineLayout pl; | ||||
14272 | err = vkCreatePipelineLayout(m_device->device(), &plci, | ||||
14273 | nullptr, &pl); | ||||
14274 | ASSERT_VK_SUCCESS(err); | ||||
14275 | |||||
14276 | char const *csSource = | ||||
14277 | "#version 450\n" | ||||
14278 | "\n" | ||||
14279 | "layout(local_size_x=1) in;\n" | ||||
14280 | "layout(set=0, binding=0) uniform texture2D t;\n" | ||||
14281 | "layout(set=0, binding=1) uniform sampler s;\n" | ||||
14282 | "layout(set=0, binding=2) buffer block { vec4 x; };\n" | ||||
14283 | "void main() {\n" | ||||
14284 | " x = texture(sampler2D(t, s), vec2(0));\n" | ||||
14285 | "}\n"; | ||||
14286 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); | ||||
14287 | |||||
14288 | VkComputePipelineCreateInfo cpci = { | ||||
14289 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, nullptr, | ||||
14290 | 0, { | ||||
14291 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, | ||||
14292 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, | ||||
14293 | cs.handle(), "main", nullptr | ||||
14294 | }, | ||||
14295 | pl, VK_NULL_HANDLE, -1 | ||||
14296 | }; | ||||
14297 | |||||
14298 | VkPipeline pipe; | ||||
14299 | err = vkCreateComputePipelines( | ||||
14300 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); | ||||
14301 | |||||
14302 | m_errorMonitor->VerifyNotFound(); | ||||
14303 | |||||
14304 | if (err == VK_SUCCESS) { | ||||
14305 | vkDestroyPipeline(m_device->device(), pipe, nullptr); | ||||
14306 | } | ||||
14307 | |||||
14308 | vkDestroyPipelineLayout(m_device->device(), pl, nullptr); | ||||
14309 | vkDestroyDescriptorSetLayout(m_device->device(), dsl, nullptr); | ||||
14310 | } | ||||
14311 | |||||
Chris Forbes | 6a4991a | 2016-07-19 15:07:32 +1200 | [diff] [blame] | 14312 | TEST_F(VkLayerTest, CreateComputePipelineCombinedImageSamplerConsumedAsBoth) { |
Chris Forbes | 1cc7954 | 2016-07-20 11:13:44 +1200 | [diff] [blame] | 14313 | TEST_DESCRIPTION("Test that pipeline validation accepts a shader consuming " |
14314 | "both the sampler and the image of a combined image+sampler " | ||||
14315 | "but via separate variables"); | ||||
Chris Forbes | 6a4991a | 2016-07-19 15:07:32 +1200 | [diff] [blame] | 14316 | m_errorMonitor->ExpectSuccess(); |
14317 | |||||
14318 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14319 | |||||
14320 | VkDescriptorSetLayoutBinding bindings[] = { | ||||
14321 | { | ||||
14322 | 0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, | ||||
14323 | 1, VK_SHADER_STAGE_COMPUTE_BIT, nullptr | ||||
14324 | }, | ||||
14325 | { | ||||
14326 | 1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, | ||||
14327 | 1, VK_SHADER_STAGE_COMPUTE_BIT, nullptr | ||||
14328 | }, | ||||
14329 | }; | ||||
14330 | VkDescriptorSetLayoutCreateInfo dslci = { | ||||
14331 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, nullptr, | ||||
14332 | 0, 2, bindings | ||||
14333 | }; | ||||
14334 | VkDescriptorSetLayout dsl; | ||||
14335 | VkResult err = vkCreateDescriptorSetLayout(m_device->device(), &dslci, | ||||
14336 | nullptr, &dsl); | ||||
14337 | ASSERT_VK_SUCCESS(err); | ||||
14338 | |||||
14339 | VkPipelineLayoutCreateInfo plci = { | ||||
14340 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, nullptr, | ||||
14341 | 0, 1, &dsl, 0, nullptr | ||||
14342 | }; | ||||
14343 | VkPipelineLayout pl; | ||||
14344 | err = vkCreatePipelineLayout(m_device->device(), &plci, | ||||
14345 | nullptr, &pl); | ||||
14346 | ASSERT_VK_SUCCESS(err); | ||||
14347 | |||||
14348 | char const *csSource = | ||||
14349 | "#version 450\n" | ||||
14350 | "\n" | ||||
14351 | "layout(local_size_x=1) in;\n" | ||||
14352 | "layout(set=0, binding=0) uniform texture2D t;\n" | ||||
14353 | "layout(set=0, binding=0) uniform sampler s; // both binding 0!\n" | ||||
14354 | "layout(set=0, binding=1) buffer block { vec4 x; };\n" | ||||
14355 | "void main() {\n" | ||||
14356 | " x = texture(sampler2D(t, s), vec2(0));\n" | ||||
14357 | "}\n"; | ||||
14358 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); | ||||
14359 | |||||
14360 | VkComputePipelineCreateInfo cpci = { | ||||
14361 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, nullptr, | ||||
14362 | 0, { | ||||
14363 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, | ||||
14364 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, | ||||
14365 | cs.handle(), "main", nullptr | ||||
14366 | }, | ||||
14367 | pl, VK_NULL_HANDLE, -1 | ||||
14368 | }; | ||||
14369 | |||||
14370 | VkPipeline pipe; | ||||
14371 | err = vkCreateComputePipelines( | ||||
14372 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); | ||||
14373 | |||||
14374 | m_errorMonitor->VerifyNotFound(); | ||||
14375 | |||||
14376 | if (err == VK_SUCCESS) { | ||||
14377 | vkDestroyPipeline(m_device->device(), pipe, nullptr); | ||||
14378 | } | ||||
14379 | |||||
14380 | vkDestroyPipelineLayout(m_device->device(), pl, nullptr); | ||||
14381 | vkDestroyDescriptorSetLayout(m_device->device(), dsl, nullptr); | ||||
14382 | } | ||||
14383 | |||||
Chris Forbes | 5002059 | 2016-07-27 13:52:41 +1200 | [diff] [blame] | 14384 | TEST_F(VkLayerTest, DrawTimeImageViewTypeMismatchWithPipeline) { |
14385 | TEST_DESCRIPTION("Test that an error is produced when an image view type " | ||||
14386 | "does not match the dimensionality declared in the shader"); | ||||
14387 | |||||
14388 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14389 | "requires an image view of type VK_IMAGE_VIEW_TYPE_3D"); | ||||
14390 | |||||
14391 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14392 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
14393 | |||||
14394 | char const *vsSource = | ||||
14395 | "#version 450\n" | ||||
14396 | "\n" | ||||
14397 | "out gl_PerVertex { vec4 gl_Position; };\n" | ||||
14398 | "void main() { gl_Position = vec4(0); }\n"; | ||||
14399 | char const *fsSource = | ||||
14400 | "#version 450\n" | ||||
14401 | "\n" | ||||
14402 | "layout(set=0, binding=0) uniform sampler3D s;\n" | ||||
14403 | "layout(location=0) out vec4 color;\n" | ||||
14404 | "void main() {\n" | ||||
14405 | " color = texture(s, vec3(0));\n" | ||||
14406 | "}\n"; | ||||
14407 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
14408 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
14409 | |||||
14410 | VkPipelineObj pipe(m_device); | ||||
14411 | pipe.AddShader(&vs); | ||||
14412 | pipe.AddShader(&fs); | ||||
14413 | pipe.AddColorAttachment(); | ||||
14414 | |||||
14415 | VkTextureObj texture(m_device, nullptr); | ||||
14416 | VkSamplerObj sampler(m_device); | ||||
14417 | |||||
14418 | VkDescriptorSetObj descriptorSet(m_device); | ||||
14419 | descriptorSet.AppendSamplerTexture(&sampler, &texture); | ||||
14420 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
14421 | |||||
14422 | VkResult err = pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
14423 | ASSERT_VK_SUCCESS(err); | ||||
14424 | |||||
14425 | BeginCommandBuffer(); | ||||
14426 | |||||
14427 | m_commandBuffer->BindPipeline(pipe); | ||||
14428 | m_commandBuffer->BindDescriptorSet(descriptorSet); | ||||
14429 | |||||
14430 | VkViewport viewport = { 0, 0, 16, 16, 0, 1 }; | ||||
14431 | vkCmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport); | ||||
14432 | VkRect2D scissor = { { 0, 0 }, { 16, 16 } }; | ||||
14433 | vkCmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor); | ||||
14434 | |||||
14435 | // error produced here. | ||||
14436 | vkCmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); | ||||
14437 | |||||
14438 | m_errorMonitor->VerifyFound(); | ||||
14439 | |||||
14440 | EndCommandBuffer(); | ||||
14441 | } | ||||
14442 | |||||
Chris Forbes | 5533bfc | 2016-07-27 14:12:34 +1200 | [diff] [blame] | 14443 | TEST_F(VkLayerTest, DrawTimeImageMultisampleMismatchWithPipeline) { |
14444 | TEST_DESCRIPTION("Test that an error is produced when a multisampled images " | ||||
14445 | "are consumed via singlesample images types in the shader, or vice versa."); | ||||
14446 | |||||
14447 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14448 | "requires bound image to have multiple samples"); | ||||
14449 | |||||
14450 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14451 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
14452 | |||||
14453 | char const *vsSource = | ||||
14454 | "#version 450\n" | ||||
14455 | "\n" | ||||
14456 | "out gl_PerVertex { vec4 gl_Position; };\n" | ||||
14457 | "void main() { gl_Position = vec4(0); }\n"; | ||||
14458 | char const *fsSource = | ||||
14459 | "#version 450\n" | ||||
14460 | "\n" | ||||
14461 | "layout(set=0, binding=0) uniform sampler2DMS s;\n" | ||||
14462 | "layout(location=0) out vec4 color;\n" | ||||
14463 | "void main() {\n" | ||||
14464 | " color = texelFetch(s, ivec2(0), 0);\n" | ||||
14465 | "}\n"; | ||||
14466 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); | ||||
14467 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); | ||||
14468 | |||||
14469 | VkPipelineObj pipe(m_device); | ||||
14470 | pipe.AddShader(&vs); | ||||
14471 | pipe.AddShader(&fs); | ||||
14472 | pipe.AddColorAttachment(); | ||||
14473 | |||||
14474 | VkTextureObj texture(m_device, nullptr); | ||||
14475 | VkSamplerObj sampler(m_device); | ||||
14476 | |||||
14477 | VkDescriptorSetObj descriptorSet(m_device); | ||||
14478 | descriptorSet.AppendSamplerTexture(&sampler, &texture); | ||||
14479 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); | ||||
14480 | |||||
14481 | VkResult err = pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); | ||||
14482 | ASSERT_VK_SUCCESS(err); | ||||
14483 | |||||
14484 | BeginCommandBuffer(); | ||||
14485 | |||||
14486 | m_commandBuffer->BindPipeline(pipe); | ||||
14487 | m_commandBuffer->BindDescriptorSet(descriptorSet); | ||||
14488 | |||||
14489 | VkViewport viewport = { 0, 0, 16, 16, 0, 1 }; | ||||
14490 | vkCmdSetViewport(m_commandBuffer->handle(), 0, 1, &viewport); | ||||
14491 | VkRect2D scissor = { { 0, 0 }, { 16, 16 } }; | ||||
14492 | vkCmdSetScissor(m_commandBuffer->handle(), 0, 1, &scissor); | ||||
14493 | |||||
14494 | // error produced here. | ||||
14495 | vkCmdDraw(m_commandBuffer->handle(), 3, 1, 0, 0); | ||||
14496 | |||||
14497 | m_errorMonitor->VerifyFound(); | ||||
14498 | |||||
14499 | EndCommandBuffer(); | ||||
14500 | } | ||||
14501 | |||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 14502 | #endif // SHADER_CHECKER_TESTS |
14503 | |||||
14504 | #if DEVICE_LIMITS_TESTS | ||||
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 14505 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14506 | m_errorMonitor->SetDesiredFailureMsg( |
14507 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 14508 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 14509 | |
14510 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 14511 | |
14512 | // Create an image | ||||
14513 | VkImage image; | ||||
14514 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14515 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
14516 | const int32_t tex_width = 32; | ||||
14517 | const int32_t tex_height = 32; | ||||
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 14518 | |
14519 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14520 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
14521 | image_create_info.pNext = NULL; | ||||
14522 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14523 | image_create_info.format = tex_format; | ||||
14524 | image_create_info.extent.width = tex_width; | ||||
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 14525 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14526 | image_create_info.extent.depth = 1; |
14527 | image_create_info.mipLevels = 1; | ||||
14528 | image_create_info.arrayLayers = 1; | ||||
14529 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
14530 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
14531 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
14532 | image_create_info.flags = 0; | ||||
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 14533 | |
14534 | // Introduce error by sending down a bogus width extent | ||||
14535 | image_create_info.extent.width = 65536; | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14536 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 14537 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 14538 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 14539 | } |
14540 | |||||
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 14541 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
14542 | m_errorMonitor->SetDesiredFailureMsg( | ||||
14543 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14544 | "CreateImage extents is 0 for at least one required dimension"); | ||||
14545 | |||||
14546 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14547 | |||||
14548 | // Create an image | ||||
14549 | VkImage image; | ||||
14550 | |||||
14551 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
14552 | const int32_t tex_width = 32; | ||||
14553 | const int32_t tex_height = 32; | ||||
14554 | |||||
14555 | VkImageCreateInfo image_create_info = {}; | ||||
14556 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
14557 | image_create_info.pNext = NULL; | ||||
14558 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14559 | image_create_info.format = tex_format; | ||||
14560 | image_create_info.extent.width = tex_width; | ||||
14561 | image_create_info.extent.height = tex_height; | ||||
14562 | image_create_info.extent.depth = 1; | ||||
14563 | image_create_info.mipLevels = 1; | ||||
14564 | image_create_info.arrayLayers = 1; | ||||
14565 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
14566 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
14567 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
14568 | image_create_info.flags = 0; | ||||
14569 | |||||
14570 | // Introduce error by sending down a bogus width extent | ||||
14571 | image_create_info.extent.width = 0; | ||||
14572 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
14573 | |||||
14574 | m_errorMonitor->VerifyFound(); | ||||
14575 | } | ||||
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 14576 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 14577 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 14578 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14579 | TEST_F(VkLayerTest, InvalidImageView) { |
14580 | VkResult err; | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 14581 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14582 | m_errorMonitor->SetDesiredFailureMsg( |
14583 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 14584 | "vkCreateImageView called with baseMipLevel 10 "); |
14585 | |||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 14586 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 14587 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14588 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14589 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 14590 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14591 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
14592 | const int32_t tex_width = 32; | ||||
14593 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 14594 | |
14595 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14596 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
14597 | image_create_info.pNext = NULL; | ||||
14598 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14599 | image_create_info.format = tex_format; | ||||
14600 | image_create_info.extent.width = tex_width; | ||||
14601 | image_create_info.extent.height = tex_height; | ||||
14602 | image_create_info.extent.depth = 1; | ||||
14603 | image_create_info.mipLevels = 1; | ||||
14604 | image_create_info.arrayLayers = 1; | ||||
14605 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
14606 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
14607 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
14608 | image_create_info.flags = 0; | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 14609 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14610 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 14611 | ASSERT_VK_SUCCESS(err); |
14612 | |||||
14613 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14614 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
14615 | image_view_create_info.image = image; | ||||
14616 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
14617 | image_view_create_info.format = tex_format; | ||||
14618 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
14619 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error | ||||
14620 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
14621 | image_view_create_info.subresourceRange.aspectMask = | ||||
14622 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 14623 | |
14624 | VkImageView view; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14625 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
14626 | &view); | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 14627 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 14628 | m_errorMonitor->VerifyFound(); |
Tony Barbour | df4c004 | 2016-06-01 15:55:43 -0600 | [diff] [blame] | 14629 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 14630 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14631 | |
Mark Young | d339ba3 | 2016-05-30 13:28:35 -0600 | [diff] [blame] | 14632 | TEST_F(VkLayerTest, CreateImageViewNoMemoryBoundToImage) { |
14633 | VkResult err; | ||||
14634 | |||||
14635 | m_errorMonitor->SetDesiredFailureMsg( | ||||
14636 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 0dcf272 | 2016-07-14 09:54:11 -0600 | [diff] [blame] | 14637 | "used without first calling vkBindImageMemory"); |
Mark Young | d339ba3 | 2016-05-30 13:28:35 -0600 | [diff] [blame] | 14638 | |
14639 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14640 | |||||
14641 | // Create an image and try to create a view with no memory backing the image | ||||
14642 | VkImage image; | ||||
14643 | |||||
14644 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
14645 | const int32_t tex_width = 32; | ||||
14646 | const int32_t tex_height = 32; | ||||
14647 | |||||
14648 | VkImageCreateInfo image_create_info = {}; | ||||
14649 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
14650 | image_create_info.pNext = NULL; | ||||
14651 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14652 | image_create_info.format = tex_format; | ||||
14653 | image_create_info.extent.width = tex_width; | ||||
14654 | image_create_info.extent.height = tex_height; | ||||
14655 | image_create_info.extent.depth = 1; | ||||
14656 | image_create_info.mipLevels = 1; | ||||
14657 | image_create_info.arrayLayers = 1; | ||||
14658 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
14659 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
14660 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
14661 | image_create_info.flags = 0; | ||||
14662 | |||||
14663 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); | ||||
14664 | ASSERT_VK_SUCCESS(err); | ||||
14665 | |||||
14666 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
14667 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
14668 | image_view_create_info.image = image; | ||||
14669 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
14670 | image_view_create_info.format = tex_format; | ||||
14671 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
14672 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
14673 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
14674 | image_view_create_info.subresourceRange.aspectMask = | ||||
14675 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
14676 | |||||
14677 | VkImageView view; | ||||
14678 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, | ||||
14679 | &view); | ||||
14680 | |||||
14681 | m_errorMonitor->VerifyFound(); | ||||
14682 | vkDestroyImage(m_device->device(), image, NULL); | ||||
14683 | // If last error is success, it still created the view, so delete it. | ||||
14684 | if (err == VK_SUCCESS) { | ||||
14685 | vkDestroyImageView(m_device->device(), view, NULL); | ||||
14686 | } | ||||
14687 | |||||
14688 | } | ||||
14689 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14690 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 14691 | TEST_DESCRIPTION( |
14692 | "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] | 14693 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14694 | "vkCreateImageView: Color image " |
14695 | "formats must have ONLY the " | ||||
14696 | "VK_IMAGE_ASPECT_COLOR_BIT set"); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 14697 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 14698 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 14699 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14700 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 14701 | VkImageObj image(m_device); |
14702 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, | ||||
14703 | VK_IMAGE_TILING_LINEAR, 0); | ||||
14704 | ASSERT_TRUE(image.initialized()); | ||||
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 14705 | |
14706 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14707 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 14708 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14709 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
14710 | image_view_create_info.format = tex_format; | ||||
14711 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
14712 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
14713 | // Cause an error by setting an invalid image aspect | ||||
14714 | image_view_create_info.subresourceRange.aspectMask = | ||||
14715 | VK_IMAGE_ASPECT_METADATA_BIT; | ||||
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 14716 | |
14717 | VkImageView view; | ||||
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 14718 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 14719 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 14720 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 14721 | } |
14722 | |||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 14723 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14724 | VkResult err; |
14725 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14726 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14727 | m_errorMonitor->SetDesiredFailureMsg( |
14728 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 14729 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 14730 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14731 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14732 | |
14733 | // Create two images of different types and try to copy between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14734 | VkImage srcImage; |
14735 | VkImage dstImage; | ||||
14736 | VkDeviceMemory srcMem; | ||||
14737 | VkDeviceMemory destMem; | ||||
14738 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14739 | |
14740 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14741 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
14742 | image_create_info.pNext = NULL; | ||||
14743 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14744 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
14745 | image_create_info.extent.width = 32; | ||||
14746 | image_create_info.extent.height = 32; | ||||
14747 | image_create_info.extent.depth = 1; | ||||
14748 | image_create_info.mipLevels = 1; | ||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 14749 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14750 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
14751 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
14752 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
14753 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14754 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14755 | err = |
14756 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14757 | ASSERT_VK_SUCCESS(err); |
14758 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14759 | err = |
14760 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14761 | ASSERT_VK_SUCCESS(err); |
14762 | |||||
14763 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14764 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14765 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
14766 | memAlloc.pNext = NULL; | ||||
14767 | memAlloc.allocationSize = 0; | ||||
14768 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14769 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 14770 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14771 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14772 | pass = |
14773 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 14774 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14775 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14776 | ASSERT_VK_SUCCESS(err); |
14777 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14778 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14779 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14780 | pass = |
14781 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14782 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14783 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14784 | ASSERT_VK_SUCCESS(err); |
14785 | |||||
14786 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
14787 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14788 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14789 | ASSERT_VK_SUCCESS(err); |
14790 | |||||
14791 | BeginCommandBuffer(); | ||||
14792 | VkImageCopy copyRegion; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 14793 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14794 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 14795 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 14796 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14797 | copyRegion.srcOffset.x = 0; |
14798 | copyRegion.srcOffset.y = 0; | ||||
14799 | copyRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 14800 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14801 | copyRegion.dstSubresource.mipLevel = 0; |
14802 | copyRegion.dstSubresource.baseArrayLayer = 0; | ||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 14803 | // Introduce failure by forcing the dst layerCount to differ from src |
14804 | copyRegion.dstSubresource.layerCount = 3; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14805 | copyRegion.dstOffset.x = 0; |
14806 | copyRegion.dstOffset.y = 0; | ||||
14807 | copyRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14808 | copyRegion.extent.width = 1; |
14809 | copyRegion.extent.height = 1; | ||||
14810 | copyRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 14811 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
14812 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14813 | EndCommandBuffer(); |
14814 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 14815 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14816 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14817 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 14818 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 14819 | vkFreeMemory(m_device->device(), srcMem, NULL); |
14820 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 14821 | } |
14822 | |||||
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 14823 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
14824 | |||||
14825 | TEST_DESCRIPTION("Creating images with unsuported formats "); | ||||
14826 | |||||
14827 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14828 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
14829 | VkImageObj image(m_device); | ||||
14830 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
14831 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | ||||
14832 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
14833 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
14834 | ASSERT_TRUE(image.initialized()); | ||||
14835 | |||||
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 14836 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
14837 | VkImageCreateInfo image_create_info; | ||||
14838 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
14839 | image_create_info.pNext = NULL; | ||||
14840 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
14841 | image_create_info.format = VK_FORMAT_UNDEFINED; | ||||
14842 | image_create_info.extent.width = 32; | ||||
14843 | image_create_info.extent.height = 32; | ||||
14844 | image_create_info.extent.depth = 1; | ||||
14845 | image_create_info.mipLevels = 1; | ||||
14846 | image_create_info.arrayLayers = 1; | ||||
14847 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
14848 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
14849 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
14850 | image_create_info.flags = 0; | ||||
14851 | |||||
14852 | m_errorMonitor->SetDesiredFailureMsg( | ||||
14853 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14854 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); | ||||
14855 | |||||
14856 | VkImage localImage; | ||||
14857 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); | ||||
14858 | m_errorMonitor->VerifyFound(); | ||||
14859 | |||||
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 14860 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 14861 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 14862 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
14863 | VkFormat format = static_cast<VkFormat>(f); | ||||
14864 | VkFormatProperties fProps = m_device->format_properties(format); | ||||
14865 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && | ||||
14866 | fProps.optimalTilingFeatures == 0) { | ||||
14867 | unsupported = format; | ||||
14868 | break; | ||||
14869 | } | ||||
14870 | } | ||||
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 14871 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 14872 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 14873 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 14874 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 14875 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 14876 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 14877 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 14878 | m_errorMonitor->VerifyFound(); |
14879 | } | ||||
14880 | } | ||||
14881 | |||||
14882 | TEST_F(VkLayerTest, ImageLayerViewTests) { | ||||
14883 | VkResult ret; | ||||
14884 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); | ||||
14885 | |||||
14886 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14887 | |||||
14888 | VkImageObj image(m_device); | ||||
14889 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
14890 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | ||||
14891 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
14892 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
14893 | ASSERT_TRUE(image.initialized()); | ||||
14894 | |||||
14895 | VkImageView imgView; | ||||
14896 | VkImageViewCreateInfo imgViewInfo = {}; | ||||
14897 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; | ||||
14898 | imgViewInfo.image = image.handle(); | ||||
14899 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
14900 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
14901 | imgViewInfo.subresourceRange.layerCount = 1; | ||||
14902 | imgViewInfo.subresourceRange.baseMipLevel = 0; | ||||
14903 | imgViewInfo.subresourceRange.levelCount = 1; | ||||
14904 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
14905 | |||||
14906 | m_errorMonitor->SetDesiredFailureMsg( | ||||
14907 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14908 | "vkCreateImageView called with baseMipLevel"); | ||||
14909 | // View can't have baseMipLevel >= image's mipLevels - Expect | ||||
14910 | // VIEW_CREATE_ERROR | ||||
14911 | imgViewInfo.subresourceRange.baseMipLevel = 1; | ||||
14912 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
14913 | m_errorMonitor->VerifyFound(); | ||||
14914 | imgViewInfo.subresourceRange.baseMipLevel = 0; | ||||
14915 | |||||
14916 | m_errorMonitor->SetDesiredFailureMsg( | ||||
14917 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14918 | "vkCreateImageView called with baseArrayLayer"); | ||||
14919 | // View can't have baseArrayLayer >= image's arraySize - Expect | ||||
14920 | // VIEW_CREATE_ERROR | ||||
14921 | imgViewInfo.subresourceRange.baseArrayLayer = 1; | ||||
14922 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
14923 | m_errorMonitor->VerifyFound(); | ||||
14924 | imgViewInfo.subresourceRange.baseArrayLayer = 0; | ||||
14925 | |||||
14926 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14927 | "vkCreateImageView called with 0 in " | ||||
14928 | "pCreateInfo->subresourceRange." | ||||
14929 | "levelCount"); | ||||
14930 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR | ||||
14931 | imgViewInfo.subresourceRange.levelCount = 0; | ||||
14932 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
14933 | m_errorMonitor->VerifyFound(); | ||||
14934 | imgViewInfo.subresourceRange.levelCount = 1; | ||||
14935 | |||||
14936 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14937 | "vkCreateImageView called with 0 in " | ||||
14938 | "pCreateInfo->subresourceRange." | ||||
14939 | "layerCount"); | ||||
14940 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR | ||||
14941 | imgViewInfo.subresourceRange.layerCount = 0; | ||||
14942 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
14943 | m_errorMonitor->VerifyFound(); | ||||
14944 | imgViewInfo.subresourceRange.layerCount = 1; | ||||
14945 | |||||
14946 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14947 | "but both must be color formats"); | ||||
14948 | // Can't use depth format for view into color image - Expect INVALID_FORMAT | ||||
14949 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
14950 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
14951 | m_errorMonitor->VerifyFound(); | ||||
14952 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
14953 | |||||
14954 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14955 | "Formats MUST be IDENTICAL unless " | ||||
14956 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " | ||||
14957 | "was set on image creation."); | ||||
14958 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect | ||||
14959 | // VIEW_CREATE_ERROR | ||||
14960 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; | ||||
14961 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
14962 | m_errorMonitor->VerifyFound(); | ||||
14963 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
14964 | |||||
14965 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
14966 | "can support ImageViews with " | ||||
14967 | "differing formats but they must be " | ||||
14968 | "in the same compatibility class."); | ||||
14969 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect | ||||
14970 | // VIEW_CREATE_ERROR | ||||
14971 | VkImageCreateInfo mutImgInfo = image.create_info(); | ||||
14972 | VkImage mutImage; | ||||
14973 | mutImgInfo.format = VK_FORMAT_R8_UINT; | ||||
14974 | assert( | ||||
14975 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & | ||||
14976 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); | ||||
14977 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; | ||||
14978 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
14979 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); | ||||
14980 | ASSERT_VK_SUCCESS(ret); | ||||
14981 | imgViewInfo.image = mutImage; | ||||
14982 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); | ||||
14983 | m_errorMonitor->VerifyFound(); | ||||
14984 | imgViewInfo.image = image.handle(); | ||||
14985 | vkDestroyImage(m_device->handle(), mutImage, NULL); | ||||
14986 | } | ||||
14987 | |||||
14988 | TEST_F(VkLayerTest, MiscImageLayerTests) { | ||||
14989 | |||||
14990 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); | ||||
14991 | |||||
14992 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
14993 | |||||
14994 | VkImageObj image(m_device); | ||||
14995 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, | ||||
14996 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | | ||||
14997 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, | ||||
14998 | VK_IMAGE_TILING_OPTIMAL, 0); | ||||
14999 | ASSERT_TRUE(image.initialized()); | ||||
15000 | |||||
15001 | m_errorMonitor->SetDesiredFailureMsg( | ||||
15002 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
15003 | "number of layers in image subresource is zero"); | ||||
15004 | vk_testing::Buffer buffer; | ||||
15005 | VkMemoryPropertyFlags reqs = 0; | ||||
15006 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); | ||||
15007 | VkBufferImageCopy region = {}; | ||||
15008 | region.bufferRowLength = 128; | ||||
15009 | region.bufferImageHeight = 128; | ||||
15010 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
15011 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT | ||||
15012 | region.imageSubresource.layerCount = 0; | ||||
15013 | region.imageExtent.height = 4; | ||||
15014 | region.imageExtent.width = 4; | ||||
15015 | region.imageExtent.depth = 1; | ||||
15016 | m_commandBuffer->BeginCommandBuffer(); | ||||
15017 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), | ||||
15018 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
15019 | 1, ®ion); | ||||
15020 | m_errorMonitor->VerifyFound(); | ||||
15021 | region.imageSubresource.layerCount = 1; | ||||
15022 | |||||
15023 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
15024 | "aspectMasks for each region must " | ||||
15025 | "specify only COLOR or DEPTH or " | ||||
15026 | "STENCIL"); | ||||
15027 | // Expect MISMATCHED_IMAGE_ASPECT | ||||
15028 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; | ||||
15029 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), | ||||
15030 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, | ||||
15031 | 1, ®ion); | ||||
15032 | m_errorMonitor->VerifyFound(); | ||||
15033 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
15034 | |||||
15035 | m_errorMonitor->SetDesiredFailureMsg( | ||||
15036 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
15037 | "If the format of srcImage is a depth, stencil, depth stencil or " | ||||
15038 | "integer-based format then filter must be VK_FILTER_NEAREST"); | ||||
15039 | // Expect INVALID_FILTER | ||||
15040 | VkImageObj intImage1(m_device); | ||||
15041 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, | ||||
15042 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, | ||||
15043 | 0); | ||||
15044 | VkImageObj intImage2(m_device); | ||||
15045 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, | ||||
15046 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, | ||||
15047 | 0); | ||||
15048 | VkImageBlit blitRegion = {}; | ||||
15049 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
15050 | blitRegion.srcSubresource.baseArrayLayer = 0; | ||||
15051 | blitRegion.srcSubresource.layerCount = 1; | ||||
15052 | blitRegion.srcSubresource.mipLevel = 0; | ||||
15053 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
15054 | blitRegion.dstSubresource.baseArrayLayer = 0; | ||||
15055 | blitRegion.dstSubresource.layerCount = 1; | ||||
15056 | blitRegion.dstSubresource.mipLevel = 0; | ||||
15057 | |||||
15058 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), | ||||
15059 | intImage1.layout(), intImage2.handle(), intImage2.layout(), | ||||
15060 | 16, &blitRegion, VK_FILTER_LINEAR); | ||||
15061 | m_errorMonitor->VerifyFound(); | ||||
15062 | |||||
15063 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
15064 | "called with 0 in ppMemoryBarriers"); | ||||
15065 | VkImageMemoryBarrier img_barrier; | ||||
15066 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; | ||||
15067 | img_barrier.pNext = NULL; | ||||
15068 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; | ||||
15069 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; | ||||
15070 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
15071 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
15072 | img_barrier.image = image.handle(); | ||||
15073 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
15074 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; | ||||
15075 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
15076 | img_barrier.subresourceRange.baseArrayLayer = 0; | ||||
15077 | img_barrier.subresourceRange.baseMipLevel = 0; | ||||
15078 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE | ||||
15079 | img_barrier.subresourceRange.layerCount = 0; | ||||
15080 | img_barrier.subresourceRange.levelCount = 1; | ||||
15081 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), | ||||
15082 | VK_PIPELINE_STAGE_HOST_BIT, | ||||
15083 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, | ||||
15084 | nullptr, 1, &img_barrier); | ||||
15085 | m_errorMonitor->VerifyFound(); | ||||
15086 | img_barrier.subresourceRange.layerCount = 1; | ||||
15087 | } | ||||
15088 | |||||
15089 | TEST_F(VkLayerTest, ImageFormatLimits) { | ||||
15090 | |||||
15091 | TEST_DESCRIPTION("Exceed the limits of image format "); | ||||
15092 | |||||
15093 | m_errorMonitor->SetDesiredFailureMsg( | ||||
15094 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
15095 | "CreateImage extents exceed allowable limits for format"); | ||||
15096 | VkImageCreateInfo image_create_info = {}; | ||||
15097 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
15098 | image_create_info.pNext = NULL; | ||||
15099 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
15100 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
15101 | image_create_info.extent.width = 32; | ||||
15102 | image_create_info.extent.height = 32; | ||||
15103 | image_create_info.extent.depth = 1; | ||||
15104 | image_create_info.mipLevels = 1; | ||||
15105 | image_create_info.arrayLayers = 1; | ||||
15106 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
15107 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
15108 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
15109 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; | ||||
15110 | image_create_info.flags = 0; | ||||
15111 | |||||
15112 | VkImage nullImg; | ||||
15113 | VkImageFormatProperties imgFmtProps; | ||||
15114 | vkGetPhysicalDeviceImageFormatProperties( | ||||
15115 | gpu(), image_create_info.format, image_create_info.imageType, | ||||
15116 | image_create_info.tiling, image_create_info.usage, | ||||
15117 | image_create_info.flags, &imgFmtProps); | ||||
15118 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; | ||||
15119 | // Expect INVALID_FORMAT_LIMITS_VIOLATION | ||||
15120 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
15121 | m_errorMonitor->VerifyFound(); | ||||
15122 | image_create_info.extent.depth = 1; | ||||
15123 | |||||
15124 | m_errorMonitor->SetDesiredFailureMsg( | ||||
15125 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
15126 | "exceeds allowable maximum supported by format of"); | ||||
15127 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; | ||||
15128 | // Expect INVALID_FORMAT_LIMITS_VIOLATION | ||||
15129 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
15130 | m_errorMonitor->VerifyFound(); | ||||
15131 | image_create_info.mipLevels = 1; | ||||
15132 | |||||
15133 | m_errorMonitor->SetDesiredFailureMsg( | ||||
15134 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
15135 | "exceeds allowable maximum supported by format of"); | ||||
15136 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; | ||||
15137 | // Expect INVALID_FORMAT_LIMITS_VIOLATION | ||||
15138 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
15139 | m_errorMonitor->VerifyFound(); | ||||
15140 | image_create_info.arrayLayers = 1; | ||||
15141 | |||||
15142 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
15143 | "is not supported by format"); | ||||
15144 | int samples = imgFmtProps.sampleCounts >> 1; | ||||
15145 | image_create_info.samples = (VkSampleCountFlagBits)samples; | ||||
15146 | // Expect INVALID_FORMAT_LIMITS_VIOLATION | ||||
15147 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
15148 | m_errorMonitor->VerifyFound(); | ||||
15149 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
15150 | |||||
15151 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
15152 | "pCreateInfo->initialLayout, must be " | ||||
15153 | "VK_IMAGE_LAYOUT_UNDEFINED or " | ||||
15154 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); | ||||
15155 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | ||||
15156 | // Expect INVALID_LAYOUT | ||||
15157 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); | ||||
15158 | m_errorMonitor->VerifyFound(); | ||||
15159 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; | ||||
15160 | } | ||||
15161 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15162 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 15163 | VkResult err; |
15164 | bool pass; | ||||
15165 | |||||
15166 | // Create color images with different format sizes and try to copy between them | ||||
15167 | m_errorMonitor->SetDesiredFailureMsg( | ||||
15168 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
15169 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); | ||||
15170 | |||||
15171 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
15172 | |||||
15173 | // Create two images of different types and try to copy between them | ||||
15174 | VkImage srcImage; | ||||
15175 | VkImage dstImage; | ||||
15176 | VkDeviceMemory srcMem; | ||||
15177 | VkDeviceMemory destMem; | ||||
15178 | VkMemoryRequirements memReqs; | ||||
15179 | |||||
15180 | VkImageCreateInfo image_create_info = {}; | ||||
15181 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
15182 | image_create_info.pNext = NULL; | ||||
15183 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
15184 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
15185 | image_create_info.extent.width = 32; | ||||
15186 | image_create_info.extent.height = 32; | ||||
15187 | image_create_info.extent.depth = 1; | ||||
15188 | image_create_info.mipLevels = 1; | ||||
15189 | image_create_info.arrayLayers = 1; | ||||
15190 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
15191 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
15192 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
15193 | image_create_info.flags = 0; | ||||
15194 | |||||
15195 | err = | ||||
15196 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
15197 | ASSERT_VK_SUCCESS(err); | ||||
15198 | |||||
15199 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; | ||||
15200 | // Introduce failure by creating second image with a different-sized format. | ||||
15201 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; | ||||
15202 | |||||
15203 | err = | ||||
15204 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
15205 | ASSERT_VK_SUCCESS(err); | ||||
15206 | |||||
15207 | // Allocate memory | ||||
15208 | VkMemoryAllocateInfo memAlloc = {}; | ||||
15209 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; | ||||
15210 | memAlloc.pNext = NULL; | ||||
15211 | memAlloc.allocationSize = 0; | ||||
15212 | memAlloc.memoryTypeIndex = 0; | ||||
15213 | |||||
15214 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); | ||||
15215 | memAlloc.allocationSize = memReqs.size; | ||||
15216 | pass = | ||||
15217 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
15218 | ASSERT_TRUE(pass); | ||||
15219 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); | ||||
15220 | ASSERT_VK_SUCCESS(err); | ||||
15221 | |||||
15222 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); | ||||
15223 | memAlloc.allocationSize = memReqs.size; | ||||
15224 | pass = | ||||
15225 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
15226 | ASSERT_TRUE(pass); | ||||
15227 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); | ||||
15228 | ASSERT_VK_SUCCESS(err); | ||||
15229 | |||||
15230 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
15231 | ASSERT_VK_SUCCESS(err); | ||||
15232 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); | ||||
15233 | ASSERT_VK_SUCCESS(err); | ||||
15234 | |||||
15235 | BeginCommandBuffer(); | ||||
15236 | VkImageCopy copyRegion; | ||||
15237 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
15238 | copyRegion.srcSubresource.mipLevel = 0; | ||||
15239 | copyRegion.srcSubresource.baseArrayLayer = 0; | ||||
15240 | copyRegion.srcSubresource.layerCount = 0; | ||||
15241 | copyRegion.srcOffset.x = 0; | ||||
15242 | copyRegion.srcOffset.y = 0; | ||||
15243 | copyRegion.srcOffset.z = 0; | ||||
15244 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; | ||||
15245 | copyRegion.dstSubresource.mipLevel = 0; | ||||
15246 | copyRegion.dstSubresource.baseArrayLayer = 0; | ||||
15247 | copyRegion.dstSubresource.layerCount = 0; | ||||
15248 | copyRegion.dstOffset.x = 0; | ||||
15249 | copyRegion.dstOffset.y = 0; | ||||
15250 | copyRegion.dstOffset.z = 0; | ||||
15251 | copyRegion.extent.width = 1; | ||||
15252 | copyRegion.extent.height = 1; | ||||
15253 | copyRegion.extent.depth = 1; | ||||
15254 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, | ||||
15255 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
15256 | EndCommandBuffer(); | ||||
15257 | |||||
15258 | m_errorMonitor->VerifyFound(); | ||||
15259 | |||||
15260 | vkDestroyImage(m_device->device(), srcImage, NULL); | ||||
15261 | vkDestroyImage(m_device->device(), dstImage, NULL); | ||||
15262 | vkFreeMemory(m_device->device(), srcMem, NULL); | ||||
15263 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15264 | } |
15265 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15266 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
15267 | VkResult err; | ||||
15268 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15269 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 15270 | // 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] | 15271 | m_errorMonitor->SetDesiredFailureMsg( |
15272 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 15273 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 15274 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15275 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15276 | |
15277 | // Create two images of different types and try to copy between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15278 | VkImage srcImage; |
15279 | VkImage dstImage; | ||||
15280 | VkDeviceMemory srcMem; | ||||
15281 | VkDeviceMemory destMem; | ||||
15282 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15283 | |
15284 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15285 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
15286 | image_create_info.pNext = NULL; | ||||
15287 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
15288 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
15289 | image_create_info.extent.width = 32; | ||||
15290 | image_create_info.extent.height = 32; | ||||
15291 | image_create_info.extent.depth = 1; | ||||
15292 | image_create_info.mipLevels = 1; | ||||
15293 | image_create_info.arrayLayers = 1; | ||||
15294 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
15295 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
15296 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
15297 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15298 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15299 | err = |
15300 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15301 | ASSERT_VK_SUCCESS(err); |
15302 | |||||
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 15303 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
15304 | |||||
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 15305 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15306 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 15307 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
15308 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15309 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15310 | err = |
15311 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15312 | ASSERT_VK_SUCCESS(err); |
15313 | |||||
15314 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15315 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15316 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
15317 | memAlloc.pNext = NULL; | ||||
15318 | memAlloc.allocationSize = 0; | ||||
15319 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15320 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 15321 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15322 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15323 | pass = |
15324 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 15325 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15326 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15327 | ASSERT_VK_SUCCESS(err); |
15328 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15329 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15330 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15331 | pass = |
15332 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 15333 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15334 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15335 | ASSERT_VK_SUCCESS(err); |
15336 | |||||
15337 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
15338 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15339 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15340 | ASSERT_VK_SUCCESS(err); |
15341 | |||||
15342 | BeginCommandBuffer(); | ||||
15343 | VkImageCopy copyRegion; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 15344 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15345 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 15346 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15347 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15348 | copyRegion.srcOffset.x = 0; |
15349 | copyRegion.srcOffset.y = 0; | ||||
15350 | copyRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 15351 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15352 | copyRegion.dstSubresource.mipLevel = 0; |
15353 | copyRegion.dstSubresource.baseArrayLayer = 0; | ||||
15354 | copyRegion.dstSubresource.layerCount = 0; | ||||
15355 | copyRegion.dstOffset.x = 0; | ||||
15356 | copyRegion.dstOffset.y = 0; | ||||
15357 | copyRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15358 | copyRegion.extent.width = 1; |
15359 | copyRegion.extent.height = 1; | ||||
15360 | copyRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15361 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
15362 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15363 | EndCommandBuffer(); |
15364 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 15365 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15366 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 15367 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15368 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 15369 | vkFreeMemory(m_device->device(), srcMem, NULL); |
15370 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15371 | } |
15372 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15373 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
15374 | VkResult err; | ||||
15375 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15376 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15377 | m_errorMonitor->SetDesiredFailureMsg( |
15378 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 15379 | "vkCmdResolveImage called with source sample count less than 2."); |
15380 | |||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15381 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15382 | |
15383 | // 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] | 15384 | VkImage srcImage; |
15385 | VkImage dstImage; | ||||
15386 | VkDeviceMemory srcMem; | ||||
15387 | VkDeviceMemory destMem; | ||||
15388 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15389 | |
15390 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15391 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
15392 | image_create_info.pNext = NULL; | ||||
15393 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
15394 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
15395 | image_create_info.extent.width = 32; | ||||
15396 | image_create_info.extent.height = 1; | ||||
15397 | image_create_info.extent.depth = 1; | ||||
15398 | image_create_info.mipLevels = 1; | ||||
15399 | image_create_info.arrayLayers = 1; | ||||
15400 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
15401 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
15402 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; | ||||
15403 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15404 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15405 | err = |
15406 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15407 | ASSERT_VK_SUCCESS(err); |
15408 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15409 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15410 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15411 | err = |
15412 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15413 | ASSERT_VK_SUCCESS(err); |
15414 | |||||
15415 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15416 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15417 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
15418 | memAlloc.pNext = NULL; | ||||
15419 | memAlloc.allocationSize = 0; | ||||
15420 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15421 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 15422 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15423 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15424 | pass = |
15425 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 15426 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15427 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15428 | ASSERT_VK_SUCCESS(err); |
15429 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15430 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15431 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15432 | pass = |
15433 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 15434 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15435 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15436 | ASSERT_VK_SUCCESS(err); |
15437 | |||||
15438 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
15439 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15440 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15441 | ASSERT_VK_SUCCESS(err); |
15442 | |||||
15443 | BeginCommandBuffer(); | ||||
15444 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15445 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
15446 | // VK_IMAGE_LAYOUT_GENERAL = 1, | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15447 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 15448 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15449 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 15450 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15451 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15452 | resolveRegion.srcOffset.x = 0; |
15453 | resolveRegion.srcOffset.y = 0; | ||||
15454 | resolveRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 15455 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15456 | resolveRegion.dstSubresource.mipLevel = 0; |
15457 | resolveRegion.dstSubresource.baseArrayLayer = 0; | ||||
15458 | resolveRegion.dstSubresource.layerCount = 0; | ||||
15459 | resolveRegion.dstOffset.x = 0; | ||||
15460 | resolveRegion.dstOffset.y = 0; | ||||
15461 | resolveRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15462 | resolveRegion.extent.width = 1; |
15463 | resolveRegion.extent.height = 1; | ||||
15464 | resolveRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15465 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
15466 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15467 | EndCommandBuffer(); |
15468 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 15469 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15470 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 15471 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15472 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 15473 | vkFreeMemory(m_device->device(), srcMem, NULL); |
15474 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15475 | } |
15476 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15477 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
15478 | VkResult err; | ||||
15479 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15480 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15481 | m_errorMonitor->SetDesiredFailureMsg( |
15482 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 15483 | "vkCmdResolveImage called with dest sample count greater than 1."); |
15484 | |||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15485 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15486 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 15487 | // 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] | 15488 | VkImage srcImage; |
15489 | VkImage dstImage; | ||||
15490 | VkDeviceMemory srcMem; | ||||
15491 | VkDeviceMemory destMem; | ||||
15492 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15493 | |
15494 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15495 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
15496 | image_create_info.pNext = NULL; | ||||
15497 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
15498 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
15499 | image_create_info.extent.width = 32; | ||||
15500 | image_create_info.extent.height = 1; | ||||
15501 | image_create_info.extent.depth = 1; | ||||
15502 | image_create_info.mipLevels = 1; | ||||
15503 | image_create_info.arrayLayers = 1; | ||||
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 15504 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15505 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
15506 | // Note: Some implementations expect color attachment usage for any | ||||
15507 | // multisample surface | ||||
15508 | image_create_info.usage = | ||||
15509 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
15510 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15511 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15512 | err = |
15513 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15514 | ASSERT_VK_SUCCESS(err); |
15515 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15516 | // Note: Some implementations expect color attachment usage for any |
15517 | // multisample surface | ||||
15518 | image_create_info.usage = | ||||
15519 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15520 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15521 | err = |
15522 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15523 | ASSERT_VK_SUCCESS(err); |
15524 | |||||
15525 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15526 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15527 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
15528 | memAlloc.pNext = NULL; | ||||
15529 | memAlloc.allocationSize = 0; | ||||
15530 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15531 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 15532 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15533 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15534 | pass = |
15535 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 15536 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15537 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15538 | ASSERT_VK_SUCCESS(err); |
15539 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15540 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15541 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15542 | pass = |
15543 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 15544 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15545 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15546 | ASSERT_VK_SUCCESS(err); |
15547 | |||||
15548 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
15549 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15550 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15551 | ASSERT_VK_SUCCESS(err); |
15552 | |||||
15553 | BeginCommandBuffer(); | ||||
15554 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15555 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
15556 | // VK_IMAGE_LAYOUT_GENERAL = 1, | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15557 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 15558 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15559 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 15560 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15561 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15562 | resolveRegion.srcOffset.x = 0; |
15563 | resolveRegion.srcOffset.y = 0; | ||||
15564 | resolveRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 15565 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15566 | resolveRegion.dstSubresource.mipLevel = 0; |
15567 | resolveRegion.dstSubresource.baseArrayLayer = 0; | ||||
15568 | resolveRegion.dstSubresource.layerCount = 0; | ||||
15569 | resolveRegion.dstOffset.x = 0; | ||||
15570 | resolveRegion.dstOffset.y = 0; | ||||
15571 | resolveRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15572 | resolveRegion.extent.width = 1; |
15573 | resolveRegion.extent.height = 1; | ||||
15574 | resolveRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15575 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
15576 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15577 | EndCommandBuffer(); |
15578 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 15579 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15580 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 15581 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15582 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 15583 | vkFreeMemory(m_device->device(), srcMem, NULL); |
15584 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15585 | } |
15586 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15587 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
15588 | VkResult err; | ||||
15589 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15590 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15591 | m_errorMonitor->SetDesiredFailureMsg( |
15592 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 15593 | "vkCmdResolveImage called with unmatched source and dest formats."); |
15594 | |||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15595 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15596 | |
15597 | // Create two images of different types and try to copy between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15598 | VkImage srcImage; |
15599 | VkImage dstImage; | ||||
15600 | VkDeviceMemory srcMem; | ||||
15601 | VkDeviceMemory destMem; | ||||
15602 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15603 | |
15604 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15605 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
15606 | image_create_info.pNext = NULL; | ||||
15607 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
15608 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
15609 | image_create_info.extent.width = 32; | ||||
15610 | image_create_info.extent.height = 1; | ||||
15611 | image_create_info.extent.depth = 1; | ||||
15612 | image_create_info.mipLevels = 1; | ||||
15613 | image_create_info.arrayLayers = 1; | ||||
15614 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; | ||||
15615 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
15616 | // Note: Some implementations expect color attachment usage for any | ||||
15617 | // multisample surface | ||||
15618 | image_create_info.usage = | ||||
15619 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
15620 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15621 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15622 | err = |
15623 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15624 | ASSERT_VK_SUCCESS(err); |
15625 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15626 | // Set format to something other than source image |
15627 | image_create_info.format = VK_FORMAT_R32_SFLOAT; | ||||
15628 | // Note: Some implementations expect color attachment usage for any | ||||
15629 | // multisample surface | ||||
15630 | image_create_info.usage = | ||||
15631 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
15632 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15633 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15634 | err = |
15635 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15636 | ASSERT_VK_SUCCESS(err); |
15637 | |||||
15638 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15639 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15640 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
15641 | memAlloc.pNext = NULL; | ||||
15642 | memAlloc.allocationSize = 0; | ||||
15643 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15644 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 15645 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15646 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15647 | pass = |
15648 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 15649 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15650 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15651 | ASSERT_VK_SUCCESS(err); |
15652 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15653 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15654 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15655 | pass = |
15656 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 15657 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15658 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15659 | ASSERT_VK_SUCCESS(err); |
15660 | |||||
15661 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
15662 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15663 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15664 | ASSERT_VK_SUCCESS(err); |
15665 | |||||
15666 | BeginCommandBuffer(); | ||||
15667 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15668 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
15669 | // VK_IMAGE_LAYOUT_GENERAL = 1, | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15670 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 15671 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15672 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 15673 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15674 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15675 | resolveRegion.srcOffset.x = 0; |
15676 | resolveRegion.srcOffset.y = 0; | ||||
15677 | resolveRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 15678 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15679 | resolveRegion.dstSubresource.mipLevel = 0; |
15680 | resolveRegion.dstSubresource.baseArrayLayer = 0; | ||||
15681 | resolveRegion.dstSubresource.layerCount = 0; | ||||
15682 | resolveRegion.dstOffset.x = 0; | ||||
15683 | resolveRegion.dstOffset.y = 0; | ||||
15684 | resolveRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15685 | resolveRegion.extent.width = 1; |
15686 | resolveRegion.extent.height = 1; | ||||
15687 | resolveRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15688 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
15689 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15690 | EndCommandBuffer(); |
15691 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 15692 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15693 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 15694 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15695 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 15696 | vkFreeMemory(m_device->device(), srcMem, NULL); |
15697 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15698 | } |
15699 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15700 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
15701 | VkResult err; | ||||
15702 | bool pass; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15703 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15704 | m_errorMonitor->SetDesiredFailureMsg( |
15705 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 15706 | "vkCmdResolveImage called with unmatched source and dest image types."); |
15707 | |||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15708 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15709 | |
15710 | // Create two images of different types and try to copy between them | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15711 | VkImage srcImage; |
15712 | VkImage dstImage; | ||||
15713 | VkDeviceMemory srcMem; | ||||
15714 | VkDeviceMemory destMem; | ||||
15715 | VkMemoryRequirements memReqs; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15716 | |
15717 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15718 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
15719 | image_create_info.pNext = NULL; | ||||
15720 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
15721 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
15722 | image_create_info.extent.width = 32; | ||||
15723 | image_create_info.extent.height = 1; | ||||
15724 | image_create_info.extent.depth = 1; | ||||
15725 | image_create_info.mipLevels = 1; | ||||
15726 | image_create_info.arrayLayers = 1; | ||||
15727 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; | ||||
15728 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
15729 | // Note: Some implementations expect color attachment usage for any | ||||
15730 | // multisample surface | ||||
15731 | image_create_info.usage = | ||||
15732 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
15733 | image_create_info.flags = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15734 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15735 | err = |
15736 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15737 | ASSERT_VK_SUCCESS(err); |
15738 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15739 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
15740 | // Note: Some implementations expect color attachment usage for any | ||||
15741 | // multisample surface | ||||
15742 | image_create_info.usage = | ||||
15743 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
15744 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15745 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15746 | err = |
15747 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15748 | ASSERT_VK_SUCCESS(err); |
15749 | |||||
15750 | // Allocate memory | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15751 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15752 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
15753 | memAlloc.pNext = NULL; | ||||
15754 | memAlloc.allocationSize = 0; | ||||
15755 | memAlloc.memoryTypeIndex = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15756 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 15757 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15758 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15759 | pass = |
15760 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 15761 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15762 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15763 | ASSERT_VK_SUCCESS(err); |
15764 | |||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15765 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15766 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15767 | pass = |
15768 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); | ||||
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 15769 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15770 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15771 | ASSERT_VK_SUCCESS(err); |
15772 | |||||
15773 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); | ||||
15774 | ASSERT_VK_SUCCESS(err); | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15775 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15776 | ASSERT_VK_SUCCESS(err); |
15777 | |||||
15778 | BeginCommandBuffer(); | ||||
15779 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15780 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
15781 | // VK_IMAGE_LAYOUT_GENERAL = 1, | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15782 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 15783 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15784 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 15785 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15786 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15787 | resolveRegion.srcOffset.x = 0; |
15788 | resolveRegion.srcOffset.y = 0; | ||||
15789 | resolveRegion.srcOffset.z = 0; | ||||
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 15790 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15791 | resolveRegion.dstSubresource.mipLevel = 0; |
15792 | resolveRegion.dstSubresource.baseArrayLayer = 0; | ||||
15793 | resolveRegion.dstSubresource.layerCount = 0; | ||||
15794 | resolveRegion.dstOffset.x = 0; | ||||
15795 | resolveRegion.dstOffset.y = 0; | ||||
15796 | resolveRegion.dstOffset.z = 0; | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15797 | resolveRegion.extent.width = 1; |
15798 | resolveRegion.extent.height = 1; | ||||
15799 | resolveRegion.extent.depth = 1; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15800 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
15801 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15802 | EndCommandBuffer(); |
15803 | |||||
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 15804 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15805 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 15806 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15807 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 15808 | vkFreeMemory(m_device->device(), srcMem, NULL); |
15809 | vkFreeMemory(m_device->device(), destMem, NULL); | ||||
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 15810 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15811 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15812 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15813 | // 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] | 15814 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
15815 | // set in aspect | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15816 | // The image format check comes 2nd in validation so we trigger it first, |
15817 | // 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] | 15818 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15820 | m_errorMonitor->SetDesiredFailureMsg( |
15821 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 15822 | "Combination depth/stencil image formats can have only the "); |
15823 | |||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15824 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 15825 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 15826 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15827 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
15828 | ds_type_count.descriptorCount = 1; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15829 | |
15830 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15831 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
15832 | ds_pool_ci.pNext = NULL; | ||||
15833 | ds_pool_ci.maxSets = 1; | ||||
15834 | ds_pool_ci.poolSizeCount = 1; | ||||
15835 | ds_pool_ci.pPoolSizes = &ds_type_count; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15836 | |
15837 | VkDescriptorPool ds_pool; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15838 | err = |
15839 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15840 | ASSERT_VK_SUCCESS(err); |
15841 | |||||
15842 | VkDescriptorSetLayoutBinding dsl_binding = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15843 | dsl_binding.binding = 0; |
15844 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; | ||||
15845 | dsl_binding.descriptorCount = 1; | ||||
15846 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; | ||||
15847 | dsl_binding.pImmutableSamplers = NULL; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15848 | |
15849 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15850 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
15851 | ds_layout_ci.pNext = NULL; | ||||
15852 | ds_layout_ci.bindingCount = 1; | ||||
15853 | ds_layout_ci.pBindings = &dsl_binding; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15854 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15855 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
15856 | &ds_layout); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15857 | ASSERT_VK_SUCCESS(err); |
15858 | |||||
15859 | VkDescriptorSet descriptorSet; | ||||
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 15860 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 15861 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 15862 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15863 | alloc_info.descriptorPool = ds_pool; |
15864 | alloc_info.pSetLayouts = &ds_layout; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15865 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
15866 | &descriptorSet); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15867 | ASSERT_VK_SUCCESS(err); |
15868 | |||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15869 | VkImage image_bad; |
15870 | VkImage image_good; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15871 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 15872 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15873 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15874 | const int32_t tex_width = 32; |
15875 | const int32_t tex_height = 32; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15876 | |
15877 | VkImageCreateInfo image_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15878 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
15879 | image_create_info.pNext = NULL; | ||||
15880 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
15881 | image_create_info.format = tex_format_bad; | ||||
15882 | image_create_info.extent.width = tex_width; | ||||
15883 | image_create_info.extent.height = tex_height; | ||||
15884 | image_create_info.extent.depth = 1; | ||||
15885 | image_create_info.mipLevels = 1; | ||||
15886 | image_create_info.arrayLayers = 1; | ||||
15887 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
15888 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
15889 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | | ||||
15890 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; | ||||
15891 | image_create_info.flags = 0; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15892 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15893 | err = |
15894 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15895 | ASSERT_VK_SUCCESS(err); |
15896 | image_create_info.format = tex_format_good; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15897 | image_create_info.usage = |
15898 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; | ||||
15899 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, | ||||
15900 | &image_good); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15901 | ASSERT_VK_SUCCESS(err); |
15902 | |||||
15903 | VkImageViewCreateInfo image_view_create_info = {}; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15904 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
15905 | image_view_create_info.image = image_bad; | ||||
15906 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; | ||||
15907 | image_view_create_info.format = tex_format_bad; | ||||
15908 | image_view_create_info.subresourceRange.baseArrayLayer = 0; | ||||
15909 | image_view_create_info.subresourceRange.baseMipLevel = 0; | ||||
15910 | image_view_create_info.subresourceRange.layerCount = 1; | ||||
15911 | image_view_create_info.subresourceRange.levelCount = 1; | ||||
15912 | image_view_create_info.subresourceRange.aspectMask = | ||||
15913 | VK_IMAGE_ASPECT_COLOR_BIT; | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15914 | |
15915 | VkImageView view; | ||||
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 15916 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
15917 | &view); | ||||
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 15918 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 15919 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15920 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 15921 | vkDestroyImage(m_device->device(), image_bad, NULL); |
15922 | vkDestroyImage(m_device->device(), image_good, NULL); | ||||
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 15923 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
15924 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); | ||||
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 15925 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 15926 | |
15927 | TEST_F(VkLayerTest, ClearImageErrors) { | ||||
15928 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " | ||||
15929 | "ClearDepthStencilImage with a color image."); | ||||
15930 | |||||
15931 | ASSERT_NO_FATAL_FAILURE(InitState()); | ||||
15932 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); | ||||
15933 | |||||
15934 | // Renderpass is started here so end it as Clear cmds can't be in renderpass | ||||
15935 | BeginCommandBuffer(); | ||||
15936 | m_commandBuffer->EndRenderPass(); | ||||
15937 | |||||
15938 | // Color image | ||||
15939 | VkClearColorValue clear_color; | ||||
15940 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); | ||||
15941 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; | ||||
15942 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; | ||||
15943 | const int32_t img_width = 32; | ||||
15944 | const int32_t img_height = 32; | ||||
15945 | VkImageCreateInfo image_create_info = {}; | ||||
15946 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; | ||||
15947 | image_create_info.pNext = NULL; | ||||
15948 | image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
15949 | image_create_info.format = color_format; | ||||
15950 | image_create_info.extent.width = img_width; | ||||
15951 | image_create_info.extent.height = img_height; | ||||
15952 | image_create_info.extent.depth = 1; | ||||
15953 | image_create_info.mipLevels = 1; | ||||
15954 | image_create_info.arrayLayers = 1; | ||||
15955 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; | ||||
15956 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; | ||||
15957 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; | ||||
15958 | |||||
15959 | vk_testing::Image color_image; | ||||
15960 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, | ||||
15961 | reqs); | ||||
15962 | |||||
15963 | const VkImageSubresourceRange color_range = | ||||
15964 | vk_testing::Image::subresource_range(image_create_info, | ||||
15965 | VK_IMAGE_ASPECT_COLOR_BIT); | ||||
15966 | |||||
15967 | // Depth/Stencil image | ||||
15968 | VkClearDepthStencilValue clear_value = {0}; | ||||
15969 | reqs = 0; // don't need HOST_VISIBLE DS image | ||||
15970 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); | ||||
15971 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; | ||||
15972 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; | ||||
15973 | ds_image_create_info.extent.width = 64; | ||||
15974 | ds_image_create_info.extent.height = 64; | ||||
15975 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; | ||||
15976 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; | ||||
15977 | |||||
15978 | vk_testing::Image ds_image; | ||||
15979 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, | ||||
15980 | reqs); | ||||
15981 | |||||
15982 | const VkImageSubresourceRange ds_range = | ||||
15983 | vk_testing::Image::subresource_range(ds_image_create_info, | ||||
15984 | VK_IMAGE_ASPECT_DEPTH_BIT); | ||||
15985 | |||||
15986 | m_errorMonitor->SetDesiredFailureMsg( | ||||
15987 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
15988 | "vkCmdClearColorImage called with depth/stencil image."); | ||||
15989 | |||||
15990 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), | ||||
15991 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, | ||||
15992 | &color_range); | ||||
15993 | |||||
15994 | m_errorMonitor->VerifyFound(); | ||||
15995 | |||||
Tony Barbour | 26434b9 | 2016-06-02 09:43:50 -0600 | [diff] [blame] | 15996 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
15997 | "vkCmdClearColorImage called with " | ||||
15998 | "image created without " | ||||
15999 | "VK_IMAGE_USAGE_TRANSFER_DST_BIT"); | ||||
16000 | |||||
16001 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), | ||||
16002 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, | ||||
16003 | &color_range); | ||||
16004 | |||||
16005 | m_errorMonitor->VerifyFound(); | ||||
16006 | |||||
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 16007 | // Call CmdClearDepthStencilImage with color image |
16008 | m_errorMonitor->SetDesiredFailureMsg( | ||||
16009 | VK_DEBUG_REPORT_ERROR_BIT_EXT, | ||||
16010 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); | ||||
16011 | |||||
16012 | vkCmdClearDepthStencilImage( | ||||
16013 | m_commandBuffer->GetBufferHandle(), color_image.handle(), | ||||
16014 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, | ||||
16015 | &ds_range); | ||||
16016 | |||||
16017 | m_errorMonitor->VerifyFound(); | ||||
16018 | } | ||||
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 16019 | #endif // IMAGE_TESTS |
16020 | |||||
Cody Northrop | 1242dfd | 2016-07-13 17:24:59 -0600 | [diff] [blame] | 16021 | #if defined(ANDROID) && defined(VALIDATION_APK) |
16022 | static bool initialized = false; | ||||
16023 | static bool active = false; | ||||
16024 | |||||
16025 | // Convert Intents to argv | ||||
16026 | // Ported from Hologram sample, only difference is flexible key | ||||
16027 | std::vector<std::string> get_args(android_app &app, const char* intent_extra_data_key) | ||||
16028 | { | ||||
16029 | std::vector<std::string> args; | ||||
16030 | JavaVM &vm = *app.activity->vm; | ||||
16031 | JNIEnv *p_env; | ||||
16032 | if (vm.AttachCurrentThread(&p_env, nullptr) != JNI_OK) | ||||
16033 | return args; | ||||
16034 | |||||
16035 | JNIEnv &env = *p_env; | ||||
16036 | jobject activity = app.activity->clazz; | ||||
16037 | jmethodID get_intent_method = env.GetMethodID(env.GetObjectClass(activity), | ||||
16038 | "getIntent", "()Landroid/content/Intent;"); | ||||
16039 | jobject intent = env.CallObjectMethod(activity, get_intent_method); | ||||
16040 | jmethodID get_string_extra_method = env.GetMethodID(env.GetObjectClass(intent), | ||||
16041 | "getStringExtra", "(Ljava/lang/String;)Ljava/lang/String;"); | ||||
16042 | jvalue get_string_extra_args; | ||||
16043 | get_string_extra_args.l = env.NewStringUTF(intent_extra_data_key); | ||||
16044 | jstring extra_str = static_cast<jstring>(env.CallObjectMethodA(intent, | ||||
16045 | get_string_extra_method, &get_string_extra_args)); | ||||
16046 | |||||
16047 | std::string args_str; | ||||
16048 | if (extra_str) { | ||||
16049 | const char *extra_utf = env.GetStringUTFChars(extra_str, nullptr); | ||||
16050 | args_str = extra_utf; | ||||
16051 | env.ReleaseStringUTFChars(extra_str, extra_utf); | ||||
16052 | env.DeleteLocalRef(extra_str); | ||||
16053 | } | ||||
16054 | |||||
16055 | env.DeleteLocalRef(get_string_extra_args.l); | ||||
16056 | env.DeleteLocalRef(intent); | ||||
16057 | vm.DetachCurrentThread(); | ||||
16058 | |||||
16059 | // split args_str | ||||
16060 | std::stringstream ss(args_str); | ||||
16061 | std::string arg; | ||||
16062 | while (std::getline(ss, arg, ' ')) { | ||||
16063 | if (!arg.empty()) | ||||
16064 | args.push_back(arg); | ||||
16065 | } | ||||
16066 | |||||
16067 | return args; | ||||
16068 | } | ||||
16069 | |||||
16070 | |||||
16071 | static int32_t processInput(struct android_app* app, AInputEvent* event) { | ||||
16072 | return 0; | ||||
16073 | } | ||||
16074 | |||||
16075 | static void processCommand(struct android_app* app, int32_t cmd) { | ||||
16076 | switch(cmd) { | ||||
16077 | case APP_CMD_INIT_WINDOW: { | ||||
16078 | if (app->window) { | ||||
16079 | initialized = true; | ||||
16080 | } | ||||
16081 | break; | ||||
16082 | } | ||||
16083 | case APP_CMD_GAINED_FOCUS: { | ||||
16084 | active = true; | ||||
16085 | break; | ||||
16086 | } | ||||
16087 | case APP_CMD_LOST_FOCUS: { | ||||
16088 | active = false; | ||||
16089 | break; | ||||
16090 | } | ||||
16091 | } | ||||
16092 | } | ||||
16093 | |||||
16094 | void android_main(struct android_app *app) | ||||
16095 | { | ||||
16096 | app_dummy(); | ||||
16097 | |||||
16098 | const char* appTag = "VulkanLayerValidationTests"; | ||||
16099 | |||||
16100 | int vulkanSupport = InitVulkan(); | ||||
16101 | if (vulkanSupport == 0) { | ||||
16102 | __android_log_print(ANDROID_LOG_INFO, appTag, "==== FAILED ==== No Vulkan support found"); | ||||
16103 | return; | ||||
16104 | } | ||||
16105 | |||||
16106 | app->onAppCmd = processCommand; | ||||
16107 | app->onInputEvent = processInput; | ||||
16108 | |||||
16109 | while(1) { | ||||
16110 | int events; | ||||
16111 | struct android_poll_source* source; | ||||
16112 | while (ALooper_pollAll(active ? 0 : -1, NULL, &events, (void**)&source) >= 0) { | ||||
16113 | if (source) { | ||||
16114 | source->process(app, source); | ||||
16115 | } | ||||
16116 | |||||
16117 | if (app->destroyRequested != 0) { | ||||
16118 | VkTestFramework::Finish(); | ||||
16119 | return; | ||||
16120 | } | ||||
16121 | } | ||||
16122 | |||||
16123 | if (initialized && active) { | ||||
16124 | // Use the following key to send arguments to gtest, i.e. | ||||
16125 | // --es args "--gtest_filter=-VkLayerTest.foo" | ||||
16126 | const char key[] = "args"; | ||||
16127 | std::vector<std::string> args = get_args(*app, key); | ||||
16128 | |||||
16129 | std::string filter = ""; | ||||
16130 | if (args.size() > 0) { | ||||
16131 | __android_log_print(ANDROID_LOG_INFO, appTag, "Intent args = %s", args[0].c_str()); | ||||
16132 | filter += args[0]; | ||||
16133 | } else { | ||||
16134 | __android_log_print(ANDROID_LOG_INFO, appTag, "No Intent args detected"); | ||||
16135 | } | ||||
16136 | |||||
16137 | int argc = 2; | ||||
16138 | char *argv[] = { (char*)"foo", (char*)filter.c_str() }; | ||||
16139 | __android_log_print(ANDROID_LOG_DEBUG, appTag, "filter = %s", argv[1]); | ||||
16140 | |||||
16141 | // Route output to files until we can override the gtest output | ||||
16142 | freopen("/sdcard/Android/data/com.example.VulkanLayerValidationTests/files/out.txt", "w", stdout); | ||||
16143 | freopen("/sdcard/Android/data/com.example.VulkanLayerValidationTests/files/err.txt", "w", stderr); | ||||
16144 | |||||
16145 | ::testing::InitGoogleTest(&argc, argv); | ||||
16146 | VkTestFramework::InitArgs(&argc, argv); | ||||
16147 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); | ||||
16148 | |||||
16149 | int result = RUN_ALL_TESTS(); | ||||
16150 | |||||
16151 | if (result != 0) { | ||||
16152 | __android_log_print(ANDROID_LOG_INFO, appTag, "==== Tests FAILED ===="); | ||||
16153 | } else { | ||||
16154 | __android_log_print(ANDROID_LOG_INFO, appTag, "==== Tests PASSED ===="); | ||||
16155 | } | ||||
16156 | |||||
16157 | VkTestFramework::Finish(); | ||||
16158 | |||||
16159 | fclose(stdout); | ||||
16160 | fclose(stderr); | ||||
16161 | |||||
16162 | ANativeActivity_finish(app->activity); | ||||
16163 | |||||
16164 | return; | ||||
16165 | } | ||||
16166 | } | ||||
16167 | } | ||||
16168 | #endif | ||||
16169 | |||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 16170 | int main(int argc, char **argv) { |
16171 | int result; | ||||
16172 | |||||
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 16173 | #ifdef ANDROID |
16174 | int vulkanSupport = InitVulkan(); | ||||
16175 | if (vulkanSupport == 0) | ||||
16176 | return 1; | ||||
16177 | #endif | ||||
16178 | |||||
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 16179 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 16180 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 16181 | |
16182 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); | ||||
16183 | |||||
16184 | result = RUN_ALL_TESTS(); | ||||
16185 | |||||
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 16186 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 16187 | return result; |
16188 | } |