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 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | * of this software and/or associated documentation files (the "Materials"), to |
| 9 | * deal in the Materials without restriction, including without limitation the |
| 10 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 11 | * sell copies of the Materials, and to permit persons to whom the Materials are |
| 12 | * furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice(s) and this permission notice shall be included in |
| 15 | * all copies or substantial portions of the Materials. |
| 16 | * |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 17 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 | * |
| 21 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE |
| 24 | * USE OR OTHER DEALINGS IN THE MATERIALS. |
| 25 | * |
| 26 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 27 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 28 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 29 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 30 | * Author: Mike Stroyan <mike@LunarG.com> |
| 31 | * Author: Tobin Ehlis <tobine@google.com> |
| 32 | * Author: Tony Barbour <tony@LunarG.com> |
| 33 | */ |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 34 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 35 | #ifdef ANDROID |
| 36 | #include "vulkan_wrapper.h" |
| 37 | #else |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 38 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 39 | #endif |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 40 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 41 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 42 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 43 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | #define GLM_FORCE_RADIANS |
| 46 | #include "glm/glm.hpp" |
| 47 | #include <glm/gtc/matrix_transform.hpp> |
| 48 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 49 | #define MEM_TRACKER_TESTS 1 |
| 50 | #define OBJ_TRACKER_TESTS 1 |
| 51 | #define DRAW_STATE_TESTS 1 |
| 52 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 53 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 54 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 55 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 56 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 57 | //-------------------------------------------------------------------------------------- |
| 58 | // Mesh and VertexFormat Data |
| 59 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 60 | struct Vertex { |
| 61 | float posX, posY, posZ, posW; // Position data |
| 62 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 63 | }; |
| 64 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 65 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 66 | |
| 67 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 68 | BsoFailNone = 0x00000000, |
| 69 | BsoFailLineWidth = 0x00000001, |
| 70 | BsoFailDepthBias = 0x00000002, |
| 71 | BsoFailViewport = 0x00000004, |
| 72 | BsoFailScissor = 0x00000008, |
| 73 | BsoFailBlend = 0x00000010, |
| 74 | BsoFailDepthBounds = 0x00000020, |
| 75 | BsoFailStencilReadMask = 0x00000040, |
| 76 | BsoFailStencilWriteMask = 0x00000080, |
| 77 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 78 | } BsoFailSelect; |
| 79 | |
| 80 | struct vktriangle_vs_uniform { |
| 81 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 82 | float mvp[4][4]; |
| 83 | float position[3][4]; |
| 84 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 85 | }; |
| 86 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 87 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 88 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 89 | "vec2 vertices[3];\n" |
| 90 | "out gl_PerVertex {\n" |
| 91 | " vec4 gl_Position;\n" |
| 92 | "};\n" |
| 93 | "void main() {\n" |
| 94 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 95 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 96 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 97 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 98 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 99 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 100 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 101 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 102 | "\n" |
| 103 | "layout(location = 0) out vec4 uFragColor;\n" |
| 104 | "void main(){\n" |
| 105 | " uFragColor = vec4(0,1,0,1);\n" |
| 106 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 107 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 108 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 109 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 110 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 111 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 112 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 113 | // ******************************************************** |
| 114 | // ErrorMonitor Usage: |
| 115 | // |
| 116 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 117 | // encountered log messages. Passing NULL will match all log messages. |
| 118 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 119 | // |
| 120 | // Call DesiredMsgFound to determine if the desired failure message |
| 121 | // was encountered. |
| 122 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 123 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 124 | public: |
| 125 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 126 | test_platform_thread_create_mutex(&m_mutex); |
| 127 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 128 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 129 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 130 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 131 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 132 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 133 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 134 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 135 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 136 | m_failureMsg.clear(); |
| 137 | m_otherMsgs.clear(); |
| 138 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 139 | m_msgFound = VK_FALSE; |
| 140 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 141 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 142 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 143 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 144 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 145 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 146 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 147 | if (m_bailout != NULL) { |
| 148 | *m_bailout = true; |
| 149 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 150 | string errorString(msgString); |
| 151 | if (msgFlags & m_msgFlags) { |
| 152 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 153 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 154 | m_otherMsgs.push_back(m_failureMsg); |
| 155 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 156 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 157 | m_msgFound = VK_TRUE; |
| 158 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 159 | } else { |
| 160 | m_otherMsgs.push_back(errorString); |
| 161 | } |
| 162 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 163 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 164 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 165 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 166 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 167 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 168 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 169 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 170 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 171 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 172 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 173 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 174 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 175 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 176 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 177 | cout << "Other error messages logged for this test were:" << endl; |
| 178 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 179 | cout << " " << *iter << endl; |
| 180 | } |
| 181 | } |
| 182 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 183 | /* helpers */ |
| 184 | |
| 185 | void ExpectSuccess() { |
| 186 | // match anything |
| 187 | SetDesiredFailureMsg(~0u, ""); |
| 188 | } |
| 189 | |
| 190 | void VerifyFound() { |
| 191 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 192 | // any other messages. |
| 193 | if (!DesiredMsgFound()) { |
| 194 | DumpFailureMsgs(); |
| 195 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | void VerifyNotFound() { |
| 200 | // ExpectSuccess() configured us to match anything. Any error is a |
| 201 | // failure. |
| 202 | if (DesiredMsgFound()) { |
| 203 | DumpFailureMsgs(); |
| 204 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 205 | } |
| 206 | } |
| 207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 208 | private: |
| 209 | VkFlags m_msgFlags; |
| 210 | string m_desiredMsg; |
| 211 | string m_failureMsg; |
| 212 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 213 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 214 | bool *m_bailout; |
| 215 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 216 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 217 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 218 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 219 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 220 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 221 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 222 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 223 | (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 224 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 225 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 226 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 227 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 228 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 229 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 230 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 231 | class VkLayerTest : public VkRenderFramework { |
| 232 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 233 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 234 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 235 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 236 | BsoFailSelect failMask); |
| 237 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 238 | VkPipelineObj &pipelineobj, |
| 239 | VkDescriptorSetObj &descriptorSet, |
| 240 | BsoFailSelect failMask); |
| 241 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 242 | VkDescriptorSetObj &descriptorSet, |
| 243 | BsoFailSelect failMask) { |
| 244 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 245 | failMask); |
| 246 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 247 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 248 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 249 | VkResult BeginCommandBuffer() { |
| 250 | return BeginCommandBuffer(*m_commandBuffer); |
| 251 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 252 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 253 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 254 | uint32_t firstVertex, uint32_t firstInstance) { |
| 255 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 256 | firstInstance); |
| 257 | } |
| 258 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 259 | uint32_t firstIndex, int32_t vertexOffset, |
| 260 | uint32_t firstInstance) { |
| 261 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 262 | vertexOffset, firstInstance); |
| 263 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 264 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
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; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 278 | |
| 279 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 280 | std::vector<const char *> instance_layer_names; |
| 281 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 282 | std::vector<const char *> instance_extension_names; |
| 283 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 284 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 285 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 286 | /* |
| 287 | * Since CreateDbgMsgCallback is an instance level extension call |
| 288 | * any extension / layer that utilizes that feature also needs |
| 289 | * to be enabled at create instance time. |
| 290 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 291 | // Use Threading layer first to protect others from |
| 292 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 293 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 294 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 295 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 296 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 297 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 298 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 299 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 300 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 301 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 302 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 303 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 304 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 305 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 306 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 307 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 308 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 309 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 310 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 311 | this->app_info.pApplicationName = "layer_tests"; |
| 312 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 313 | this->app_info.pEngineName = "unittest"; |
| 314 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 315 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 316 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 317 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 318 | InitFramework(instance_layer_names, device_layer_names, |
| 319 | instance_extension_names, device_extension_names, |
| 320 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | virtual void TearDown() { |
| 324 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 325 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 326 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 327 | } |
| 328 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 329 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 330 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 331 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 332 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 333 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 334 | |
| 335 | /* |
| 336 | * For render test all drawing happens in a single render pass |
| 337 | * on a single command buffer. |
| 338 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 339 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 340 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | return result; |
| 344 | } |
| 345 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 346 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 347 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 348 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 349 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 350 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 351 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 352 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 353 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 354 | |
| 355 | return result; |
| 356 | } |
| 357 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 358 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 359 | const char *fragShaderText, |
| 360 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 361 | // Create identity matrix |
| 362 | int i; |
| 363 | struct vktriangle_vs_uniform data; |
| 364 | |
| 365 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 366 | glm::mat4 View = glm::mat4(1.0f); |
| 367 | glm::mat4 Model = glm::mat4(1.0f); |
| 368 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 369 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 370 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 371 | |
| 372 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 373 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 374 | static const Vertex tri_data[] = { |
| 375 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 376 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 377 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 378 | }; |
| 379 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 380 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 381 | data.position[i][0] = tri_data[i].posX; |
| 382 | data.position[i][1] = tri_data[i].posY; |
| 383 | data.position[i][2] = tri_data[i].posZ; |
| 384 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 385 | data.color[i][0] = tri_data[i].r; |
| 386 | data.color[i][1] = tri_data[i].g; |
| 387 | data.color[i][2] = tri_data[i].b; |
| 388 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 392 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 393 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 394 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 395 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 396 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 397 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 398 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 399 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 400 | |
| 401 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 402 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 403 | pipelineobj.AddShader(&vs); |
| 404 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 405 | if (failMask & BsoFailLineWidth) { |
| 406 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 407 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 408 | ia_state.sType = |
| 409 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 410 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 411 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 412 | } |
| 413 | if (failMask & BsoFailDepthBias) { |
| 414 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 415 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 416 | rs_state.sType = |
| 417 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 418 | rs_state.depthBiasEnable = VK_TRUE; |
| 419 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 420 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 421 | // Viewport and scissors must stay in synch or other errors will occur than |
| 422 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 423 | if (failMask & BsoFailViewport) { |
| 424 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 425 | m_viewports.clear(); |
| 426 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 427 | } |
| 428 | if (failMask & BsoFailScissor) { |
| 429 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 430 | m_scissors.clear(); |
| 431 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 432 | } |
| 433 | if (failMask & BsoFailBlend) { |
| 434 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 435 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 436 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 437 | att_state.blendEnable = VK_TRUE; |
| 438 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 439 | } |
| 440 | if (failMask & BsoFailDepthBounds) { |
| 441 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 442 | } |
| 443 | if (failMask & BsoFailStencilReadMask) { |
| 444 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 445 | } |
| 446 | if (failMask & BsoFailStencilWriteMask) { |
| 447 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 448 | } |
| 449 | if (failMask & BsoFailStencilReference) { |
| 450 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 451 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 452 | |
| 453 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 454 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 455 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 456 | |
| 457 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 458 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 459 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 460 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 461 | |
| 462 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 463 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 464 | |
| 465 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 466 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 467 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 468 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 469 | } |
| 470 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 471 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 472 | VkPipelineObj &pipelineobj, |
| 473 | VkDescriptorSetObj &descriptorSet, |
| 474 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 475 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 476 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 477 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 478 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 479 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 480 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 481 | } |
| 482 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 483 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 484 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 485 | // correctly |
| 486 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 487 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 488 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 489 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 490 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 491 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 492 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 493 | |
| 494 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 495 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 496 | ds_ci.pNext = NULL; |
| 497 | ds_ci.depthTestEnable = VK_FALSE; |
| 498 | ds_ci.depthWriteEnable = VK_TRUE; |
| 499 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 500 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 501 | if (failMask & BsoFailDepthBounds) { |
| 502 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
| 503 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 504 | ds_ci.stencilTestEnable = VK_TRUE; |
| 505 | ds_ci.front = stencil; |
| 506 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 507 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 508 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 509 | pipelineobj.SetViewport(m_viewports); |
| 510 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 511 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 512 | VkResult err = pipelineobj.CreateVKPipeline( |
| 513 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 514 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 515 | commandBuffer->BindPipeline(pipelineobj); |
| 516 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | // ******************************************************************************************************************** |
| 520 | // ******************************************************************************************************************** |
| 521 | // ******************************************************************************************************************** |
| 522 | // ******************************************************************************************************************** |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 523 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 524 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 525 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 526 | { |
| 527 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 528 | VkFenceCreateInfo fenceInfo = {}; |
| 529 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 530 | fenceInfo.pNext = NULL; |
| 531 | fenceInfo.flags = 0; |
| 532 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 533 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 534 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 535 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 536 | |
| 537 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 538 | vk_testing::Buffer buffer; |
| 539 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 540 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 541 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 542 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 543 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 544 | |
| 545 | testFence.init(*m_device, fenceInfo); |
| 546 | |
| 547 | // Bypass framework since it does the waits automatically |
| 548 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 549 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 550 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 551 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 552 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 553 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 554 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 555 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 556 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 557 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 558 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 559 | |
| 560 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 561 | ASSERT_VK_SUCCESS( err ); |
| 562 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 563 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 564 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 565 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 566 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 567 | } |
| 568 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 569 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 570 | { |
| 571 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 572 | VkFenceCreateInfo fenceInfo = {}; |
| 573 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 574 | fenceInfo.pNext = NULL; |
| 575 | fenceInfo.flags = 0; |
| 576 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 577 | 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] | 578 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 579 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 580 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 581 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 582 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 583 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 584 | 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] | 585 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 586 | |
| 587 | testFence.init(*m_device, fenceInfo); |
| 588 | |
| 589 | // Bypass framework since it does the waits automatically |
| 590 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 591 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 592 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 593 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 594 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 595 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 596 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 597 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 598 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 599 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 600 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 601 | |
| 602 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 603 | ASSERT_VK_SUCCESS( err ); |
| 604 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 605 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 606 | VkCommandBufferBeginInfo info = {}; |
| 607 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 608 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 609 | info.renderPass = VK_NULL_HANDLE; |
| 610 | info.subpass = 0; |
| 611 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 612 | info.occlusionQueryEnable = VK_FALSE; |
| 613 | info.queryFlags = 0; |
| 614 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 615 | |
| 616 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 617 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 618 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 619 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 620 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 621 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 622 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 623 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 624 | VkResult err; |
| 625 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 626 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 627 | m_errorMonitor->SetDesiredFailureMsg( |
| 628 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 629 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 630 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 631 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 632 | |
| 633 | // 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] | 634 | VkImage image; |
| 635 | VkDeviceMemory mem; |
| 636 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 637 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 638 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 639 | const int32_t tex_width = 32; |
| 640 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 641 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 642 | VkImageCreateInfo image_create_info = {}; |
| 643 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 644 | image_create_info.pNext = NULL; |
| 645 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 646 | image_create_info.format = tex_format; |
| 647 | image_create_info.extent.width = tex_width; |
| 648 | image_create_info.extent.height = tex_height; |
| 649 | image_create_info.extent.depth = 1; |
| 650 | image_create_info.mipLevels = 1; |
| 651 | image_create_info.arrayLayers = 1; |
| 652 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 653 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 654 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 655 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 656 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 657 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 658 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 659 | mem_alloc.pNext = NULL; |
| 660 | mem_alloc.allocationSize = 0; |
| 661 | // Introduce failure, do NOT set memProps to |
| 662 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 663 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 664 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 665 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 666 | ASSERT_VK_SUCCESS(err); |
| 667 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 668 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 669 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 670 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 671 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 672 | pass = |
| 673 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 674 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 675 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 676 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 677 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 678 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 679 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 680 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 681 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 682 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 683 | ASSERT_VK_SUCCESS(err); |
| 684 | |
| 685 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 686 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 687 | ASSERT_VK_SUCCESS(err); |
| 688 | |
| 689 | // Map memory as if to initialize the image |
| 690 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 691 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 692 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 693 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 694 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 695 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 696 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 697 | } |
| 698 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 699 | TEST_F(VkLayerTest, RebindMemory) { |
| 700 | VkResult err; |
| 701 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 702 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 703 | m_errorMonitor->SetDesiredFailureMsg( |
| 704 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 705 | "which has already been bound to mem object"); |
| 706 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 707 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 708 | |
| 709 | // 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] | 710 | VkImage image; |
| 711 | VkDeviceMemory mem1; |
| 712 | VkDeviceMemory mem2; |
| 713 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 714 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 715 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 716 | const int32_t tex_width = 32; |
| 717 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 718 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 719 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 720 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 721 | image_create_info.pNext = NULL; |
| 722 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 723 | image_create_info.format = tex_format; |
| 724 | image_create_info.extent.width = tex_width; |
| 725 | image_create_info.extent.height = tex_height; |
| 726 | image_create_info.extent.depth = 1; |
| 727 | image_create_info.mipLevels = 1; |
| 728 | image_create_info.arrayLayers = 1; |
| 729 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 730 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 731 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 732 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 733 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 734 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 735 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 736 | mem_alloc.pNext = NULL; |
| 737 | mem_alloc.allocationSize = 0; |
| 738 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 739 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 740 | // Introduce failure, do NOT set memProps to |
| 741 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 742 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 743 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 744 | ASSERT_VK_SUCCESS(err); |
| 745 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 746 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 747 | |
| 748 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 749 | pass = |
| 750 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 751 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 752 | |
| 753 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 754 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 755 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 756 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 757 | ASSERT_VK_SUCCESS(err); |
| 758 | |
| 759 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 760 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 761 | ASSERT_VK_SUCCESS(err); |
| 762 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 763 | // Introduce validation failure, try to bind a different memory object to |
| 764 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 765 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 766 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 767 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 768 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 769 | vkDestroyImage(m_device->device(), image, NULL); |
| 770 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 771 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 772 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 773 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 774 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 775 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 776 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 777 | m_errorMonitor->SetDesiredFailureMsg( |
| 778 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 779 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 780 | |
| 781 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 782 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 783 | fenceInfo.pNext = NULL; |
| 784 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 785 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 786 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 787 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 788 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 789 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 790 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 791 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 792 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 793 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 794 | |
| 795 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 796 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 797 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 798 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 799 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 800 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 801 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 802 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 803 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 804 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 805 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 806 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 807 | |
| 808 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 809 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 810 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 811 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 812 | } |
| 813 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 814 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 815 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 816 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 817 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 818 | fenceInfo.pNext = NULL; |
| 819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 820 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 821 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 822 | "submitted to VkResetFences in UNSIGNALED STATE"); |
| 823 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 824 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 825 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 826 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 827 | vkResetFences(m_device->device(), 1, fences); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 828 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 829 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 830 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 831 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 832 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 833 | #if 0 |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 834 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 835 | { |
| 836 | // Initiate Draw w/o a PSO bound |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 837 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 838 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 839 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 840 | |
| 841 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 842 | VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 843 | BeginCommandBuffer(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 844 | |
| 845 | const VkExtent3D e3d = { |
| 846 | .width = 128, |
| 847 | .height = 128, |
| 848 | .depth = 1, |
| 849 | }; |
| 850 | const VkImageCreateInfo ici = { |
| 851 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 852 | .pNext = NULL, |
| 853 | .imageType = VK_IMAGE_TYPE_2D, |
| 854 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 855 | .extent = e3d, |
| 856 | .mipLevels = 1, |
| 857 | .arraySize = 1, |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 858 | .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 859 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | 660f0ca | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 860 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 861 | .flags = 0, |
| 862 | }; |
| 863 | |
| 864 | VkImage dsi; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 865 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 866 | VkDepthStencilView dsv; |
| 867 | const VkDepthStencilViewCreateInfo dsvci = { |
| 868 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 869 | .pNext = NULL, |
| 870 | .image = dsi, |
| 871 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 4a26189 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 872 | .baseArrayLayer = 0, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 873 | .arraySize = 1, |
| 874 | .flags = 0, |
| 875 | }; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 876 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 877 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 878 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 879 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 880 | #endif // 0 |
| 881 | #endif // MEM_TRACKER_TESTS |
| 882 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 883 | #if OBJ_TRACKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 884 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 885 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 886 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 887 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 888 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 889 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 890 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 891 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 892 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 893 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 894 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 895 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 896 | |
| 897 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 898 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 899 | ds_pool_ci.pNext = NULL; |
| 900 | ds_pool_ci.maxSets = 1; |
| 901 | ds_pool_ci.poolSizeCount = 1; |
| 902 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 903 | |
| 904 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 905 | err = |
| 906 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 907 | ASSERT_VK_SUCCESS(err); |
| 908 | |
| 909 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 910 | dsl_binding.binding = 0; |
| 911 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 912 | dsl_binding.descriptorCount = 1; |
| 913 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 914 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 915 | |
| 916 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 917 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 918 | ds_layout_ci.pNext = NULL; |
| 919 | ds_layout_ci.bindingCount = 1; |
| 920 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 921 | |
| 922 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 923 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 924 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 925 | ASSERT_VK_SUCCESS(err); |
| 926 | |
| 927 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 928 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 929 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 930 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 931 | alloc_info.descriptorPool = ds_pool; |
| 932 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 933 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 934 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 935 | ASSERT_VK_SUCCESS(err); |
| 936 | |
| 937 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 938 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 939 | pipeline_layout_ci.pNext = NULL; |
| 940 | pipeline_layout_ci.setLayoutCount = 1; |
| 941 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 942 | |
| 943 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 944 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 945 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 946 | ASSERT_VK_SUCCESS(err); |
| 947 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 948 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 949 | |
| 950 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 951 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 952 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 953 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 954 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 955 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 956 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 957 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 958 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 959 | } |
| 960 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 961 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 962 | VkResult err; |
| 963 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 964 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 965 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 966 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 967 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 968 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 969 | |
| 970 | // 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] | 971 | VkImage image; |
| 972 | VkDeviceMemory mem; |
| 973 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 974 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 975 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 976 | const int32_t tex_width = 32; |
| 977 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 978 | |
| 979 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 980 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 981 | image_create_info.pNext = NULL; |
| 982 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 983 | image_create_info.format = tex_format; |
| 984 | image_create_info.extent.width = tex_width; |
| 985 | image_create_info.extent.height = tex_height; |
| 986 | image_create_info.extent.depth = 1; |
| 987 | image_create_info.mipLevels = 1; |
| 988 | image_create_info.arrayLayers = 1; |
| 989 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 990 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 991 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 992 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 993 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 994 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 995 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 996 | mem_alloc.pNext = NULL; |
| 997 | mem_alloc.allocationSize = 0; |
| 998 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 999 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1000 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1001 | ASSERT_VK_SUCCESS(err); |
| 1002 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1003 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1004 | |
| 1005 | mem_alloc.allocationSize = mem_reqs.size; |
| 1006 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1007 | pass = |
| 1008 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1009 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1010 | |
| 1011 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1012 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1013 | ASSERT_VK_SUCCESS(err); |
| 1014 | |
| 1015 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1016 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1017 | |
| 1018 | // Try to bind free memory that has been freed |
| 1019 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1020 | // This may very well return an error. |
| 1021 | (void)err; |
| 1022 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1023 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1024 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1025 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1026 | } |
| 1027 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1028 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1029 | VkResult err; |
| 1030 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1031 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1032 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1033 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1034 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1035 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1036 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1037 | // Create an image object, allocate memory, destroy the object and then try |
| 1038 | // to bind it |
| 1039 | VkImage image; |
| 1040 | VkDeviceMemory mem; |
| 1041 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1042 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1043 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1044 | const int32_t tex_width = 32; |
| 1045 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1046 | |
| 1047 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1048 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1049 | image_create_info.pNext = NULL; |
| 1050 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1051 | image_create_info.format = tex_format; |
| 1052 | image_create_info.extent.width = tex_width; |
| 1053 | image_create_info.extent.height = tex_height; |
| 1054 | image_create_info.extent.depth = 1; |
| 1055 | image_create_info.mipLevels = 1; |
| 1056 | image_create_info.arrayLayers = 1; |
| 1057 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1058 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1059 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1060 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1061 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1062 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1063 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1064 | mem_alloc.pNext = NULL; |
| 1065 | mem_alloc.allocationSize = 0; |
| 1066 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1067 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1068 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1069 | ASSERT_VK_SUCCESS(err); |
| 1070 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1071 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1072 | |
| 1073 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1074 | pass = |
| 1075 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1076 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1077 | |
| 1078 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1079 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1080 | ASSERT_VK_SUCCESS(err); |
| 1081 | |
| 1082 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1083 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1084 | ASSERT_VK_SUCCESS(err); |
| 1085 | |
| 1086 | // Now Try to bind memory to this destroyed object |
| 1087 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1088 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1089 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1090 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1091 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1092 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1093 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1094 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1095 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1096 | #endif // OBJ_TRACKER_TESTS |
| 1097 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1098 | #if DRAW_STATE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1099 | TEST_F(VkLayerTest, LineWidthStateNotBound) { |
| 1100 | m_errorMonitor->SetDesiredFailureMsg( |
| 1101 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1102 | "Dynamic line width state not set for this command buffer"); |
| 1103 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1104 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line " |
| 1105 | "width state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1106 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1107 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1108 | BsoFailLineWidth); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1109 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1110 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1111 | } |
| 1112 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1113 | TEST_F(VkLayerTest, DepthBiasStateNotBound) { |
| 1114 | m_errorMonitor->SetDesiredFailureMsg( |
| 1115 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1116 | "Dynamic depth bias state not set for this command buffer"); |
| 1117 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1118 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth " |
| 1119 | "bias state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1120 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1121 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1122 | BsoFailDepthBias); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1123 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1124 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1125 | } |
| 1126 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1127 | // Disable these two tests until we can sort out how to track multiple layer |
| 1128 | // errors |
| 1129 | TEST_F(VkLayerTest, ViewportStateNotBound) { |
| 1130 | m_errorMonitor->SetDesiredFailureMsg( |
| 1131 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1132 | "Dynamic viewport state not set for this command buffer"); |
| 1133 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1134 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport " |
| 1135 | "state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1136 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1137 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1138 | BsoFailViewport); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1139 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1140 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1141 | } |
| 1142 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1143 | TEST_F(VkLayerTest, ScissorStateNotBound) { |
| 1144 | m_errorMonitor->SetDesiredFailureMsg( |
| 1145 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1146 | "Dynamic scissor state not set for this command buffer"); |
| 1147 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1148 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport " |
| 1149 | "state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1150 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1151 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1152 | BsoFailScissor); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1153 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1154 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1155 | } |
| 1156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1157 | TEST_F(VkLayerTest, BlendStateNotBound) { |
| 1158 | m_errorMonitor->SetDesiredFailureMsg( |
| 1159 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 1160 | "Dynamic blend constants state not set for this command buffer"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1161 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1162 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend " |
| 1163 | "state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1165 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1166 | BsoFailBlend); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1167 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1168 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1169 | } |
| 1170 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1171 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) { |
| 1172 | m_errorMonitor->SetDesiredFailureMsg( |
| 1173 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1174 | "Dynamic depth bounds state not set for this command buffer"); |
| 1175 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1176 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth " |
| 1177 | "bounds state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1178 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1179 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1180 | BsoFailDepthBounds); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1181 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1182 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1183 | } |
| 1184 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1185 | TEST_F(VkLayerTest, StencilReadMaskNotSet) { |
| 1186 | m_errorMonitor->SetDesiredFailureMsg( |
| 1187 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1188 | "Dynamic stencil read mask state not set for this command buffer"); |
| 1189 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1190 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1191 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1192 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1193 | "read mask is not set beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1194 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1195 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1196 | BsoFailStencilReadMask); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1197 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1198 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1199 | } |
| 1200 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1201 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) { |
| 1202 | m_errorMonitor->SetDesiredFailureMsg( |
| 1203 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1204 | "Dynamic stencil write mask state not set for this command buffer"); |
| 1205 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1206 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1208 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1209 | "write mask is not set beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1210 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1211 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1212 | BsoFailStencilWriteMask); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1213 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1214 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1215 | } |
| 1216 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1217 | TEST_F(VkLayerTest, StencilReferenceNotSet) { |
| 1218 | m_errorMonitor->SetDesiredFailureMsg( |
| 1219 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1220 | "Dynamic stencil reference state not set for this command buffer"); |
| 1221 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1222 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1223 | "reference is not set beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1224 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1225 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1226 | BsoFailStencilReference); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1227 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1228 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1229 | } |
| 1230 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1231 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1232 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1233 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1234 | m_errorMonitor->SetDesiredFailureMsg( |
| 1235 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1236 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 1237 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1238 | |
| 1239 | VkFenceCreateInfo fenceInfo = {}; |
| 1240 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1241 | fenceInfo.pNext = NULL; |
| 1242 | fenceInfo.flags = 0; |
| 1243 | |
| 1244 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1245 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1246 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1247 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1248 | // We luck out b/c by default the framework creates CB w/ the |
| 1249 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1250 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1251 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 1252 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1253 | EndCommandBuffer(); |
| 1254 | |
| 1255 | testFence.init(*m_device, fenceInfo); |
| 1256 | |
| 1257 | // Bypass framework since it does the waits automatically |
| 1258 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1259 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1260 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1261 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1262 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1263 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1264 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1265 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1266 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1267 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1268 | submit_info.pSignalSemaphores = NULL; |
| 1269 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1270 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 1271 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1272 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1273 | // Cause validation error by re-submitting cmd buffer that should only be |
| 1274 | // submitted once |
| 1275 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1276 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1277 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1278 | } |
| 1279 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1280 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1281 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1282 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1283 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1284 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1285 | "Unable to allocate 1 descriptors of " |
| 1286 | "type " |
| 1287 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1288 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1289 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1290 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1291 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1292 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 1293 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1294 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1295 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1296 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1297 | |
| 1298 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1299 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1300 | ds_pool_ci.pNext = NULL; |
| 1301 | ds_pool_ci.flags = 0; |
| 1302 | ds_pool_ci.maxSets = 1; |
| 1303 | ds_pool_ci.poolSizeCount = 1; |
| 1304 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1305 | |
| 1306 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1307 | err = |
| 1308 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1309 | ASSERT_VK_SUCCESS(err); |
| 1310 | |
| 1311 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1312 | dsl_binding.binding = 0; |
| 1313 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1314 | dsl_binding.descriptorCount = 1; |
| 1315 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1316 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1317 | |
| 1318 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1319 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1320 | ds_layout_ci.pNext = NULL; |
| 1321 | ds_layout_ci.bindingCount = 1; |
| 1322 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1323 | |
| 1324 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1325 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1326 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1327 | ASSERT_VK_SUCCESS(err); |
| 1328 | |
| 1329 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1330 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1331 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1332 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1333 | alloc_info.descriptorPool = ds_pool; |
| 1334 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1335 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1336 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1337 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1338 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1339 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1340 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1341 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1342 | } |
| 1343 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1344 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 1345 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1346 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1347 | m_errorMonitor->SetDesiredFailureMsg( |
| 1348 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1349 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 1350 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1351 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1352 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1353 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1354 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1355 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1356 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1357 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1358 | |
| 1359 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1360 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1361 | ds_pool_ci.pNext = NULL; |
| 1362 | ds_pool_ci.maxSets = 1; |
| 1363 | ds_pool_ci.poolSizeCount = 1; |
| 1364 | ds_pool_ci.flags = 0; |
| 1365 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1366 | // app can only call vkResetDescriptorPool on this pool.; |
| 1367 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1368 | |
| 1369 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1370 | err = |
| 1371 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1372 | ASSERT_VK_SUCCESS(err); |
| 1373 | |
| 1374 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1375 | dsl_binding.binding = 0; |
| 1376 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1377 | dsl_binding.descriptorCount = 1; |
| 1378 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1379 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1380 | |
| 1381 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1382 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1383 | ds_layout_ci.pNext = NULL; |
| 1384 | ds_layout_ci.bindingCount = 1; |
| 1385 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1386 | |
| 1387 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1388 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1389 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1390 | ASSERT_VK_SUCCESS(err); |
| 1391 | |
| 1392 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1393 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1394 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1395 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1396 | alloc_info.descriptorPool = ds_pool; |
| 1397 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1398 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1399 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1400 | ASSERT_VK_SUCCESS(err); |
| 1401 | |
| 1402 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1403 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1404 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1405 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1406 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1407 | } |
| 1408 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1409 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 1410 | // Attempt to clear Descriptor Pool with bad object. |
| 1411 | // ObjectTracker should catch this. |
| 1412 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1413 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
| 1414 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1415 | vkResetDescriptorPool(device(), badPool, 0); |
| 1416 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1417 | } |
| 1418 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1419 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 1420 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 1421 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1422 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 1423 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
| 1424 | VkDescriptorSet badSet = (VkDescriptorSet)0xbaad6001; |
| 1425 | VkResult err; |
| 1426 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1427 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 1428 | |
| 1429 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1430 | |
| 1431 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 1432 | layout_bindings[0].binding = 0; |
| 1433 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1434 | layout_bindings[0].descriptorCount = 1; |
| 1435 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 1436 | layout_bindings[0].pImmutableSamplers = NULL; |
| 1437 | |
| 1438 | VkDescriptorSetLayout descriptor_set_layout; |
| 1439 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 1440 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1441 | dslci.pNext = NULL; |
| 1442 | dslci.bindingCount = 1; |
| 1443 | dslci.pBindings = layout_bindings; |
| 1444 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
| 1445 | assert(!err); |
| 1446 | |
| 1447 | VkPipelineLayout pipeline_layout; |
| 1448 | VkPipelineLayoutCreateInfo plci = {}; |
| 1449 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1450 | plci.pNext = NULL; |
| 1451 | plci.setLayoutCount = 1; |
| 1452 | plci.pSetLayouts = &descriptor_set_layout; |
| 1453 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 1454 | assert(!err); |
| 1455 | |
| 1456 | BeginCommandBuffer(); |
| 1457 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 1458 | pipeline_layout, 0, 1, &badSet, 0, NULL); |
| 1459 | m_errorMonitor->VerifyFound(); |
| 1460 | EndCommandBuffer(); |
| 1461 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 1462 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1463 | } |
| 1464 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1465 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 1466 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 1467 | // ObjectTracker should catch this. |
| 1468 | VkDescriptorSetLayout bad_layout = (VkDescriptorSetLayout)0xbaad6001; |
| 1469 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1470 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 1471 | |
| 1472 | VkPipelineLayout pipeline_layout; |
| 1473 | VkPipelineLayoutCreateInfo plci = {}; |
| 1474 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1475 | plci.pNext = NULL; |
| 1476 | plci.setLayoutCount = 1; |
| 1477 | plci.pSetLayouts = &bad_layout; |
| 1478 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 1479 | |
| 1480 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1481 | } |
| 1482 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1483 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 1484 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 1485 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1486 | // Create a valid cmd buffer |
| 1487 | // call vkCmdBindPipeline w/ false Pipeline |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 1488 | VkPipeline bad_pipeline = (VkPipeline)0xbaad6001; |
| 1489 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1490 | "Invalid VkPipeline Object 0xbaad6001"); |
| 1491 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1492 | BeginCommandBuffer(); |
| 1493 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1494 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 1495 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1496 | } |
| 1497 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1498 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 1499 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 1500 | // CommandBuffer |
| 1501 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1502 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 1503 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1504 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1505 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1506 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1507 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1508 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1509 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1510 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1511 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1512 | |
| 1513 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1514 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1515 | ds_pool_ci.pNext = NULL; |
| 1516 | ds_pool_ci.maxSets = 1; |
| 1517 | ds_pool_ci.poolSizeCount = 1; |
| 1518 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1519 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1520 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1521 | err = |
| 1522 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1523 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1524 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1525 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1526 | dsl_binding.binding = 0; |
| 1527 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1528 | dsl_binding.descriptorCount = 1; |
| 1529 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1530 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1531 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1532 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1533 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1534 | ds_layout_ci.pNext = NULL; |
| 1535 | ds_layout_ci.bindingCount = 1; |
| 1536 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1537 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1538 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1539 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1540 | ASSERT_VK_SUCCESS(err); |
| 1541 | |
| 1542 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1543 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1544 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1545 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1546 | alloc_info.descriptorPool = ds_pool; |
| 1547 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1548 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1549 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1550 | ASSERT_VK_SUCCESS(err); |
| 1551 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1552 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1553 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1554 | pipeline_layout_ci.pNext = NULL; |
| 1555 | pipeline_layout_ci.setLayoutCount = 1; |
| 1556 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1557 | |
| 1558 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1559 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1560 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1561 | ASSERT_VK_SUCCESS(err); |
| 1562 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1563 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 1564 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 1565 | // 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] | 1566 | // on more devices |
| 1567 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 1568 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1569 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1570 | VkPipelineObj pipe(m_device); |
| 1571 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1572 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 1573 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1574 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1575 | |
| 1576 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1577 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1578 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1579 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1580 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1581 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1582 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1583 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1584 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1585 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1586 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1587 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1588 | } |
| 1589 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1590 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1591 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1592 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1593 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1594 | m_errorMonitor->SetDesiredFailureMsg( |
| 1595 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1596 | "Attempt to update descriptor with invalid bufferView "); |
| 1597 | |
| 1598 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1599 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1600 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1601 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1602 | |
| 1603 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1604 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1605 | ds_pool_ci.pNext = NULL; |
| 1606 | ds_pool_ci.maxSets = 1; |
| 1607 | ds_pool_ci.poolSizeCount = 1; |
| 1608 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1609 | |
| 1610 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1611 | err = |
| 1612 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1613 | ASSERT_VK_SUCCESS(err); |
| 1614 | |
| 1615 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1616 | dsl_binding.binding = 0; |
| 1617 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1618 | dsl_binding.descriptorCount = 1; |
| 1619 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1620 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1621 | |
| 1622 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1623 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1624 | ds_layout_ci.pNext = NULL; |
| 1625 | ds_layout_ci.bindingCount = 1; |
| 1626 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1627 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1628 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1629 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1630 | ASSERT_VK_SUCCESS(err); |
| 1631 | |
| 1632 | VkDescriptorSet descriptorSet; |
| 1633 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1634 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1635 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1636 | alloc_info.descriptorPool = ds_pool; |
| 1637 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1638 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1639 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1640 | ASSERT_VK_SUCCESS(err); |
| 1641 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1642 | VkBufferView view = |
| 1643 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1644 | VkWriteDescriptorSet descriptor_write; |
| 1645 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1646 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1647 | descriptor_write.dstSet = descriptorSet; |
| 1648 | descriptor_write.dstBinding = 0; |
| 1649 | descriptor_write.descriptorCount = 1; |
| 1650 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1651 | descriptor_write.pTexelBufferView = &view; |
| 1652 | |
| 1653 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1654 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1655 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1656 | |
| 1657 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1658 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1659 | } |
| 1660 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1661 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 1662 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 1663 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1664 | // 1. No dynamicOffset supplied |
| 1665 | // 2. Too many dynamicOffsets supplied |
| 1666 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1667 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1668 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1669 | " requires 1 dynamicOffsets, but only " |
| 1670 | "0 dynamicOffsets are left in " |
| 1671 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1672 | |
| 1673 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1674 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1675 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1676 | |
| 1677 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1678 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1679 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1680 | |
| 1681 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1682 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1683 | ds_pool_ci.pNext = NULL; |
| 1684 | ds_pool_ci.maxSets = 1; |
| 1685 | ds_pool_ci.poolSizeCount = 1; |
| 1686 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1687 | |
| 1688 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1689 | err = |
| 1690 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1691 | ASSERT_VK_SUCCESS(err); |
| 1692 | |
| 1693 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1694 | dsl_binding.binding = 0; |
| 1695 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1696 | dsl_binding.descriptorCount = 1; |
| 1697 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1698 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1699 | |
| 1700 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1701 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1702 | ds_layout_ci.pNext = NULL; |
| 1703 | ds_layout_ci.bindingCount = 1; |
| 1704 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1705 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1706 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1707 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1708 | ASSERT_VK_SUCCESS(err); |
| 1709 | |
| 1710 | VkDescriptorSet descriptorSet; |
| 1711 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1712 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1713 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1714 | alloc_info.descriptorPool = ds_pool; |
| 1715 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1716 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1717 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1718 | ASSERT_VK_SUCCESS(err); |
| 1719 | |
| 1720 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1721 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1722 | pipeline_layout_ci.pNext = NULL; |
| 1723 | pipeline_layout_ci.setLayoutCount = 1; |
| 1724 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1725 | |
| 1726 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1727 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1728 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1729 | ASSERT_VK_SUCCESS(err); |
| 1730 | |
| 1731 | // Create a buffer to update the descriptor with |
| 1732 | uint32_t qfi = 0; |
| 1733 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1734 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1735 | buffCI.size = 1024; |
| 1736 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1737 | buffCI.queueFamilyIndexCount = 1; |
| 1738 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1739 | |
| 1740 | VkBuffer dyub; |
| 1741 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 1742 | ASSERT_VK_SUCCESS(err); |
| 1743 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 1744 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1745 | buffInfo.buffer = dyub; |
| 1746 | buffInfo.offset = 0; |
| 1747 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1748 | |
| 1749 | VkWriteDescriptorSet descriptor_write; |
| 1750 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1751 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1752 | descriptor_write.dstSet = descriptorSet; |
| 1753 | descriptor_write.dstBinding = 0; |
| 1754 | descriptor_write.descriptorCount = 1; |
| 1755 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1756 | descriptor_write.pBufferInfo = &buffInfo; |
| 1757 | |
| 1758 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1759 | |
| 1760 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1761 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1762 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1763 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1764 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1765 | uint32_t pDynOff[2] = {512, 756}; |
| 1766 | // 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] | 1767 | m_errorMonitor->SetDesiredFailureMsg( |
| 1768 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1769 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1770 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1771 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1772 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 1773 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1774 | // Finally cause error due to dynamicOffset being too big |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1775 | m_errorMonitor->SetDesiredFailureMsg( |
| 1776 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1777 | " from its update, this oversteps its buffer ("); |
| 1778 | // Create PSO to be used for draw-time errors below |
| 1779 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 1780 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1781 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1782 | "out gl_PerVertex { \n" |
| 1783 | " vec4 gl_Position;\n" |
| 1784 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1785 | "void main(){\n" |
| 1786 | " gl_Position = vec4(1);\n" |
| 1787 | "}\n"; |
| 1788 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 1789 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1790 | "\n" |
| 1791 | "layout(location=0) out vec4 x;\n" |
| 1792 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 1793 | "void main(){\n" |
| 1794 | " x = vec4(bar.y);\n" |
| 1795 | "}\n"; |
| 1796 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1797 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 1798 | VkPipelineObj pipe(m_device); |
| 1799 | pipe.AddShader(&vs); |
| 1800 | pipe.AddShader(&fs); |
| 1801 | pipe.AddColorAttachment(); |
| 1802 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 1803 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1804 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1805 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1806 | // This update should succeed, but offset size of 512 will overstep buffer |
| 1807 | // /w range 1024 & size 1024 |
| 1808 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1809 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1810 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1811 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1812 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1813 | |
| 1814 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1815 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1816 | } |
| 1817 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 1818 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 1819 | // Hit push constant error cases: |
| 1820 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 1821 | // 2. Incorrectly set push constant size to 0 |
| 1822 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 1823 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 1824 | VkResult err; |
| 1825 | m_errorMonitor->SetDesiredFailureMsg( |
| 1826 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1827 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 1828 | |
| 1829 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1830 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1831 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1832 | |
| 1833 | VkPushConstantRange pc_range = {}; |
| 1834 | pc_range.size = 0xFFFFFFFFu; |
| 1835 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 1836 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1837 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1838 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 1839 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 1840 | |
| 1841 | VkPipelineLayout pipeline_layout; |
| 1842 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1843 | &pipeline_layout); |
| 1844 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1845 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 1846 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 1847 | pc_range.size = 0; |
| 1848 | m_errorMonitor->SetDesiredFailureMsg( |
| 1849 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1850 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 1851 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1852 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1853 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 1854 | pc_range.size = 1; |
| 1855 | m_errorMonitor->SetDesiredFailureMsg( |
| 1856 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1857 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 1858 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1859 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1860 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 1861 | // Cause error due to bad size in vkCmdPushConstants() call |
| 1862 | m_errorMonitor->SetDesiredFailureMsg( |
| 1863 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1864 | "vkCmdPushConstants() call has push constants with offset "); |
| 1865 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 1866 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 1867 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1868 | &pipeline_layout); |
| 1869 | ASSERT_VK_SUCCESS(err); |
| 1870 | BeginCommandBuffer(); |
| 1871 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 1872 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1873 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 1874 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1875 | } |
| 1876 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1877 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1878 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1879 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1880 | |
| 1881 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1882 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1883 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1884 | |
| 1885 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 1886 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1887 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1888 | ds_type_count[0].descriptorCount = 10; |
| 1889 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 1890 | ds_type_count[1].descriptorCount = 2; |
| 1891 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 1892 | ds_type_count[2].descriptorCount = 2; |
| 1893 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1894 | ds_type_count[3].descriptorCount = 5; |
| 1895 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 1896 | // type |
| 1897 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 1898 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 1899 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1900 | |
| 1901 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1902 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1903 | ds_pool_ci.pNext = NULL; |
| 1904 | ds_pool_ci.maxSets = 5; |
| 1905 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 1906 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1907 | |
| 1908 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1909 | err = |
| 1910 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1911 | ASSERT_VK_SUCCESS(err); |
| 1912 | |
| 1913 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 1914 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1915 | dsl_binding[0].binding = 0; |
| 1916 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1917 | dsl_binding[0].descriptorCount = 5; |
| 1918 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 1919 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1920 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1921 | // Create layout identical to set0 layout but w/ different stageFlags |
| 1922 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1923 | dsl_fs_stage_only.binding = 0; |
| 1924 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1925 | dsl_fs_stage_only.descriptorCount = 5; |
| 1926 | dsl_fs_stage_only.stageFlags = |
| 1927 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 1928 | // bind time |
| 1929 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1930 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1931 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1932 | ds_layout_ci.pNext = NULL; |
| 1933 | ds_layout_ci.bindingCount = 1; |
| 1934 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1935 | static const uint32_t NUM_LAYOUTS = 4; |
| 1936 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1937 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1938 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 1939 | // layout for error case |
| 1940 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1941 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1942 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1943 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1944 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1945 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1946 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1947 | dsl_binding[0].binding = 0; |
| 1948 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1949 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 1950 | dsl_binding[1].binding = 1; |
| 1951 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 1952 | dsl_binding[1].descriptorCount = 2; |
| 1953 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 1954 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1955 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1956 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1957 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1958 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1959 | ASSERT_VK_SUCCESS(err); |
| 1960 | dsl_binding[0].binding = 0; |
| 1961 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1962 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1963 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1964 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1965 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1966 | ASSERT_VK_SUCCESS(err); |
| 1967 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1968 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1969 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1970 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1971 | ASSERT_VK_SUCCESS(err); |
| 1972 | |
| 1973 | static const uint32_t NUM_SETS = 4; |
| 1974 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 1975 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1976 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1977 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1978 | alloc_info.descriptorPool = ds_pool; |
| 1979 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1980 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1981 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1982 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1983 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1984 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1985 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1986 | err = |
| 1987 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1988 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1989 | |
| 1990 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1991 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1992 | pipeline_layout_ci.pNext = NULL; |
| 1993 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 1994 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1995 | |
| 1996 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1997 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1998 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1999 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2000 | // Create pipelineLayout with only one setLayout |
| 2001 | pipeline_layout_ci.setLayoutCount = 1; |
| 2002 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2003 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2004 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2005 | ASSERT_VK_SUCCESS(err); |
| 2006 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 2007 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 2008 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2009 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2010 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2011 | ASSERT_VK_SUCCESS(err); |
| 2012 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 2013 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 2014 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2015 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2016 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2017 | ASSERT_VK_SUCCESS(err); |
| 2018 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 2019 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 2020 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2021 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2022 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2023 | ASSERT_VK_SUCCESS(err); |
| 2024 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 2025 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 2026 | pl_bad_s0[0] = ds_layout_fs_only; |
| 2027 | pl_bad_s0[1] = ds_layout[1]; |
| 2028 | pipeline_layout_ci.setLayoutCount = 2; |
| 2029 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 2030 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2031 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2032 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2033 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2034 | |
| 2035 | // Create a buffer to update the descriptor with |
| 2036 | uint32_t qfi = 0; |
| 2037 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2038 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2039 | buffCI.size = 1024; |
| 2040 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 2041 | buffCI.queueFamilyIndexCount = 1; |
| 2042 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2043 | |
| 2044 | VkBuffer dyub; |
| 2045 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 2046 | ASSERT_VK_SUCCESS(err); |
| 2047 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 2048 | static const uint32_t NUM_BUFFS = 5; |
| 2049 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2050 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2051 | buffInfo[i].buffer = dyub; |
| 2052 | buffInfo[i].offset = 0; |
| 2053 | buffInfo[i].range = 1024; |
| 2054 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2055 | VkImage image; |
| 2056 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2057 | const int32_t tex_width = 32; |
| 2058 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2059 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2060 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2061 | image_create_info.pNext = NULL; |
| 2062 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2063 | image_create_info.format = tex_format; |
| 2064 | image_create_info.extent.width = tex_width; |
| 2065 | image_create_info.extent.height = tex_height; |
| 2066 | image_create_info.extent.depth = 1; |
| 2067 | image_create_info.mipLevels = 1; |
| 2068 | image_create_info.arrayLayers = 1; |
| 2069 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2070 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2071 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2072 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2073 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 2074 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2075 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2076 | VkMemoryRequirements memReqs; |
| 2077 | VkDeviceMemory imageMem; |
| 2078 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2079 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2080 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2081 | memAlloc.pNext = NULL; |
| 2082 | memAlloc.allocationSize = 0; |
| 2083 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2084 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 2085 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2086 | pass = |
| 2087 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2088 | ASSERT_TRUE(pass); |
| 2089 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 2090 | ASSERT_VK_SUCCESS(err); |
| 2091 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 2092 | ASSERT_VK_SUCCESS(err); |
| 2093 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2094 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2095 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2096 | image_view_create_info.image = image; |
| 2097 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2098 | image_view_create_info.format = tex_format; |
| 2099 | image_view_create_info.subresourceRange.layerCount = 1; |
| 2100 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 2101 | image_view_create_info.subresourceRange.levelCount = 1; |
| 2102 | image_view_create_info.subresourceRange.aspectMask = |
| 2103 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2104 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2105 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2106 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 2107 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2108 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2109 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2110 | imageInfo[0].imageView = view; |
| 2111 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2112 | imageInfo[1].imageView = view; |
| 2113 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2114 | imageInfo[2].imageView = view; |
| 2115 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2116 | imageInfo[3].imageView = view; |
| 2117 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2118 | |
| 2119 | static const uint32_t NUM_SET_UPDATES = 3; |
| 2120 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 2121 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2122 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 2123 | descriptor_write[0].dstBinding = 0; |
| 2124 | descriptor_write[0].descriptorCount = 5; |
| 2125 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2126 | descriptor_write[0].pBufferInfo = buffInfo; |
| 2127 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2128 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 2129 | descriptor_write[1].dstBinding = 0; |
| 2130 | descriptor_write[1].descriptorCount = 2; |
| 2131 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 2132 | descriptor_write[1].pImageInfo = imageInfo; |
| 2133 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2134 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 2135 | descriptor_write[2].dstBinding = 1; |
| 2136 | descriptor_write[2].descriptorCount = 2; |
| 2137 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2138 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2139 | |
| 2140 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2141 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2142 | // Create PSO to be used for draw-time errors below |
| 2143 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 2144 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2145 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2146 | "out gl_PerVertex {\n" |
| 2147 | " vec4 gl_Position;\n" |
| 2148 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2149 | "void main(){\n" |
| 2150 | " gl_Position = vec4(1);\n" |
| 2151 | "}\n"; |
| 2152 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 2153 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2154 | "\n" |
| 2155 | "layout(location=0) out vec4 x;\n" |
| 2156 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 2157 | "void main(){\n" |
| 2158 | " x = vec4(bar.y);\n" |
| 2159 | "}\n"; |
| 2160 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2161 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2162 | VkPipelineObj pipe(m_device); |
| 2163 | pipe.AddShader(&vs); |
| 2164 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2165 | pipe.AddColorAttachment(); |
| 2166 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2167 | |
| 2168 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2169 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2170 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2171 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2172 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 2173 | // of PSO |
| 2174 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 2175 | // cmd_pipeline.c |
| 2176 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 2177 | // cmd_bind_graphics_pipeline() |
| 2178 | // TODO : Want to cause various binding incompatibility issues here to test |
| 2179 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2180 | // First cause various verify_layout_compatibility() fails |
| 2181 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2182 | // verify_set_layout_compatibility fail cases: |
| 2183 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2184 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2185 | " due to: invalid VkPipelineLayout "); |
| 2186 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2187 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2188 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 2189 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2190 | m_errorMonitor->VerifyFound(); |
| 2191 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2192 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2193 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2194 | " attempting to bind set to index 1"); |
| 2195 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2196 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 2197 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2198 | m_errorMonitor->VerifyFound(); |
| 2199 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2200 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2201 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 2202 | // descriptors |
| 2203 | m_errorMonitor->SetDesiredFailureMsg( |
| 2204 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2205 | ", but corresponding set being bound has 5 descriptors."); |
| 2206 | vkCmdBindDescriptorSets( |
| 2207 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2208 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2209 | m_errorMonitor->VerifyFound(); |
| 2210 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2211 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 2212 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2213 | m_errorMonitor->SetDesiredFailureMsg( |
| 2214 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2215 | " descriptor from pipelineLayout is type 'VK_DESCRIPTOR_TYPE_SAMPLER'"); |
| 2216 | vkCmdBindDescriptorSets( |
| 2217 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2218 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2219 | m_errorMonitor->VerifyFound(); |
| 2220 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2221 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 2222 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2223 | m_errorMonitor->SetDesiredFailureMsg( |
| 2224 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2225 | " descriptor from pipelineLayout has stageFlags "); |
| 2226 | vkCmdBindDescriptorSets( |
| 2227 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2228 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2229 | m_errorMonitor->VerifyFound(); |
| 2230 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2231 | // Cause INFO messages due to disturbing previously bound Sets |
| 2232 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2233 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2234 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2235 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2236 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2237 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2238 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2239 | " previously bound as set #0 was disturbed "); |
| 2240 | vkCmdBindDescriptorSets( |
| 2241 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2242 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2243 | m_errorMonitor->VerifyFound(); |
| 2244 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2245 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2246 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2247 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2248 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2249 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2250 | " newly bound as set #0 so set #1 and " |
| 2251 | "any subsequent sets were disturbed "); |
| 2252 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2253 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2254 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2255 | m_errorMonitor->VerifyFound(); |
| 2256 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2257 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2258 | // 1. Error due to not binding required set (we actually use same code as |
| 2259 | // above to disturb set0) |
| 2260 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2261 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2262 | 2, &descriptorSet[0], 0, NULL); |
| 2263 | vkCmdBindDescriptorSets( |
| 2264 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2265 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 2266 | m_errorMonitor->SetDesiredFailureMsg( |
| 2267 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2268 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2269 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2270 | m_errorMonitor->VerifyFound(); |
| 2271 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2272 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2273 | // 2. Error due to bound set not being compatible with PSO's |
| 2274 | // VkPipelineLayout (diff stageFlags in this case) |
| 2275 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2276 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2277 | 2, &descriptorSet[0], 0, NULL); |
| 2278 | m_errorMonitor->SetDesiredFailureMsg( |
| 2279 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2280 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2281 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2282 | m_errorMonitor->VerifyFound(); |
| 2283 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2284 | // Remaining clean-up |
| 2285 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2286 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2287 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 2288 | } |
| 2289 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
| 2290 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, descriptorSet); |
| 2291 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2292 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2293 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2294 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2295 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2296 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2297 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2298 | m_errorMonitor->SetDesiredFailureMsg( |
| 2299 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2300 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2301 | |
| 2302 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2303 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2304 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2305 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2306 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2307 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2308 | } |
| 2309 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2310 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 2311 | VkResult err; |
| 2312 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2313 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2314 | m_errorMonitor->SetDesiredFailureMsg( |
| 2315 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 2316 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2317 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2318 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2319 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2320 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2321 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2322 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2323 | cmd.commandPool = m_commandPool; |
| 2324 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2325 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2326 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2327 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2328 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2329 | |
| 2330 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2331 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2332 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2333 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2334 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2335 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 2336 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2337 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2338 | |
| 2339 | // The error should be caught by validation of the BeginCommandBuffer call |
| 2340 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 2341 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2342 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2343 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2344 | } |
| 2345 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2346 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2347 | // Cause error due to Begin while recording CB |
| 2348 | // Then cause 2 errors for attempting to reset CB w/o having |
| 2349 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 2350 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2351 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2352 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2353 | |
| 2354 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2355 | |
| 2356 | // Calls AllocateCommandBuffers |
| 2357 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 2358 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2359 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 2360 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2361 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2362 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2363 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2364 | cmd_buf_info.pNext = NULL; |
| 2365 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2366 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2367 | |
| 2368 | // Begin CB to transition to recording state |
| 2369 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2370 | // Can't re-begin. This should trigger error |
| 2371 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2372 | m_errorMonitor->VerifyFound(); |
| 2373 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2374 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2375 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2376 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 2377 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 2378 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2379 | m_errorMonitor->VerifyFound(); |
| 2380 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2381 | m_errorMonitor->SetDesiredFailureMsg( |
| 2382 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2383 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2384 | // Transition CB to RECORDED state |
| 2385 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 2386 | // Now attempting to Begin will implicitly reset, which triggers error |
| 2387 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2388 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2389 | } |
| 2390 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2391 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2392 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2393 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2394 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2395 | m_errorMonitor->SetDesiredFailureMsg( |
| 2396 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2397 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 2398 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2399 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2400 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2401 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2402 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2403 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2404 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2405 | |
| 2406 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2407 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2408 | ds_pool_ci.pNext = NULL; |
| 2409 | ds_pool_ci.maxSets = 1; |
| 2410 | ds_pool_ci.poolSizeCount = 1; |
| 2411 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2412 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2413 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2414 | err = |
| 2415 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2416 | ASSERT_VK_SUCCESS(err); |
| 2417 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2418 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2419 | dsl_binding.binding = 0; |
| 2420 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2421 | dsl_binding.descriptorCount = 1; |
| 2422 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2423 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2424 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2425 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2426 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2427 | ds_layout_ci.pNext = NULL; |
| 2428 | ds_layout_ci.bindingCount = 1; |
| 2429 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2430 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2431 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2432 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2433 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2434 | ASSERT_VK_SUCCESS(err); |
| 2435 | |
| 2436 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2437 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2438 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2439 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2440 | alloc_info.descriptorPool = ds_pool; |
| 2441 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2442 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2443 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2444 | ASSERT_VK_SUCCESS(err); |
| 2445 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2446 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2447 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2448 | pipeline_layout_ci.setLayoutCount = 1; |
| 2449 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2450 | |
| 2451 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2452 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2453 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2454 | ASSERT_VK_SUCCESS(err); |
| 2455 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2456 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2457 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2458 | |
| 2459 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2460 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2461 | vp_state_ci.scissorCount = 1; |
| 2462 | vp_state_ci.pScissors = ≻ |
| 2463 | vp_state_ci.viewportCount = 1; |
| 2464 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2465 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2466 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 2467 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 2468 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 2469 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 2470 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 2471 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 2472 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 2473 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 2474 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2475 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2476 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2477 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2478 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2479 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2480 | gp_ci.layout = pipeline_layout; |
| 2481 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2482 | |
| 2483 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2484 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2485 | pc_ci.initialDataSize = 0; |
| 2486 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2487 | |
| 2488 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2489 | VkPipelineCache pipelineCache; |
| 2490 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2491 | err = |
| 2492 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2493 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2494 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2495 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2496 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2497 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2498 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2499 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2500 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2501 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2502 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2503 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2504 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 2505 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 2506 | { |
| 2507 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2508 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2509 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2510 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2511 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 2512 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2513 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2514 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2515 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2516 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2517 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2518 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2519 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2520 | |
| 2521 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2522 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2523 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2524 | ds_pool_ci.poolSizeCount = 1; |
| 2525 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2526 | |
| 2527 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2528 | err = vkCreateDescriptorPool(m_device->device(), |
| 2529 | 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] | 2530 | ASSERT_VK_SUCCESS(err); |
| 2531 | |
| 2532 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2533 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2534 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2535 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2536 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2537 | dsl_binding.pImmutableSamplers = NULL; |
| 2538 | |
| 2539 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2540 | ds_layout_ci.sType = |
| 2541 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2542 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2543 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2544 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2545 | |
| 2546 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2547 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2548 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2549 | ASSERT_VK_SUCCESS(err); |
| 2550 | |
| 2551 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2552 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 2553 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2554 | ASSERT_VK_SUCCESS(err); |
| 2555 | |
| 2556 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2557 | pipeline_layout_ci.sType = |
| 2558 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2559 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2560 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2561 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2562 | |
| 2563 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2564 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2565 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2566 | ASSERT_VK_SUCCESS(err); |
| 2567 | |
| 2568 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 2569 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 2570 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2571 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 2572 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2573 | // 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] | 2574 | VkShaderObj |
| 2575 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 2576 | this); |
| 2577 | VkShaderObj |
| 2578 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 2579 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2580 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2581 | shaderStages[0].sType = |
| 2582 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2583 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2584 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2585 | shaderStages[1].sType = |
| 2586 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2587 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2588 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2589 | shaderStages[2].sType = |
| 2590 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2591 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2592 | shaderStages[2].shader = te.handle(); |
| 2593 | |
| 2594 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2595 | iaCI.sType = |
| 2596 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2597 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2598 | |
| 2599 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 2600 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 2601 | tsCI.patchControlPoints = 0; // This will cause an error |
| 2602 | |
| 2603 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2604 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2605 | gp_ci.pNext = NULL; |
| 2606 | gp_ci.stageCount = 3; |
| 2607 | gp_ci.pStages = shaderStages; |
| 2608 | gp_ci.pVertexInputState = NULL; |
| 2609 | gp_ci.pInputAssemblyState = &iaCI; |
| 2610 | gp_ci.pTessellationState = &tsCI; |
| 2611 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2612 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2613 | gp_ci.pMultisampleState = NULL; |
| 2614 | gp_ci.pDepthStencilState = NULL; |
| 2615 | gp_ci.pColorBlendState = NULL; |
| 2616 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2617 | gp_ci.layout = pipeline_layout; |
| 2618 | gp_ci.renderPass = renderPass(); |
| 2619 | |
| 2620 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2621 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2622 | pc_ci.pNext = NULL; |
| 2623 | pc_ci.initialSize = 0; |
| 2624 | pc_ci.initialData = 0; |
| 2625 | pc_ci.maxSize = 0; |
| 2626 | |
| 2627 | VkPipeline pipeline; |
| 2628 | VkPipelineCache pipelineCache; |
| 2629 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2630 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 2631 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2632 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2633 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2634 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2635 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2636 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2637 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2638 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2639 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2640 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2641 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2642 | } |
| 2643 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2644 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2645 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2646 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2647 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2648 | m_errorMonitor->SetDesiredFailureMsg( |
| 2649 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2650 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2651 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2652 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2653 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2654 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2655 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2656 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2657 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2658 | |
| 2659 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2660 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2661 | ds_pool_ci.maxSets = 1; |
| 2662 | ds_pool_ci.poolSizeCount = 1; |
| 2663 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2664 | |
| 2665 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2666 | err = |
| 2667 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2668 | ASSERT_VK_SUCCESS(err); |
| 2669 | |
| 2670 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2671 | dsl_binding.binding = 0; |
| 2672 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2673 | dsl_binding.descriptorCount = 1; |
| 2674 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2675 | |
| 2676 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2677 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2678 | ds_layout_ci.bindingCount = 1; |
| 2679 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2680 | |
| 2681 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2682 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2683 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2684 | ASSERT_VK_SUCCESS(err); |
| 2685 | |
| 2686 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2687 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2688 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2689 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2690 | alloc_info.descriptorPool = ds_pool; |
| 2691 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2692 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2693 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2694 | ASSERT_VK_SUCCESS(err); |
| 2695 | |
| 2696 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2697 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2698 | pipeline_layout_ci.setLayoutCount = 1; |
| 2699 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2700 | |
| 2701 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2702 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2703 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2704 | ASSERT_VK_SUCCESS(err); |
| 2705 | |
| 2706 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2707 | |
| 2708 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2709 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2710 | vp_state_ci.scissorCount = 0; |
| 2711 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2712 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2713 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2714 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 2715 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 2716 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 2717 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 2718 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 2719 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 2720 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 2721 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 2722 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2723 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2724 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2725 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2726 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 2727 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2728 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 2729 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 2730 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2731 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2732 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2733 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2734 | |
| 2735 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2736 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2737 | gp_ci.stageCount = 2; |
| 2738 | gp_ci.pStages = shaderStages; |
| 2739 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2740 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2741 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2742 | gp_ci.layout = pipeline_layout; |
| 2743 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2744 | |
| 2745 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2746 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2747 | |
| 2748 | VkPipeline pipeline; |
| 2749 | VkPipelineCache pipelineCache; |
| 2750 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2751 | err = |
| 2752 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2753 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2754 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2755 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2756 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2757 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2758 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2759 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2760 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2761 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2762 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2763 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2764 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 2765 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2766 | // 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] | 2767 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2768 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2769 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [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 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2774 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2775 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2776 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2777 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2778 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2779 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2780 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2781 | |
| 2782 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2783 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2784 | ds_pool_ci.maxSets = 1; |
| 2785 | ds_pool_ci.poolSizeCount = 1; |
| 2786 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2787 | |
| 2788 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2789 | err = |
| 2790 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2791 | ASSERT_VK_SUCCESS(err); |
| 2792 | |
| 2793 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2794 | dsl_binding.binding = 0; |
| 2795 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2796 | dsl_binding.descriptorCount = 1; |
| 2797 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2798 | |
| 2799 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2800 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2801 | ds_layout_ci.bindingCount = 1; |
| 2802 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2803 | |
| 2804 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2805 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2806 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2807 | ASSERT_VK_SUCCESS(err); |
| 2808 | |
| 2809 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2810 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2811 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2812 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2813 | alloc_info.descriptorPool = ds_pool; |
| 2814 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2815 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2816 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2817 | ASSERT_VK_SUCCESS(err); |
| 2818 | |
| 2819 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2820 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2821 | pipeline_layout_ci.setLayoutCount = 1; |
| 2822 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2823 | |
| 2824 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2825 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2826 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2827 | ASSERT_VK_SUCCESS(err); |
| 2828 | |
| 2829 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2830 | // Set scissor as dynamic to avoid second error |
| 2831 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2832 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2833 | dyn_state_ci.dynamicStateCount = 1; |
| 2834 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2835 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2836 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2837 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2838 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2839 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 2840 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2841 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 2842 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 2843 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2844 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2845 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2846 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2847 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2848 | |
| 2849 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 2850 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 2851 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 2852 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 2853 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 2854 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 2855 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 2856 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 2857 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2858 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2859 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2860 | gp_ci.stageCount = 2; |
| 2861 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2862 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2863 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 2864 | // should cause validation error |
| 2865 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2866 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2867 | gp_ci.layout = pipeline_layout; |
| 2868 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2869 | |
| 2870 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2871 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2872 | |
| 2873 | VkPipeline pipeline; |
| 2874 | VkPipelineCache pipelineCache; |
| 2875 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2876 | err = |
| 2877 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2878 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2879 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2880 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2881 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2882 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2883 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2884 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2885 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2886 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2887 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2888 | } |
| 2889 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2890 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 2891 | // count |
| 2892 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 2893 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2894 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2895 | m_errorMonitor->SetDesiredFailureMsg( |
| 2896 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2897 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 2898 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2899 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2900 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2901 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2902 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2903 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2904 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2905 | |
| 2906 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2907 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2908 | ds_pool_ci.maxSets = 1; |
| 2909 | ds_pool_ci.poolSizeCount = 1; |
| 2910 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2911 | |
| 2912 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2913 | err = |
| 2914 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2915 | ASSERT_VK_SUCCESS(err); |
| 2916 | |
| 2917 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2918 | dsl_binding.binding = 0; |
| 2919 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2920 | dsl_binding.descriptorCount = 1; |
| 2921 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2922 | |
| 2923 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2924 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2925 | ds_layout_ci.bindingCount = 1; |
| 2926 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2927 | |
| 2928 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2929 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2930 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2931 | ASSERT_VK_SUCCESS(err); |
| 2932 | |
| 2933 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2934 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2935 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2936 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2937 | alloc_info.descriptorPool = ds_pool; |
| 2938 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2939 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2940 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2941 | ASSERT_VK_SUCCESS(err); |
| 2942 | |
| 2943 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2944 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2945 | pipeline_layout_ci.setLayoutCount = 1; |
| 2946 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2947 | |
| 2948 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2949 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2950 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2951 | ASSERT_VK_SUCCESS(err); |
| 2952 | |
| 2953 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2954 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2955 | vp_state_ci.viewportCount = 1; |
| 2956 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2957 | vp_state_ci.scissorCount = 1; |
| 2958 | vp_state_ci.pScissors = |
| 2959 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2960 | |
| 2961 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2962 | // Set scissor as dynamic to avoid that error |
| 2963 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2964 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2965 | dyn_state_ci.dynamicStateCount = 1; |
| 2966 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2967 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2968 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2969 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2970 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2971 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 2972 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2973 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 2974 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 2975 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2976 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2977 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2978 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2979 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2980 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2981 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2982 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2983 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2984 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2985 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2986 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2987 | |
| 2988 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2989 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2990 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2991 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2992 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2993 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2994 | rs_ci.pNext = nullptr; |
| 2995 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 2996 | VkPipelineColorBlendAttachmentState att = {}; |
| 2997 | att.blendEnable = VK_FALSE; |
| 2998 | att.colorWriteMask = 0xf; |
| 2999 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3000 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 3001 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 3002 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3003 | cb_ci.attachmentCount = 1; |
| 3004 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3005 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3006 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3007 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3008 | gp_ci.stageCount = 2; |
| 3009 | gp_ci.pStages = shaderStages; |
| 3010 | gp_ci.pVertexInputState = &vi_ci; |
| 3011 | gp_ci.pInputAssemblyState = &ia_ci; |
| 3012 | gp_ci.pViewportState = &vp_state_ci; |
| 3013 | gp_ci.pRasterizationState = &rs_ci; |
| 3014 | gp_ci.pColorBlendState = &cb_ci; |
| 3015 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3016 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3017 | gp_ci.layout = pipeline_layout; |
| 3018 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3019 | |
| 3020 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3021 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3022 | |
| 3023 | VkPipeline pipeline; |
| 3024 | VkPipelineCache pipelineCache; |
| 3025 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3026 | err = |
| 3027 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3028 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3029 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3030 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3031 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3032 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3033 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3034 | // 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] | 3035 | // First need to successfully create the PSO from above by setting |
| 3036 | // pViewports |
| 3037 | m_errorMonitor->SetDesiredFailureMsg( |
| 3038 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3039 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 3040 | "scissorCount is 1. These counts must match."); |
| 3041 | |
| 3042 | VkViewport vp = {}; // Just need dummy vp to point to |
| 3043 | vp_state_ci.pViewports = &vp; |
| 3044 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3045 | &gp_ci, NULL, &pipeline); |
| 3046 | ASSERT_VK_SUCCESS(err); |
| 3047 | BeginCommandBuffer(); |
| 3048 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3049 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 3050 | VkRect2D scissors[2] = {}; // don't care about data |
| 3051 | // Count of 2 doesn't match PSO count of 1 |
| 3052 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 3053 | Draw(1, 0, 0, 0); |
| 3054 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3055 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3056 | |
| 3057 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3058 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3059 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3060 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3061 | } |
| 3062 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 3063 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 3064 | // viewportCount |
| 3065 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 3066 | VkResult err; |
| 3067 | |
| 3068 | m_errorMonitor->SetDesiredFailureMsg( |
| 3069 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3070 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 3071 | |
| 3072 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3073 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3074 | |
| 3075 | VkDescriptorPoolSize ds_type_count = {}; |
| 3076 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3077 | ds_type_count.descriptorCount = 1; |
| 3078 | |
| 3079 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3080 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3081 | ds_pool_ci.maxSets = 1; |
| 3082 | ds_pool_ci.poolSizeCount = 1; |
| 3083 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 3084 | |
| 3085 | VkDescriptorPool ds_pool; |
| 3086 | err = |
| 3087 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 3088 | ASSERT_VK_SUCCESS(err); |
| 3089 | |
| 3090 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3091 | dsl_binding.binding = 0; |
| 3092 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3093 | dsl_binding.descriptorCount = 1; |
| 3094 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3095 | |
| 3096 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3097 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3098 | ds_layout_ci.bindingCount = 1; |
| 3099 | ds_layout_ci.pBindings = &dsl_binding; |
| 3100 | |
| 3101 | VkDescriptorSetLayout ds_layout; |
| 3102 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3103 | &ds_layout); |
| 3104 | ASSERT_VK_SUCCESS(err); |
| 3105 | |
| 3106 | VkDescriptorSet descriptorSet; |
| 3107 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 3108 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 3109 | alloc_info.descriptorSetCount = 1; |
| 3110 | alloc_info.descriptorPool = ds_pool; |
| 3111 | alloc_info.pSetLayouts = &ds_layout; |
| 3112 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3113 | &descriptorSet); |
| 3114 | ASSERT_VK_SUCCESS(err); |
| 3115 | |
| 3116 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3117 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3118 | pipeline_layout_ci.setLayoutCount = 1; |
| 3119 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3120 | |
| 3121 | VkPipelineLayout pipeline_layout; |
| 3122 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3123 | &pipeline_layout); |
| 3124 | ASSERT_VK_SUCCESS(err); |
| 3125 | |
| 3126 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 3127 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3128 | vp_state_ci.scissorCount = 1; |
| 3129 | vp_state_ci.pScissors = |
| 3130 | NULL; // Null scissor w/ count of 1 should cause error |
| 3131 | vp_state_ci.viewportCount = 1; |
| 3132 | vp_state_ci.pViewports = |
| 3133 | NULL; // vp is dynamic (below) so this won't cause error |
| 3134 | |
| 3135 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 3136 | // Set scissor as dynamic to avoid that error |
| 3137 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 3138 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3139 | dyn_state_ci.dynamicStateCount = 1; |
| 3140 | dyn_state_ci.pDynamicStates = &vp_state; |
| 3141 | |
| 3142 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 3143 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 3144 | |
| 3145 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3146 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3147 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3148 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 3149 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3150 | // but add it to be able to run on more devices |
| 3151 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3152 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 3153 | |
| 3154 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 3155 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 3156 | vi_ci.pNext = nullptr; |
| 3157 | vi_ci.vertexBindingDescriptionCount = 0; |
| 3158 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 3159 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 3160 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 3161 | |
| 3162 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 3163 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 3164 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 3165 | |
| 3166 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 3167 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3168 | rs_ci.pNext = nullptr; |
| 3169 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3170 | VkPipelineColorBlendAttachmentState att = {}; |
| 3171 | att.blendEnable = VK_FALSE; |
| 3172 | att.colorWriteMask = 0xf; |
| 3173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3174 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 3175 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 3176 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3177 | cb_ci.attachmentCount = 1; |
| 3178 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3179 | |
| 3180 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 3181 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3182 | gp_ci.stageCount = 2; |
| 3183 | gp_ci.pStages = shaderStages; |
| 3184 | gp_ci.pVertexInputState = &vi_ci; |
| 3185 | gp_ci.pInputAssemblyState = &ia_ci; |
| 3186 | gp_ci.pViewportState = &vp_state_ci; |
| 3187 | gp_ci.pRasterizationState = &rs_ci; |
| 3188 | gp_ci.pColorBlendState = &cb_ci; |
| 3189 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3190 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3191 | gp_ci.layout = pipeline_layout; |
| 3192 | gp_ci.renderPass = renderPass(); |
| 3193 | |
| 3194 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 3195 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3196 | |
| 3197 | VkPipeline pipeline; |
| 3198 | VkPipelineCache pipelineCache; |
| 3199 | |
| 3200 | err = |
| 3201 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 3202 | ASSERT_VK_SUCCESS(err); |
| 3203 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3204 | &gp_ci, NULL, &pipeline); |
| 3205 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3206 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3207 | |
| 3208 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 3209 | // First need to successfully create the PSO from above by setting |
| 3210 | // pViewports |
| 3211 | m_errorMonitor->SetDesiredFailureMsg( |
| 3212 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3213 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 3214 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3215 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3216 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 3217 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3218 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3219 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3220 | ASSERT_VK_SUCCESS(err); |
| 3221 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3222 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3223 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3224 | VkViewport viewports[2] = {}; // don't care about data |
| 3225 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 3226 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3227 | Draw(1, 0, 0, 0); |
| 3228 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3229 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3230 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3231 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3232 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3233 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3234 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3235 | } |
| 3236 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3237 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3238 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3239 | m_errorMonitor->SetDesiredFailureMsg( |
| 3240 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3241 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3242 | |
| 3243 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3244 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3245 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3246 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3247 | // Don't care about RenderPass handle b/c error should be flagged before |
| 3248 | // that |
| 3249 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 3250 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3251 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3252 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3253 | } |
| 3254 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3255 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3256 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3257 | m_errorMonitor->SetDesiredFailureMsg( |
| 3258 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3259 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3260 | |
| 3261 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3262 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3263 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3264 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3265 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 3266 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3267 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3268 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 3269 | rp_begin.pNext = NULL; |
| 3270 | rp_begin.renderPass = renderPass(); |
| 3271 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3272 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3273 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 3274 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3275 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3276 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3277 | } |
| 3278 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3279 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3280 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3281 | m_errorMonitor->SetDesiredFailureMsg( |
| 3282 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3283 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3284 | |
| 3285 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3286 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3287 | |
| 3288 | // Renderpass is started here |
| 3289 | BeginCommandBuffer(); |
| 3290 | |
| 3291 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3292 | vk_testing::Buffer dstBuffer; |
| 3293 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3294 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3295 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3296 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3297 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3298 | } |
| 3299 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3300 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3301 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3302 | m_errorMonitor->SetDesiredFailureMsg( |
| 3303 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3304 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3305 | |
| 3306 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3307 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3308 | |
| 3309 | // Renderpass is started here |
| 3310 | BeginCommandBuffer(); |
| 3311 | |
| 3312 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3313 | vk_testing::Buffer dstBuffer; |
| 3314 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3315 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3316 | VkDeviceSize dstOffset = 0; |
| 3317 | VkDeviceSize dataSize = 1024; |
| 3318 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3319 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3320 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 3321 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3322 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3323 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3324 | } |
| 3325 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3326 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3327 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3328 | m_errorMonitor->SetDesiredFailureMsg( |
| 3329 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3330 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3331 | |
| 3332 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3333 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3334 | |
| 3335 | // Renderpass is started here |
| 3336 | BeginCommandBuffer(); |
| 3337 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 3338 | VkClearColorValue clear_color; |
| 3339 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3340 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 3341 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3342 | const int32_t tex_width = 32; |
| 3343 | const int32_t tex_height = 32; |
| 3344 | VkImageCreateInfo image_create_info = {}; |
| 3345 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3346 | image_create_info.pNext = NULL; |
| 3347 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3348 | image_create_info.format = tex_format; |
| 3349 | image_create_info.extent.width = tex_width; |
| 3350 | image_create_info.extent.height = tex_height; |
| 3351 | image_create_info.extent.depth = 1; |
| 3352 | image_create_info.mipLevels = 1; |
| 3353 | image_create_info.arrayLayers = 1; |
| 3354 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3355 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3356 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3357 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3358 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3359 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 3360 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3361 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3362 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 3363 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3364 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3365 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 3366 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3367 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3368 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3369 | } |
| 3370 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3371 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3372 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3373 | m_errorMonitor->SetDesiredFailureMsg( |
| 3374 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3375 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3376 | |
| 3377 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3378 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3379 | |
| 3380 | // Renderpass is started here |
| 3381 | BeginCommandBuffer(); |
| 3382 | |
| 3383 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 3384 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3385 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 3386 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3387 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3388 | image_create_info.extent.width = 64; |
| 3389 | image_create_info.extent.height = 64; |
| 3390 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3391 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3392 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3393 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3394 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 3395 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3396 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3397 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 3398 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3399 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3400 | vkCmdClearDepthStencilImage( |
| 3401 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 3402 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 3403 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3404 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3405 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3406 | } |
| 3407 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3408 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3409 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3410 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3411 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3412 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3413 | "vkCmdClearAttachments: This call " |
| 3414 | "must be issued inside an active " |
| 3415 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3416 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3417 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3418 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3419 | |
| 3420 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3421 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3422 | ASSERT_VK_SUCCESS(err); |
| 3423 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3424 | VkClearAttachment color_attachment; |
| 3425 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3426 | color_attachment.clearValue.color.float32[0] = 0; |
| 3427 | color_attachment.clearValue.color.float32[1] = 0; |
| 3428 | color_attachment.clearValue.color.float32[2] = 0; |
| 3429 | color_attachment.clearValue.color.float32[3] = 0; |
| 3430 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3431 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 3432 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 3433 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3434 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3435 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3436 | } |
| 3437 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3438 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3439 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3440 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3441 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3442 | m_errorMonitor->SetDesiredFailureMsg( |
| 3443 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3444 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 3445 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3446 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3447 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3448 | uint32_t qfi = 0; |
| 3449 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3450 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3451 | buffCI.size = 1024; |
| 3452 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 3453 | buffCI.queueFamilyIndexCount = 1; |
| 3454 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3455 | |
| 3456 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3457 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3458 | ASSERT_VK_SUCCESS(err); |
| 3459 | |
| 3460 | BeginCommandBuffer(); |
| 3461 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3462 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3463 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3464 | // 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] | 3465 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 3466 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3467 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3468 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3469 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3470 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3471 | } |
| 3472 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3473 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 3474 | // Create an out-of-range queueFamilyIndex |
| 3475 | m_errorMonitor->SetDesiredFailureMsg( |
| 3476 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 3477 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3478 | |
| 3479 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3480 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3481 | VkBufferCreateInfo buffCI = {}; |
| 3482 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3483 | buffCI.size = 1024; |
| 3484 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 3485 | buffCI.queueFamilyIndexCount = 1; |
| 3486 | // Introduce failure by specifying invalid queue_family_index |
| 3487 | uint32_t qfi = 777; |
| 3488 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 3489 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3490 | |
| 3491 | VkBuffer ib; |
| 3492 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 3493 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3494 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3495 | } |
| 3496 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3497 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 3498 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 3499 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3500 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3501 | m_errorMonitor->SetDesiredFailureMsg( |
| 3502 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3503 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3504 | |
| 3505 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3506 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3507 | |
| 3508 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3509 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3510 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 3511 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3512 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3513 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3514 | } |
| 3515 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3516 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3517 | // 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] | 3518 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3519 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3520 | m_errorMonitor->SetDesiredFailureMsg( |
| 3521 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Write descriptor update has descriptor " |
| 3522 | "type VK_DESCRIPTOR_TYPE_SAMPLER that " |
| 3523 | "does not match "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3524 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3525 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3526 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3527 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3528 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3529 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3530 | |
| 3531 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3532 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3533 | ds_pool_ci.pNext = NULL; |
| 3534 | ds_pool_ci.maxSets = 1; |
| 3535 | ds_pool_ci.poolSizeCount = 1; |
| 3536 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3537 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3538 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3539 | err = |
| 3540 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3541 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3542 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3543 | dsl_binding.binding = 0; |
| 3544 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3545 | dsl_binding.descriptorCount = 1; |
| 3546 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3547 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3548 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3549 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3550 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3551 | ds_layout_ci.pNext = NULL; |
| 3552 | ds_layout_ci.bindingCount = 1; |
| 3553 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3554 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3555 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3556 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3557 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3558 | ASSERT_VK_SUCCESS(err); |
| 3559 | |
| 3560 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3561 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3562 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3563 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3564 | alloc_info.descriptorPool = ds_pool; |
| 3565 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3566 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3567 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3568 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3569 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3570 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3571 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3572 | sampler_ci.pNext = NULL; |
| 3573 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3574 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3575 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3576 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3577 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3578 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3579 | sampler_ci.mipLodBias = 1.0; |
| 3580 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3581 | sampler_ci.maxAnisotropy = 1; |
| 3582 | sampler_ci.compareEnable = VK_FALSE; |
| 3583 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3584 | sampler_ci.minLod = 1.0; |
| 3585 | sampler_ci.maxLod = 1.0; |
| 3586 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3587 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3588 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3589 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3590 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3591 | ASSERT_VK_SUCCESS(err); |
| 3592 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3593 | VkDescriptorImageInfo info = {}; |
| 3594 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3595 | |
| 3596 | VkWriteDescriptorSet descriptor_write; |
| 3597 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3598 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3599 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3600 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3601 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3602 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3603 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3604 | |
| 3605 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3606 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3607 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3608 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3609 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3610 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3611 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3612 | } |
| 3613 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3614 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3615 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3616 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3617 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3618 | m_errorMonitor->SetDesiredFailureMsg( |
| 3619 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Descriptor update type of " |
| 3620 | "VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET " |
| 3621 | "is out of bounds for matching binding"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3622 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3623 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3624 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3625 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3626 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3627 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3628 | |
| 3629 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3630 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3631 | ds_pool_ci.pNext = NULL; |
| 3632 | ds_pool_ci.maxSets = 1; |
| 3633 | ds_pool_ci.poolSizeCount = 1; |
| 3634 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3635 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3636 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3637 | err = |
| 3638 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3639 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3640 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3641 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3642 | dsl_binding.binding = 0; |
| 3643 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3644 | dsl_binding.descriptorCount = 1; |
| 3645 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3646 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3647 | |
| 3648 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3649 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3650 | ds_layout_ci.pNext = NULL; |
| 3651 | ds_layout_ci.bindingCount = 1; |
| 3652 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3653 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3654 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3655 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3656 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3657 | ASSERT_VK_SUCCESS(err); |
| 3658 | |
| 3659 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3660 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3661 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3662 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3663 | alloc_info.descriptorPool = ds_pool; |
| 3664 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3665 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3666 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3667 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3668 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3669 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3670 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3671 | sampler_ci.pNext = NULL; |
| 3672 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3673 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3674 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3675 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3676 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3677 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3678 | sampler_ci.mipLodBias = 1.0; |
| 3679 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3680 | sampler_ci.maxAnisotropy = 1; |
| 3681 | sampler_ci.compareEnable = VK_FALSE; |
| 3682 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3683 | sampler_ci.minLod = 1.0; |
| 3684 | sampler_ci.maxLod = 1.0; |
| 3685 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3686 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3687 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3688 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3689 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3690 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3691 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3692 | VkDescriptorImageInfo info = {}; |
| 3693 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3694 | |
| 3695 | VkWriteDescriptorSet descriptor_write; |
| 3696 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3697 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3698 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3699 | descriptor_write.dstArrayElement = |
| 3700 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3701 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3702 | // 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] | 3703 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3704 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3705 | |
| 3706 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3707 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3708 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3709 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3710 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3711 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3712 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3713 | } |
| 3714 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3715 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 3716 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 3717 | // index 2 |
| 3718 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3719 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3720 | m_errorMonitor->SetDesiredFailureMsg( |
| 3721 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3722 | " does not have binding to match update binding "); |
| 3723 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3724 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3725 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3726 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3727 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3728 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3729 | |
| 3730 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3731 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3732 | ds_pool_ci.pNext = NULL; |
| 3733 | ds_pool_ci.maxSets = 1; |
| 3734 | ds_pool_ci.poolSizeCount = 1; |
| 3735 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3736 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3737 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3738 | err = |
| 3739 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3740 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3741 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3742 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3743 | dsl_binding.binding = 0; |
| 3744 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3745 | dsl_binding.descriptorCount = 1; |
| 3746 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3747 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3748 | |
| 3749 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3750 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3751 | ds_layout_ci.pNext = NULL; |
| 3752 | ds_layout_ci.bindingCount = 1; |
| 3753 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3754 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3755 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3756 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3757 | ASSERT_VK_SUCCESS(err); |
| 3758 | |
| 3759 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3760 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3761 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3762 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3763 | alloc_info.descriptorPool = ds_pool; |
| 3764 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3765 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3766 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3767 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3768 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3769 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3770 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3771 | sampler_ci.pNext = NULL; |
| 3772 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3773 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3774 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3775 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3776 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3777 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3778 | sampler_ci.mipLodBias = 1.0; |
| 3779 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3780 | sampler_ci.maxAnisotropy = 1; |
| 3781 | sampler_ci.compareEnable = VK_FALSE; |
| 3782 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3783 | sampler_ci.minLod = 1.0; |
| 3784 | sampler_ci.maxLod = 1.0; |
| 3785 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3786 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3787 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3788 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3789 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3790 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3791 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3792 | VkDescriptorImageInfo info = {}; |
| 3793 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3794 | |
| 3795 | VkWriteDescriptorSet descriptor_write; |
| 3796 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3797 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3798 | descriptor_write.dstSet = descriptorSet; |
| 3799 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3800 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3801 | // 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] | 3802 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3803 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3804 | |
| 3805 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3806 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3807 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3808 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3809 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3810 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3811 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3812 | } |
| 3813 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3814 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 3815 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 3816 | // types |
| 3817 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3818 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3819 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3820 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3821 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3822 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3823 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3824 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3825 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3826 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3827 | |
| 3828 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3829 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3830 | ds_pool_ci.pNext = NULL; |
| 3831 | ds_pool_ci.maxSets = 1; |
| 3832 | ds_pool_ci.poolSizeCount = 1; |
| 3833 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3834 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3835 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3836 | err = |
| 3837 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3838 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3839 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3840 | dsl_binding.binding = 0; |
| 3841 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3842 | dsl_binding.descriptorCount = 1; |
| 3843 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3844 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3845 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3846 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3847 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3848 | ds_layout_ci.pNext = NULL; |
| 3849 | ds_layout_ci.bindingCount = 1; |
| 3850 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3851 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3852 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3853 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3854 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3855 | ASSERT_VK_SUCCESS(err); |
| 3856 | |
| 3857 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3858 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3859 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3860 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3861 | alloc_info.descriptorPool = ds_pool; |
| 3862 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3863 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3864 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3865 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3866 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3867 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3868 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3869 | sampler_ci.pNext = NULL; |
| 3870 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3871 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3872 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3873 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3874 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3875 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3876 | sampler_ci.mipLodBias = 1.0; |
| 3877 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3878 | sampler_ci.maxAnisotropy = 1; |
| 3879 | sampler_ci.compareEnable = VK_FALSE; |
| 3880 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3881 | sampler_ci.minLod = 1.0; |
| 3882 | sampler_ci.maxLod = 1.0; |
| 3883 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3884 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3885 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3886 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3887 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3888 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3889 | VkDescriptorImageInfo info = {}; |
| 3890 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3891 | |
| 3892 | VkWriteDescriptorSet descriptor_write; |
| 3893 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3894 | descriptor_write.sType = |
| 3895 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3896 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3897 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3898 | // 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] | 3899 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3900 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3901 | |
| 3902 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3903 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3904 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3905 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3906 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3907 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3908 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3909 | } |
| 3910 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3911 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3912 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3913 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3914 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3915 | m_errorMonitor->SetDesiredFailureMsg( |
| 3916 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3917 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 3918 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3919 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3920 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 3921 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3922 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3923 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3924 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3925 | |
| 3926 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3927 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3928 | ds_pool_ci.pNext = NULL; |
| 3929 | ds_pool_ci.maxSets = 1; |
| 3930 | ds_pool_ci.poolSizeCount = 1; |
| 3931 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3932 | |
| 3933 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3934 | err = |
| 3935 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3936 | ASSERT_VK_SUCCESS(err); |
| 3937 | |
| 3938 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3939 | dsl_binding.binding = 0; |
| 3940 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3941 | dsl_binding.descriptorCount = 1; |
| 3942 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3943 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3944 | |
| 3945 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3946 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3947 | ds_layout_ci.pNext = NULL; |
| 3948 | ds_layout_ci.bindingCount = 1; |
| 3949 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3950 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3951 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3952 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3953 | ASSERT_VK_SUCCESS(err); |
| 3954 | |
| 3955 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3956 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3957 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3958 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3959 | alloc_info.descriptorPool = ds_pool; |
| 3960 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3961 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3962 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3963 | ASSERT_VK_SUCCESS(err); |
| 3964 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3965 | VkSampler sampler = |
| 3966 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3967 | |
| 3968 | VkDescriptorImageInfo descriptor_info; |
| 3969 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3970 | descriptor_info.sampler = sampler; |
| 3971 | |
| 3972 | VkWriteDescriptorSet descriptor_write; |
| 3973 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3974 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3975 | descriptor_write.dstSet = descriptorSet; |
| 3976 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3977 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3978 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3979 | descriptor_write.pImageInfo = &descriptor_info; |
| 3980 | |
| 3981 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3982 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3983 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3984 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3985 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3986 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3987 | } |
| 3988 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3989 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 3990 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 3991 | // imageView |
| 3992 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3993 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3994 | m_errorMonitor->SetDesiredFailureMsg( |
| 3995 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3996 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 3997 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3998 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3999 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4000 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4001 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4002 | |
| 4003 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4004 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4005 | ds_pool_ci.pNext = NULL; |
| 4006 | ds_pool_ci.maxSets = 1; |
| 4007 | ds_pool_ci.poolSizeCount = 1; |
| 4008 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4009 | |
| 4010 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4011 | err = |
| 4012 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4013 | ASSERT_VK_SUCCESS(err); |
| 4014 | |
| 4015 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4016 | dsl_binding.binding = 0; |
| 4017 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4018 | dsl_binding.descriptorCount = 1; |
| 4019 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4020 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4021 | |
| 4022 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4023 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4024 | ds_layout_ci.pNext = NULL; |
| 4025 | ds_layout_ci.bindingCount = 1; |
| 4026 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4027 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4028 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4029 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4030 | ASSERT_VK_SUCCESS(err); |
| 4031 | |
| 4032 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4033 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4034 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4035 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4036 | alloc_info.descriptorPool = ds_pool; |
| 4037 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4038 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4039 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4040 | ASSERT_VK_SUCCESS(err); |
| 4041 | |
| 4042 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4043 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4044 | sampler_ci.pNext = NULL; |
| 4045 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4046 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4047 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4048 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4049 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4050 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4051 | sampler_ci.mipLodBias = 1.0; |
| 4052 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4053 | sampler_ci.maxAnisotropy = 1; |
| 4054 | sampler_ci.compareEnable = VK_FALSE; |
| 4055 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4056 | sampler_ci.minLod = 1.0; |
| 4057 | sampler_ci.maxLod = 1.0; |
| 4058 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4059 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4060 | |
| 4061 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4062 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4063 | ASSERT_VK_SUCCESS(err); |
| 4064 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4065 | VkImageView view = |
| 4066 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4067 | |
| 4068 | VkDescriptorImageInfo descriptor_info; |
| 4069 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 4070 | descriptor_info.sampler = sampler; |
| 4071 | descriptor_info.imageView = view; |
| 4072 | |
| 4073 | VkWriteDescriptorSet descriptor_write; |
| 4074 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4075 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4076 | descriptor_write.dstSet = descriptorSet; |
| 4077 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4078 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4079 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4080 | descriptor_write.pImageInfo = &descriptor_info; |
| 4081 | |
| 4082 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4083 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4084 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4085 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4086 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4087 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4088 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4089 | } |
| 4090 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4091 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 4092 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 4093 | // into the other |
| 4094 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4095 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4096 | m_errorMonitor->SetDesiredFailureMsg( |
| 4097 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Copy descriptor update index 0, update " |
| 4098 | "count #1, has src update descriptor " |
| 4099 | "type VK_DESCRIPTOR_TYPE_SAMPLER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4100 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4101 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4102 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4103 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4104 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4105 | ds_type_count[0].descriptorCount = 1; |
| 4106 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4107 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4108 | |
| 4109 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4110 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4111 | ds_pool_ci.pNext = NULL; |
| 4112 | ds_pool_ci.maxSets = 1; |
| 4113 | ds_pool_ci.poolSizeCount = 2; |
| 4114 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4115 | |
| 4116 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4117 | err = |
| 4118 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4119 | ASSERT_VK_SUCCESS(err); |
| 4120 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4121 | dsl_binding[0].binding = 0; |
| 4122 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4123 | dsl_binding[0].descriptorCount = 1; |
| 4124 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4125 | dsl_binding[0].pImmutableSamplers = NULL; |
| 4126 | dsl_binding[1].binding = 1; |
| 4127 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4128 | dsl_binding[1].descriptorCount = 1; |
| 4129 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 4130 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4131 | |
| 4132 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4133 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4134 | ds_layout_ci.pNext = NULL; |
| 4135 | ds_layout_ci.bindingCount = 2; |
| 4136 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4137 | |
| 4138 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4139 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4140 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4141 | ASSERT_VK_SUCCESS(err); |
| 4142 | |
| 4143 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4144 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4145 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4146 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4147 | alloc_info.descriptorPool = ds_pool; |
| 4148 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4149 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4150 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4151 | ASSERT_VK_SUCCESS(err); |
| 4152 | |
| 4153 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4154 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4155 | sampler_ci.pNext = NULL; |
| 4156 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4157 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4158 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4159 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4160 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4161 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4162 | sampler_ci.mipLodBias = 1.0; |
| 4163 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4164 | sampler_ci.maxAnisotropy = 1; |
| 4165 | sampler_ci.compareEnable = VK_FALSE; |
| 4166 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4167 | sampler_ci.minLod = 1.0; |
| 4168 | sampler_ci.maxLod = 1.0; |
| 4169 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4170 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4171 | |
| 4172 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4173 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4174 | ASSERT_VK_SUCCESS(err); |
| 4175 | |
| 4176 | VkDescriptorImageInfo info = {}; |
| 4177 | info.sampler = sampler; |
| 4178 | |
| 4179 | VkWriteDescriptorSet descriptor_write; |
| 4180 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 4181 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4182 | descriptor_write.dstSet = descriptorSet; |
| 4183 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4184 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4185 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4186 | descriptor_write.pImageInfo = &info; |
| 4187 | // This write update should succeed |
| 4188 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4189 | // Now perform a copy update that fails due to type mismatch |
| 4190 | VkCopyDescriptorSet copy_ds_update; |
| 4191 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4192 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4193 | copy_ds_update.srcSet = descriptorSet; |
| 4194 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4195 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4196 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4197 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4198 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4199 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4200 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4201 | // 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] | 4202 | m_errorMonitor->SetDesiredFailureMsg( |
| 4203 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4204 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4205 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4206 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4207 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4208 | copy_ds_update.srcBinding = |
| 4209 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4210 | copy_ds_update.dstSet = descriptorSet; |
| 4211 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4212 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4213 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4214 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4215 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4216 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4217 | // 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] | 4218 | m_errorMonitor->SetDesiredFailureMsg( |
| 4219 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4220 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 4221 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4222 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4223 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4224 | copy_ds_update.srcSet = descriptorSet; |
| 4225 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4226 | copy_ds_update.dstSet = descriptorSet; |
| 4227 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4228 | copy_ds_update.descriptorCount = |
| 4229 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4230 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4231 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4232 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4233 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4234 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4235 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4236 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4237 | } |
| 4238 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4239 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 4240 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 4241 | // sampleCount |
| 4242 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4243 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4244 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4245 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4246 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4247 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4248 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4249 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4250 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4251 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4252 | |
| 4253 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4254 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4255 | ds_pool_ci.pNext = NULL; |
| 4256 | ds_pool_ci.maxSets = 1; |
| 4257 | ds_pool_ci.poolSizeCount = 1; |
| 4258 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4259 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4260 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4261 | err = |
| 4262 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4263 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4264 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4265 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4266 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4267 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4268 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4269 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4270 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4271 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4272 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4273 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4274 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4275 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4276 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4277 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4278 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4279 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4280 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4281 | ASSERT_VK_SUCCESS(err); |
| 4282 | |
| 4283 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4284 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4285 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4286 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4287 | alloc_info.descriptorPool = ds_pool; |
| 4288 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4289 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4290 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4291 | ASSERT_VK_SUCCESS(err); |
| 4292 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4293 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4294 | pipe_ms_state_ci.sType = |
| 4295 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4296 | pipe_ms_state_ci.pNext = NULL; |
| 4297 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 4298 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4299 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4300 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4301 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4302 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4303 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4304 | pipeline_layout_ci.pNext = NULL; |
| 4305 | pipeline_layout_ci.setLayoutCount = 1; |
| 4306 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4307 | |
| 4308 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4309 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4310 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4311 | ASSERT_VK_SUCCESS(err); |
| 4312 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4313 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4314 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4315 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4316 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 4317 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4318 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4319 | VkPipelineObj pipe(m_device); |
| 4320 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4321 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4322 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4323 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4324 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4325 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4326 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4327 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4328 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4329 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4330 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4331 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4332 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4333 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4334 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4335 | } |
Tobin Ehlis | 0f10db5 | 2016-04-04 10:00:21 -0600 | [diff] [blame] | 4336 | #ifdef ADD_BACK_IN_WHEN_CHECK_IS_BACK // TODO : Re-enable when GH256 fixed |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4337 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 4338 | // Create Pipeline where the number of blend attachments doesn't match the |
| 4339 | // number of color attachments. In this case, we don't add any color |
| 4340 | // blend attachments even though we have a color attachment. |
| 4341 | VkResult err; |
| 4342 | |
| 4343 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4344 | "Mismatch between blend state attachment"); |
| 4345 | |
| 4346 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4347 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4348 | VkDescriptorPoolSize ds_type_count = {}; |
| 4349 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4350 | ds_type_count.descriptorCount = 1; |
| 4351 | |
| 4352 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4353 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4354 | ds_pool_ci.pNext = NULL; |
| 4355 | ds_pool_ci.maxSets = 1; |
| 4356 | ds_pool_ci.poolSizeCount = 1; |
| 4357 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4358 | |
| 4359 | VkDescriptorPool ds_pool; |
| 4360 | err = |
| 4361 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4362 | ASSERT_VK_SUCCESS(err); |
| 4363 | |
| 4364 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4365 | dsl_binding.binding = 0; |
| 4366 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4367 | dsl_binding.descriptorCount = 1; |
| 4368 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4369 | dsl_binding.pImmutableSamplers = NULL; |
| 4370 | |
| 4371 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4372 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4373 | ds_layout_ci.pNext = NULL; |
| 4374 | ds_layout_ci.bindingCount = 1; |
| 4375 | ds_layout_ci.pBindings = &dsl_binding; |
| 4376 | |
| 4377 | VkDescriptorSetLayout ds_layout; |
| 4378 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4379 | &ds_layout); |
| 4380 | ASSERT_VK_SUCCESS(err); |
| 4381 | |
| 4382 | VkDescriptorSet descriptorSet; |
| 4383 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4384 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4385 | alloc_info.descriptorSetCount = 1; |
| 4386 | alloc_info.descriptorPool = ds_pool; |
| 4387 | alloc_info.pSetLayouts = &ds_layout; |
| 4388 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4389 | &descriptorSet); |
| 4390 | ASSERT_VK_SUCCESS(err); |
| 4391 | |
| 4392 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4393 | pipe_ms_state_ci.sType = |
| 4394 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4395 | pipe_ms_state_ci.pNext = NULL; |
| 4396 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 4397 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4398 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4399 | pipe_ms_state_ci.pSampleMask = NULL; |
| 4400 | |
| 4401 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4402 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4403 | pipeline_layout_ci.pNext = NULL; |
| 4404 | pipeline_layout_ci.setLayoutCount = 1; |
| 4405 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4406 | |
| 4407 | VkPipelineLayout pipeline_layout; |
| 4408 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4409 | &pipeline_layout); |
| 4410 | ASSERT_VK_SUCCESS(err); |
| 4411 | |
| 4412 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4413 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4414 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4415 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 4416 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4417 | // but add it to be able to run on more devices |
| 4418 | VkPipelineObj pipe(m_device); |
| 4419 | pipe.AddShader(&vs); |
| 4420 | pipe.AddShader(&fs); |
| 4421 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4422 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4423 | |
| 4424 | BeginCommandBuffer(); |
| 4425 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4426 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4427 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4428 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4429 | |
| 4430 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4431 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4432 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4433 | } |
Tony Barbour | 4e81a20 | 2016-04-04 11:09:40 -0600 | [diff] [blame] | 4434 | #endif //ADD_BACK_IN_WHEN_CHECK_IS_BACK |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4435 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 4436 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 4437 | // to issuing a Draw |
| 4438 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4439 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4440 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 4441 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4442 | "vkCmdClearAttachments() issued on CB object "); |
| 4443 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4444 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4445 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4446 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4447 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4448 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4449 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4450 | |
| 4451 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4452 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4453 | ds_pool_ci.pNext = NULL; |
| 4454 | ds_pool_ci.maxSets = 1; |
| 4455 | ds_pool_ci.poolSizeCount = 1; |
| 4456 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4457 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4458 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4459 | err = |
| 4460 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4461 | ASSERT_VK_SUCCESS(err); |
| 4462 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4463 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4464 | dsl_binding.binding = 0; |
| 4465 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4466 | dsl_binding.descriptorCount = 1; |
| 4467 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4468 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4469 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4470 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4471 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4472 | ds_layout_ci.pNext = NULL; |
| 4473 | ds_layout_ci.bindingCount = 1; |
| 4474 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4475 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4476 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4477 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4478 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4479 | ASSERT_VK_SUCCESS(err); |
| 4480 | |
| 4481 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4482 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4483 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4484 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4485 | alloc_info.descriptorPool = ds_pool; |
| 4486 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4487 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4488 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4489 | ASSERT_VK_SUCCESS(err); |
| 4490 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4491 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4492 | pipe_ms_state_ci.sType = |
| 4493 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4494 | pipe_ms_state_ci.pNext = NULL; |
| 4495 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 4496 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4497 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4498 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4499 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4500 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4501 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4502 | pipeline_layout_ci.pNext = NULL; |
| 4503 | pipeline_layout_ci.setLayoutCount = 1; |
| 4504 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4505 | |
| 4506 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4507 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4508 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4509 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4510 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4511 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4512 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 4513 | // 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] | 4514 | // on more devices |
| 4515 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4516 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4517 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4518 | VkPipelineObj pipe(m_device); |
| 4519 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4520 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4521 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4522 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4523 | |
| 4524 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4525 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4526 | // Main thing we care about for this test is that the VkImage obj we're |
| 4527 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4528 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4529 | VkClearAttachment color_attachment; |
| 4530 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4531 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 4532 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 4533 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 4534 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 4535 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4536 | VkClearRect clear_rect = { |
| 4537 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4538 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4539 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 4540 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4541 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4542 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4543 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4544 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4545 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4546 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4547 | } |
| 4548 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4549 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 4550 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4551 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4552 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4553 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 4554 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4555 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4556 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4557 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4558 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4559 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4560 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4561 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4562 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4563 | |
| 4564 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4565 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4566 | ds_pool_ci.pNext = NULL; |
| 4567 | ds_pool_ci.maxSets = 1; |
| 4568 | ds_pool_ci.poolSizeCount = 1; |
| 4569 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4570 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4571 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4572 | err = |
| 4573 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4574 | ASSERT_VK_SUCCESS(err); |
| 4575 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4576 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4577 | dsl_binding.binding = 0; |
| 4578 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4579 | dsl_binding.descriptorCount = 1; |
| 4580 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4581 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4582 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4583 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4584 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4585 | ds_layout_ci.pNext = NULL; |
| 4586 | ds_layout_ci.bindingCount = 1; |
| 4587 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4588 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4589 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4590 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4591 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4592 | ASSERT_VK_SUCCESS(err); |
| 4593 | |
| 4594 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4595 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4596 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4597 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4598 | alloc_info.descriptorPool = ds_pool; |
| 4599 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4600 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4601 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4602 | ASSERT_VK_SUCCESS(err); |
| 4603 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4604 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4605 | pipe_ms_state_ci.sType = |
| 4606 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4607 | pipe_ms_state_ci.pNext = NULL; |
| 4608 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 4609 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4610 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4611 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4612 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4613 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4614 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4615 | pipeline_layout_ci.pNext = NULL; |
| 4616 | pipeline_layout_ci.setLayoutCount = 1; |
| 4617 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4618 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4619 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4620 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4621 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4622 | ASSERT_VK_SUCCESS(err); |
| 4623 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4624 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4625 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4626 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4627 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 4628 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4629 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4630 | VkPipelineObj pipe(m_device); |
| 4631 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4632 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4633 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4634 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4635 | pipe.SetViewport(m_viewports); |
| 4636 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4637 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4638 | |
| 4639 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4640 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4641 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4642 | // Don't care about actual data, just need to get to draw to flag error |
| 4643 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4644 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 4645 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4646 | 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] | 4647 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4648 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4649 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4650 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4651 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4652 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4653 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4654 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4655 | #endif // DRAW_STATE_TESTS |
| 4656 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 4657 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4658 | #if GTEST_IS_THREADSAFE |
| 4659 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4660 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4661 | VkEvent event; |
| 4662 | bool bailout; |
| 4663 | }; |
| 4664 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4665 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 4666 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4667 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4668 | for (int i = 0; i < 10000; i++) { |
| 4669 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 4670 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4671 | if (data->bailout) { |
| 4672 | break; |
| 4673 | } |
| 4674 | } |
| 4675 | return NULL; |
| 4676 | } |
| 4677 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4678 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4679 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4680 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4681 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4682 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4683 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4684 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4685 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4686 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4687 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4688 | // Calls AllocateCommandBuffers |
| 4689 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4690 | |
| 4691 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4692 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4693 | |
| 4694 | VkEventCreateInfo event_info; |
| 4695 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4696 | VkResult err; |
| 4697 | |
| 4698 | memset(&event_info, 0, sizeof(event_info)); |
| 4699 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 4700 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4701 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4702 | ASSERT_VK_SUCCESS(err); |
| 4703 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4704 | err = vkResetEvent(device(), event); |
| 4705 | ASSERT_VK_SUCCESS(err); |
| 4706 | |
| 4707 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4708 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4709 | data.event = event; |
| 4710 | data.bailout = false; |
| 4711 | m_errorMonitor->SetBailout(&data.bailout); |
| 4712 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4713 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4714 | // Add many entries to command buffer from this thread at the same time. |
| 4715 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4716 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4717 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4718 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4719 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 4720 | m_errorMonitor->SetBailout(NULL); |
| 4721 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4722 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4723 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4724 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4725 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4726 | #endif // GTEST_IS_THREADSAFE |
| 4727 | #endif // THREADING_TESTS |
| 4728 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4729 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4730 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4731 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4732 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4733 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4734 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4735 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4736 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4737 | VkShaderModule module; |
| 4738 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4739 | struct icd_spv_header spv; |
| 4740 | |
| 4741 | spv.magic = ICD_SPV_MAGIC; |
| 4742 | spv.version = ICD_SPV_VERSION; |
| 4743 | spv.gen_magic = 0; |
| 4744 | |
| 4745 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4746 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4747 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4748 | moduleCreateInfo.codeSize = 4; |
| 4749 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4750 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4751 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4752 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4753 | } |
| 4754 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4755 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4756 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4757 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4758 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4759 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4760 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4761 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4762 | VkShaderModule module; |
| 4763 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4764 | struct icd_spv_header spv; |
| 4765 | |
| 4766 | spv.magic = ~ICD_SPV_MAGIC; |
| 4767 | spv.version = ICD_SPV_VERSION; |
| 4768 | spv.gen_magic = 0; |
| 4769 | |
| 4770 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4771 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4772 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4773 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4774 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4775 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4776 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4777 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4778 | } |
| 4779 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4780 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4781 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4782 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4783 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4784 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4785 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4786 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4787 | VkShaderModule module; |
| 4788 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4789 | struct icd_spv_header spv; |
| 4790 | |
| 4791 | spv.magic = ICD_SPV_MAGIC; |
| 4792 | spv.version = ~ICD_SPV_VERSION; |
| 4793 | spv.gen_magic = 0; |
| 4794 | |
| 4795 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4796 | moduleCreateInfo.pNext = NULL; |
| 4797 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4798 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4799 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4800 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4801 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4802 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4803 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4804 | } |
| 4805 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4806 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4807 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4808 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4809 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4810 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4811 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4812 | |
| 4813 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4814 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4815 | "\n" |
| 4816 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4817 | "out gl_PerVertex {\n" |
| 4818 | " vec4 gl_Position;\n" |
| 4819 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4820 | "void main(){\n" |
| 4821 | " gl_Position = vec4(1);\n" |
| 4822 | " x = 0;\n" |
| 4823 | "}\n"; |
| 4824 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4825 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4826 | "\n" |
| 4827 | "layout(location=0) out vec4 color;\n" |
| 4828 | "void main(){\n" |
| 4829 | " color = vec4(1);\n" |
| 4830 | "}\n"; |
| 4831 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4832 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4833 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4834 | |
| 4835 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4836 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4837 | pipe.AddShader(&vs); |
| 4838 | pipe.AddShader(&fs); |
| 4839 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4840 | VkDescriptorSetObj descriptorSet(m_device); |
| 4841 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4842 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4843 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4844 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4845 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4846 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4847 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4848 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4849 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4850 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4851 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4852 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4853 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4854 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4855 | |
| 4856 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4857 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4858 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4859 | "out gl_PerVertex {\n" |
| 4860 | " vec4 gl_Position;\n" |
| 4861 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4862 | "void main(){\n" |
| 4863 | " gl_Position = vec4(1);\n" |
| 4864 | "}\n"; |
| 4865 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4866 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4867 | "\n" |
| 4868 | "layout(location=0) in float x;\n" |
| 4869 | "layout(location=0) out vec4 color;\n" |
| 4870 | "void main(){\n" |
| 4871 | " color = vec4(x);\n" |
| 4872 | "}\n"; |
| 4873 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4874 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4875 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4876 | |
| 4877 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4878 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4879 | pipe.AddShader(&vs); |
| 4880 | pipe.AddShader(&fs); |
| 4881 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4882 | VkDescriptorSetObj descriptorSet(m_device); |
| 4883 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4884 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4885 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4886 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4887 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4888 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4889 | } |
| 4890 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4891 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 4892 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4893 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 4894 | |
| 4895 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4896 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4897 | |
| 4898 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4899 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 4900 | "\n" |
| 4901 | "out gl_PerVertex {\n" |
| 4902 | " vec4 gl_Position;\n" |
| 4903 | "};\n" |
| 4904 | "void main(){\n" |
| 4905 | " gl_Position = vec4(1);\n" |
| 4906 | "}\n"; |
| 4907 | char const *fsSource = |
| 4908 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 4909 | "\n" |
| 4910 | "in block { layout(location=0) float x; } ins;\n" |
| 4911 | "layout(location=0) out vec4 color;\n" |
| 4912 | "void main(){\n" |
| 4913 | " color = vec4(ins.x);\n" |
| 4914 | "}\n"; |
| 4915 | |
| 4916 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4917 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4918 | |
| 4919 | VkPipelineObj pipe(m_device); |
| 4920 | pipe.AddColorAttachment(); |
| 4921 | pipe.AddShader(&vs); |
| 4922 | pipe.AddShader(&fs); |
| 4923 | |
| 4924 | VkDescriptorSetObj descriptorSet(m_device); |
| 4925 | descriptorSet.AppendDummy(); |
| 4926 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 4927 | |
| 4928 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4929 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4930 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 4931 | } |
| 4932 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4933 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 4934 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 4935 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4936 | "output arr[2] of float32' vs 'ptr to " |
| 4937 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 4938 | |
| 4939 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4940 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4941 | |
| 4942 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4943 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 4944 | "\n" |
| 4945 | "layout(location=0) out float x[2];\n" |
| 4946 | "out gl_PerVertex {\n" |
| 4947 | " vec4 gl_Position;\n" |
| 4948 | "};\n" |
| 4949 | "void main(){\n" |
| 4950 | " x[0] = 0; x[1] = 0;\n" |
| 4951 | " gl_Position = vec4(1);\n" |
| 4952 | "}\n"; |
| 4953 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4954 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 4955 | "\n" |
| 4956 | "layout(location=0) in float x[3];\n" |
| 4957 | "layout(location=0) out vec4 color;\n" |
| 4958 | "void main(){\n" |
| 4959 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 4960 | "}\n"; |
| 4961 | |
| 4962 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4963 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4964 | |
| 4965 | VkPipelineObj pipe(m_device); |
| 4966 | pipe.AddColorAttachment(); |
| 4967 | pipe.AddShader(&vs); |
| 4968 | pipe.AddShader(&fs); |
| 4969 | |
| 4970 | VkDescriptorSetObj descriptorSet(m_device); |
| 4971 | descriptorSet.AppendDummy(); |
| 4972 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 4973 | |
| 4974 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4975 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4976 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 4977 | } |
| 4978 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4979 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4980 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4981 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4982 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4983 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4984 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4985 | |
| 4986 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4987 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4988 | "\n" |
| 4989 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4990 | "out gl_PerVertex {\n" |
| 4991 | " vec4 gl_Position;\n" |
| 4992 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4993 | "void main(){\n" |
| 4994 | " x = 0;\n" |
| 4995 | " gl_Position = vec4(1);\n" |
| 4996 | "}\n"; |
| 4997 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4998 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4999 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5000 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5001 | "layout(location=0) out vec4 color;\n" |
| 5002 | "void main(){\n" |
| 5003 | " color = vec4(x);\n" |
| 5004 | "}\n"; |
| 5005 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5006 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5007 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5008 | |
| 5009 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5010 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5011 | pipe.AddShader(&vs); |
| 5012 | pipe.AddShader(&fs); |
| 5013 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5014 | VkDescriptorSetObj descriptorSet(m_device); |
| 5015 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5016 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5017 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5018 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5019 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5020 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5021 | } |
| 5022 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5023 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5024 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5025 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5026 | |
| 5027 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5028 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5029 | |
| 5030 | char const *vsSource = |
| 5031 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5032 | "\n" |
| 5033 | "out block { layout(location=0) int x; } outs;\n" |
| 5034 | "out gl_PerVertex {\n" |
| 5035 | " vec4 gl_Position;\n" |
| 5036 | "};\n" |
| 5037 | "void main(){\n" |
| 5038 | " outs.x = 0;\n" |
| 5039 | " gl_Position = vec4(1);\n" |
| 5040 | "}\n"; |
| 5041 | char const *fsSource = |
| 5042 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5043 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5044 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5045 | "layout(location=0) out vec4 color;\n" |
| 5046 | "void main(){\n" |
| 5047 | " color = vec4(ins.x);\n" |
| 5048 | "}\n"; |
| 5049 | |
| 5050 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5051 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5052 | |
| 5053 | VkPipelineObj pipe(m_device); |
| 5054 | pipe.AddColorAttachment(); |
| 5055 | pipe.AddShader(&vs); |
| 5056 | pipe.AddShader(&fs); |
| 5057 | |
| 5058 | VkDescriptorSetObj descriptorSet(m_device); |
| 5059 | descriptorSet.AppendDummy(); |
| 5060 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5061 | |
| 5062 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5063 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5064 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5065 | } |
| 5066 | |
| 5067 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 5068 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5069 | "location 0.0 which is not written by vertex shader"); |
| 5070 | |
| 5071 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5072 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5073 | |
| 5074 | char const *vsSource = |
| 5075 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5076 | "\n" |
| 5077 | "out block { layout(location=1) float x; } outs;\n" |
| 5078 | "out gl_PerVertex {\n" |
| 5079 | " vec4 gl_Position;\n" |
| 5080 | "};\n" |
| 5081 | "void main(){\n" |
| 5082 | " outs.x = 0;\n" |
| 5083 | " gl_Position = vec4(1);\n" |
| 5084 | "}\n"; |
| 5085 | char const *fsSource = |
| 5086 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5087 | "\n" |
| 5088 | "in block { layout(location=0) float x; } ins;\n" |
| 5089 | "layout(location=0) out vec4 color;\n" |
| 5090 | "void main(){\n" |
| 5091 | " color = vec4(ins.x);\n" |
| 5092 | "}\n"; |
| 5093 | |
| 5094 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5095 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5096 | |
| 5097 | VkPipelineObj pipe(m_device); |
| 5098 | pipe.AddColorAttachment(); |
| 5099 | pipe.AddShader(&vs); |
| 5100 | pipe.AddShader(&fs); |
| 5101 | |
| 5102 | VkDescriptorSetObj descriptorSet(m_device); |
| 5103 | descriptorSet.AppendDummy(); |
| 5104 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5105 | |
| 5106 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5107 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5108 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5109 | } |
| 5110 | |
| 5111 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 5112 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5113 | "location 0.1 which is not written by vertex shader"); |
| 5114 | |
| 5115 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5116 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5117 | |
| 5118 | char const *vsSource = |
| 5119 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5120 | "\n" |
| 5121 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 5122 | "out gl_PerVertex {\n" |
| 5123 | " vec4 gl_Position;\n" |
| 5124 | "};\n" |
| 5125 | "void main(){\n" |
| 5126 | " outs.x = 0;\n" |
| 5127 | " gl_Position = vec4(1);\n" |
| 5128 | "}\n"; |
| 5129 | char const *fsSource = |
| 5130 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5131 | "\n" |
| 5132 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 5133 | "layout(location=0) out vec4 color;\n" |
| 5134 | "void main(){\n" |
| 5135 | " color = vec4(ins.x);\n" |
| 5136 | "}\n"; |
| 5137 | |
| 5138 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5139 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5140 | |
| 5141 | VkPipelineObj pipe(m_device); |
| 5142 | pipe.AddColorAttachment(); |
| 5143 | pipe.AddShader(&vs); |
| 5144 | pipe.AddShader(&fs); |
| 5145 | |
| 5146 | VkDescriptorSetObj descriptorSet(m_device); |
| 5147 | descriptorSet.AppendDummy(); |
| 5148 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5149 | |
| 5150 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5151 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5152 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5153 | } |
| 5154 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5155 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5156 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5157 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5158 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5159 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5160 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5161 | |
| 5162 | VkVertexInputBindingDescription input_binding; |
| 5163 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5164 | |
| 5165 | VkVertexInputAttributeDescription input_attrib; |
| 5166 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5167 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5168 | |
| 5169 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5170 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5171 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5172 | "out gl_PerVertex {\n" |
| 5173 | " vec4 gl_Position;\n" |
| 5174 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5175 | "void main(){\n" |
| 5176 | " gl_Position = vec4(1);\n" |
| 5177 | "}\n"; |
| 5178 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5179 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5180 | "\n" |
| 5181 | "layout(location=0) out vec4 color;\n" |
| 5182 | "void main(){\n" |
| 5183 | " color = vec4(1);\n" |
| 5184 | "}\n"; |
| 5185 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5186 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5187 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5188 | |
| 5189 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5190 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5191 | pipe.AddShader(&vs); |
| 5192 | pipe.AddShader(&fs); |
| 5193 | |
| 5194 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5195 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5196 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5197 | VkDescriptorSetObj descriptorSet(m_device); |
| 5198 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5199 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5200 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5201 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5202 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5203 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5204 | } |
| 5205 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5206 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5207 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5208 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5209 | |
| 5210 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5211 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5212 | |
| 5213 | VkVertexInputBindingDescription input_binding; |
| 5214 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5215 | |
| 5216 | VkVertexInputAttributeDescription input_attrib; |
| 5217 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5218 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5219 | |
| 5220 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5221 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5222 | "\n" |
| 5223 | "layout(location=1) in float x;\n" |
| 5224 | "out gl_PerVertex {\n" |
| 5225 | " vec4 gl_Position;\n" |
| 5226 | "};\n" |
| 5227 | "void main(){\n" |
| 5228 | " gl_Position = vec4(x);\n" |
| 5229 | "}\n"; |
| 5230 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5231 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5232 | "\n" |
| 5233 | "layout(location=0) out vec4 color;\n" |
| 5234 | "void main(){\n" |
| 5235 | " color = vec4(1);\n" |
| 5236 | "}\n"; |
| 5237 | |
| 5238 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5239 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5240 | |
| 5241 | VkPipelineObj pipe(m_device); |
| 5242 | pipe.AddColorAttachment(); |
| 5243 | pipe.AddShader(&vs); |
| 5244 | pipe.AddShader(&fs); |
| 5245 | |
| 5246 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5247 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5248 | |
| 5249 | VkDescriptorSetObj descriptorSet(m_device); |
| 5250 | descriptorSet.AppendDummy(); |
| 5251 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5252 | |
| 5253 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5254 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5255 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5256 | } |
| 5257 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5258 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 5259 | m_errorMonitor->SetDesiredFailureMsg( |
| 5260 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5261 | "VS consumes input at location 0 but not provided"); |
| 5262 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5263 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5264 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5265 | |
| 5266 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5267 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5268 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5269 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5270 | "out gl_PerVertex {\n" |
| 5271 | " vec4 gl_Position;\n" |
| 5272 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5273 | "void main(){\n" |
| 5274 | " gl_Position = x;\n" |
| 5275 | "}\n"; |
| 5276 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5277 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5278 | "\n" |
| 5279 | "layout(location=0) out vec4 color;\n" |
| 5280 | "void main(){\n" |
| 5281 | " color = vec4(1);\n" |
| 5282 | "}\n"; |
| 5283 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5284 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5285 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5286 | |
| 5287 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5288 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5289 | pipe.AddShader(&vs); |
| 5290 | pipe.AddShader(&fs); |
| 5291 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5292 | VkDescriptorSetObj descriptorSet(m_device); |
| 5293 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5294 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5295 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5296 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5297 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5298 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5299 | } |
| 5300 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5301 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 5302 | m_errorMonitor->SetDesiredFailureMsg( |
| 5303 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5304 | "location 0 does not match VS input type"); |
| 5305 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5306 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5307 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5308 | |
| 5309 | VkVertexInputBindingDescription input_binding; |
| 5310 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5311 | |
| 5312 | VkVertexInputAttributeDescription input_attrib; |
| 5313 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5314 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5315 | |
| 5316 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5317 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5318 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5319 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5320 | "out gl_PerVertex {\n" |
| 5321 | " vec4 gl_Position;\n" |
| 5322 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5323 | "void main(){\n" |
| 5324 | " gl_Position = vec4(x);\n" |
| 5325 | "}\n"; |
| 5326 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5327 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5328 | "\n" |
| 5329 | "layout(location=0) out vec4 color;\n" |
| 5330 | "void main(){\n" |
| 5331 | " color = vec4(1);\n" |
| 5332 | "}\n"; |
| 5333 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5334 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5335 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5336 | |
| 5337 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5338 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5339 | pipe.AddShader(&vs); |
| 5340 | pipe.AddShader(&fs); |
| 5341 | |
| 5342 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5343 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5344 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5345 | VkDescriptorSetObj descriptorSet(m_device); |
| 5346 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5347 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5348 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5349 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5350 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5351 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5352 | } |
| 5353 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 5354 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 5355 | m_errorMonitor->SetDesiredFailureMsg( |
| 5356 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5357 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 5358 | |
| 5359 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5360 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5361 | |
| 5362 | char const *vsSource = |
| 5363 | "#version 450\n" |
| 5364 | "\n" |
| 5365 | "out gl_PerVertex {\n" |
| 5366 | " vec4 gl_Position;\n" |
| 5367 | "};\n" |
| 5368 | "void main(){\n" |
| 5369 | " gl_Position = vec4(1);\n" |
| 5370 | "}\n"; |
| 5371 | char const *fsSource = |
| 5372 | "#version 450\n" |
| 5373 | "\n" |
| 5374 | "layout(location=0) out vec4 color;\n" |
| 5375 | "void main(){\n" |
| 5376 | " color = vec4(1);\n" |
| 5377 | "}\n"; |
| 5378 | |
| 5379 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5380 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5381 | |
| 5382 | VkPipelineObj pipe(m_device); |
| 5383 | pipe.AddColorAttachment(); |
| 5384 | pipe.AddShader(&vs); |
| 5385 | pipe.AddShader(&vs); |
| 5386 | pipe.AddShader(&fs); |
| 5387 | |
| 5388 | VkDescriptorSetObj descriptorSet(m_device); |
| 5389 | descriptorSet.AppendDummy(); |
| 5390 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5391 | |
| 5392 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5393 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5394 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 5395 | } |
| 5396 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5397 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5398 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5399 | |
| 5400 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5401 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5402 | |
| 5403 | VkVertexInputBindingDescription input_binding; |
| 5404 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5405 | |
| 5406 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5407 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5408 | |
| 5409 | for (int i = 0; i < 2; i++) { |
| 5410 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5411 | input_attribs[i].location = i; |
| 5412 | } |
| 5413 | |
| 5414 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5415 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5416 | "\n" |
| 5417 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5418 | "out gl_PerVertex {\n" |
| 5419 | " vec4 gl_Position;\n" |
| 5420 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5421 | "void main(){\n" |
| 5422 | " gl_Position = x[0] + x[1];\n" |
| 5423 | "}\n"; |
| 5424 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5425 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5426 | "\n" |
| 5427 | "layout(location=0) out vec4 color;\n" |
| 5428 | "void main(){\n" |
| 5429 | " color = vec4(1);\n" |
| 5430 | "}\n"; |
| 5431 | |
| 5432 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5433 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5434 | |
| 5435 | VkPipelineObj pipe(m_device); |
| 5436 | pipe.AddColorAttachment(); |
| 5437 | pipe.AddShader(&vs); |
| 5438 | pipe.AddShader(&fs); |
| 5439 | |
| 5440 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5441 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5442 | |
| 5443 | VkDescriptorSetObj descriptorSet(m_device); |
| 5444 | descriptorSet.AppendDummy(); |
| 5445 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5446 | |
| 5447 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5448 | |
| 5449 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5450 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5451 | } |
| 5452 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5453 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 5454 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5455 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5456 | |
| 5457 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5458 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5459 | |
| 5460 | VkVertexInputBindingDescription input_binding; |
| 5461 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5462 | |
| 5463 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5464 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5465 | |
| 5466 | for (int i = 0; i < 2; i++) { |
| 5467 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5468 | input_attribs[i].location = i; |
| 5469 | } |
| 5470 | |
| 5471 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5472 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5473 | "\n" |
| 5474 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5475 | "out gl_PerVertex {\n" |
| 5476 | " vec4 gl_Position;\n" |
| 5477 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5478 | "void main(){\n" |
| 5479 | " gl_Position = x[0] + x[1];\n" |
| 5480 | "}\n"; |
| 5481 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5482 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5483 | "\n" |
| 5484 | "layout(location=0) out vec4 color;\n" |
| 5485 | "void main(){\n" |
| 5486 | " color = vec4(1);\n" |
| 5487 | "}\n"; |
| 5488 | |
| 5489 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5490 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5491 | |
| 5492 | VkPipelineObj pipe(m_device); |
| 5493 | pipe.AddColorAttachment(); |
| 5494 | pipe.AddShader(&vs); |
| 5495 | pipe.AddShader(&fs); |
| 5496 | |
| 5497 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5498 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5499 | |
| 5500 | VkDescriptorSetObj descriptorSet(m_device); |
| 5501 | descriptorSet.AppendDummy(); |
| 5502 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5503 | |
| 5504 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5505 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5506 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5507 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5508 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5509 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 5510 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5511 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5512 | |
| 5513 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5514 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5515 | |
| 5516 | char const *vsSource = |
| 5517 | "#version 450\n" |
| 5518 | "out gl_PerVertex {\n" |
| 5519 | " vec4 gl_Position;\n" |
| 5520 | "};\n" |
| 5521 | "void main(){\n" |
| 5522 | " gl_Position = vec4(0);\n" |
| 5523 | "}\n"; |
| 5524 | char const *fsSource = |
| 5525 | "#version 450\n" |
| 5526 | "\n" |
| 5527 | "layout(location=0) out vec4 color;\n" |
| 5528 | "void main(){\n" |
| 5529 | " color = vec4(1);\n" |
| 5530 | "}\n"; |
| 5531 | |
| 5532 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5533 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5534 | |
| 5535 | VkPipelineObj pipe(m_device); |
| 5536 | pipe.AddColorAttachment(); |
| 5537 | pipe.AddShader(&vs); |
| 5538 | pipe.AddShader(&fs); |
| 5539 | |
| 5540 | VkDescriptorSetObj descriptorSet(m_device); |
| 5541 | descriptorSet.AppendDummy(); |
| 5542 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5543 | |
| 5544 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5545 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5546 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5547 | } |
| 5548 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 5549 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 5550 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5551 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 5552 | |
| 5553 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 5554 | |
| 5555 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5556 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5557 | |
| 5558 | char const *vsSource = |
| 5559 | "#version 450\n" |
| 5560 | "out gl_PerVertex {\n" |
| 5561 | " vec4 gl_Position;\n" |
| 5562 | "};\n" |
| 5563 | "layout(location=0) out vec3 x;\n" |
| 5564 | "layout(location=1) out ivec3 y;\n" |
| 5565 | "layout(location=2) out vec3 z;\n" |
| 5566 | "void main(){\n" |
| 5567 | " gl_Position = vec4(0);\n" |
| 5568 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 5569 | "}\n"; |
| 5570 | char const *fsSource = |
| 5571 | "#version 450\n" |
| 5572 | "\n" |
| 5573 | "layout(location=0) out vec4 color;\n" |
| 5574 | "layout(location=0) in float x;\n" |
| 5575 | "layout(location=1) flat in int y;\n" |
| 5576 | "layout(location=2) in vec2 z;\n" |
| 5577 | "void main(){\n" |
| 5578 | " color = vec4(1 + x + y + z.x);\n" |
| 5579 | "}\n"; |
| 5580 | |
| 5581 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5582 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5583 | |
| 5584 | VkPipelineObj pipe(m_device); |
| 5585 | pipe.AddColorAttachment(); |
| 5586 | pipe.AddShader(&vs); |
| 5587 | pipe.AddShader(&fs); |
| 5588 | |
| 5589 | VkDescriptorSetObj descriptorSet(m_device); |
| 5590 | descriptorSet.AppendDummy(); |
| 5591 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5592 | |
| 5593 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5594 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5595 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 5596 | } |
| 5597 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5598 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 5599 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5600 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5601 | |
| 5602 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5603 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5604 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 5605 | if (!m_device->phy().features().tessellationShader) { |
| 5606 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 5607 | return; |
| 5608 | } |
| 5609 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5610 | char const *vsSource = |
| 5611 | "#version 450\n" |
| 5612 | "void main(){}\n"; |
| 5613 | char const *tcsSource = |
| 5614 | "#version 450\n" |
| 5615 | "layout(location=0) out int x[];\n" |
| 5616 | "layout(vertices=3) out;\n" |
| 5617 | "void main(){\n" |
| 5618 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 5619 | " gl_TessLevelInner[0] = 1;\n" |
| 5620 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 5621 | "}\n"; |
| 5622 | char const *tesSource = |
| 5623 | "#version 450\n" |
| 5624 | "layout(triangles, equal_spacing, cw) in;\n" |
| 5625 | "layout(location=0) in int x[];\n" |
| 5626 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 5627 | "void main(){\n" |
| 5628 | " gl_Position.xyz = gl_TessCoord;\n" |
| 5629 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 5630 | "}\n"; |
| 5631 | char const *fsSource = |
| 5632 | "#version 450\n" |
| 5633 | "layout(location=0) out vec4 color;\n" |
| 5634 | "void main(){\n" |
| 5635 | " color = vec4(1);\n" |
| 5636 | "}\n"; |
| 5637 | |
| 5638 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5639 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 5640 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 5641 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5642 | |
| 5643 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 5644 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 5645 | nullptr, |
| 5646 | 0, |
| 5647 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 5648 | VK_FALSE}; |
| 5649 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 5650 | VkPipelineTessellationStateCreateInfo tsci{ |
| 5651 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 5652 | nullptr, |
| 5653 | 0, |
| 5654 | 3}; |
| 5655 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5656 | VkPipelineObj pipe(m_device); |
| 5657 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 5658 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5659 | pipe.AddColorAttachment(); |
| 5660 | pipe.AddShader(&vs); |
| 5661 | pipe.AddShader(&tcs); |
| 5662 | pipe.AddShader(&tes); |
| 5663 | pipe.AddShader(&fs); |
| 5664 | |
| 5665 | VkDescriptorSetObj descriptorSet(m_device); |
| 5666 | descriptorSet.AppendDummy(); |
| 5667 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5668 | |
| 5669 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5670 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5671 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5672 | } |
| 5673 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 5674 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 5675 | { |
| 5676 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5677 | "is per-vertex in tessellation control shader stage " |
| 5678 | "but per-patch in tessellation evaluation shader stage"); |
| 5679 | |
| 5680 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5681 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5682 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 5683 | if (!m_device->phy().features().tessellationShader) { |
| 5684 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 5685 | return; |
| 5686 | } |
| 5687 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 5688 | char const *vsSource = |
| 5689 | "#version 450\n" |
| 5690 | "void main(){}\n"; |
| 5691 | char const *tcsSource = |
| 5692 | "#version 450\n" |
| 5693 | "layout(location=0) out int x[];\n" |
| 5694 | "layout(vertices=3) out;\n" |
| 5695 | "void main(){\n" |
| 5696 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 5697 | " gl_TessLevelInner[0] = 1;\n" |
| 5698 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 5699 | "}\n"; |
| 5700 | char const *tesSource = |
| 5701 | "#version 450\n" |
| 5702 | "layout(triangles, equal_spacing, cw) in;\n" |
| 5703 | "layout(location=0) patch in int x;\n" |
| 5704 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 5705 | "void main(){\n" |
| 5706 | " gl_Position.xyz = gl_TessCoord;\n" |
| 5707 | " gl_Position.w = x;\n" |
| 5708 | "}\n"; |
| 5709 | char const *fsSource = |
| 5710 | "#version 450\n" |
| 5711 | "layout(location=0) out vec4 color;\n" |
| 5712 | "void main(){\n" |
| 5713 | " color = vec4(1);\n" |
| 5714 | "}\n"; |
| 5715 | |
| 5716 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5717 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 5718 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 5719 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5720 | |
| 5721 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 5722 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 5723 | nullptr, |
| 5724 | 0, |
| 5725 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 5726 | VK_FALSE}; |
| 5727 | |
| 5728 | VkPipelineTessellationStateCreateInfo tsci{ |
| 5729 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 5730 | nullptr, |
| 5731 | 0, |
| 5732 | 3}; |
| 5733 | |
| 5734 | VkPipelineObj pipe(m_device); |
| 5735 | pipe.SetInputAssembly(&iasci); |
| 5736 | pipe.SetTessellation(&tsci); |
| 5737 | pipe.AddColorAttachment(); |
| 5738 | pipe.AddShader(&vs); |
| 5739 | pipe.AddShader(&tcs); |
| 5740 | pipe.AddShader(&tes); |
| 5741 | pipe.AddShader(&fs); |
| 5742 | |
| 5743 | VkDescriptorSetObj descriptorSet(m_device); |
| 5744 | descriptorSet.AppendDummy(); |
| 5745 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5746 | |
| 5747 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5748 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5749 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 5750 | } |
| 5751 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5752 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 5753 | m_errorMonitor->SetDesiredFailureMsg( |
| 5754 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5755 | "Duplicate vertex input binding descriptions for binding 0"); |
| 5756 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5757 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5758 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5759 | |
| 5760 | /* Two binding descriptions for binding 0 */ |
| 5761 | VkVertexInputBindingDescription input_bindings[2]; |
| 5762 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 5763 | |
| 5764 | VkVertexInputAttributeDescription input_attrib; |
| 5765 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5766 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5767 | |
| 5768 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5769 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5770 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5771 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5772 | "out gl_PerVertex {\n" |
| 5773 | " vec4 gl_Position;\n" |
| 5774 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5775 | "void main(){\n" |
| 5776 | " gl_Position = vec4(x);\n" |
| 5777 | "}\n"; |
| 5778 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5779 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5780 | "\n" |
| 5781 | "layout(location=0) out vec4 color;\n" |
| 5782 | "void main(){\n" |
| 5783 | " color = vec4(1);\n" |
| 5784 | "}\n"; |
| 5785 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5786 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5787 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5788 | |
| 5789 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5790 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5791 | pipe.AddShader(&vs); |
| 5792 | pipe.AddShader(&fs); |
| 5793 | |
| 5794 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 5795 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5796 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5797 | VkDescriptorSetObj descriptorSet(m_device); |
| 5798 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5799 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5800 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5801 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5802 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5803 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5804 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 5805 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5806 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5807 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5808 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5809 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5810 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5811 | |
| 5812 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5813 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5814 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5815 | "out gl_PerVertex {\n" |
| 5816 | " vec4 gl_Position;\n" |
| 5817 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5818 | "void main(){\n" |
| 5819 | " gl_Position = vec4(1);\n" |
| 5820 | "}\n"; |
| 5821 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5822 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5823 | "\n" |
| 5824 | "void main(){\n" |
| 5825 | "}\n"; |
| 5826 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5827 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5828 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5829 | |
| 5830 | VkPipelineObj pipe(m_device); |
| 5831 | pipe.AddShader(&vs); |
| 5832 | pipe.AddShader(&fs); |
| 5833 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5834 | /* set up CB 0, not written */ |
| 5835 | pipe.AddColorAttachment(); |
| 5836 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5837 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5838 | VkDescriptorSetObj descriptorSet(m_device); |
| 5839 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5840 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5841 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5842 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5843 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5844 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5845 | } |
| 5846 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5847 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5848 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5849 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5850 | "FS writes to output location 1 with no matching attachment"); |
| 5851 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5852 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5853 | |
| 5854 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5855 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5856 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5857 | "out gl_PerVertex {\n" |
| 5858 | " vec4 gl_Position;\n" |
| 5859 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5860 | "void main(){\n" |
| 5861 | " gl_Position = vec4(1);\n" |
| 5862 | "}\n"; |
| 5863 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5864 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5865 | "\n" |
| 5866 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5867 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5868 | "void main(){\n" |
| 5869 | " x = vec4(1);\n" |
| 5870 | " y = vec4(1);\n" |
| 5871 | "}\n"; |
| 5872 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5873 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5874 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5875 | |
| 5876 | VkPipelineObj pipe(m_device); |
| 5877 | pipe.AddShader(&vs); |
| 5878 | pipe.AddShader(&fs); |
| 5879 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5880 | /* set up CB 0, not written */ |
| 5881 | pipe.AddColorAttachment(); |
| 5882 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5883 | /* FS writes CB 1, but we don't configure it */ |
| 5884 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5885 | VkDescriptorSetObj descriptorSet(m_device); |
| 5886 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5887 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5888 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5889 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5890 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5891 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5892 | } |
| 5893 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5894 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5895 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5896 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5897 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5898 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5899 | |
| 5900 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5901 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5902 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5903 | "out gl_PerVertex {\n" |
| 5904 | " vec4 gl_Position;\n" |
| 5905 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5906 | "void main(){\n" |
| 5907 | " gl_Position = vec4(1);\n" |
| 5908 | "}\n"; |
| 5909 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5910 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5911 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5912 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5913 | "void main(){\n" |
| 5914 | " x = ivec4(1);\n" |
| 5915 | "}\n"; |
| 5916 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5917 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5918 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5919 | |
| 5920 | VkPipelineObj pipe(m_device); |
| 5921 | pipe.AddShader(&vs); |
| 5922 | pipe.AddShader(&fs); |
| 5923 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5924 | /* set up CB 0; type is UNORM by default */ |
| 5925 | pipe.AddColorAttachment(); |
| 5926 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5927 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5928 | VkDescriptorSetObj descriptorSet(m_device); |
| 5929 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5930 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5931 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5932 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5933 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5934 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5935 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 5936 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5937 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5938 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5939 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5940 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5941 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5942 | |
| 5943 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5944 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5945 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5946 | "out gl_PerVertex {\n" |
| 5947 | " vec4 gl_Position;\n" |
| 5948 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5949 | "void main(){\n" |
| 5950 | " gl_Position = vec4(1);\n" |
| 5951 | "}\n"; |
| 5952 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5953 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5954 | "\n" |
| 5955 | "layout(location=0) out vec4 x;\n" |
| 5956 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5957 | "void main(){\n" |
| 5958 | " x = vec4(bar.y);\n" |
| 5959 | "}\n"; |
| 5960 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5961 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5962 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5963 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5964 | VkPipelineObj pipe(m_device); |
| 5965 | pipe.AddShader(&vs); |
| 5966 | pipe.AddShader(&fs); |
| 5967 | |
| 5968 | /* set up CB 0; type is UNORM by default */ |
| 5969 | pipe.AddColorAttachment(); |
| 5970 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5971 | |
| 5972 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5973 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5974 | |
| 5975 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5976 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5977 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5978 | } |
| 5979 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 5980 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 5981 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5982 | "not declared in layout"); |
| 5983 | |
| 5984 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5985 | |
| 5986 | char const *vsSource = |
| 5987 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 5988 | "\n" |
| 5989 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 5990 | "out gl_PerVertex {\n" |
| 5991 | " vec4 gl_Position;\n" |
| 5992 | "};\n" |
| 5993 | "void main(){\n" |
| 5994 | " gl_Position = vec4(consts.x);\n" |
| 5995 | "}\n"; |
| 5996 | char const *fsSource = |
| 5997 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 5998 | "\n" |
| 5999 | "layout(location=0) out vec4 x;\n" |
| 6000 | "void main(){\n" |
| 6001 | " x = vec4(1);\n" |
| 6002 | "}\n"; |
| 6003 | |
| 6004 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6005 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6006 | |
| 6007 | VkPipelineObj pipe(m_device); |
| 6008 | pipe.AddShader(&vs); |
| 6009 | pipe.AddShader(&fs); |
| 6010 | |
| 6011 | /* set up CB 0; type is UNORM by default */ |
| 6012 | pipe.AddColorAttachment(); |
| 6013 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6014 | |
| 6015 | VkDescriptorSetObj descriptorSet(m_device); |
| 6016 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6017 | |
| 6018 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6019 | |
| 6020 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6021 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 6022 | } |
| 6023 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6024 | #endif // SHADER_CHECKER_TESTS |
| 6025 | |
| 6026 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 6027 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6028 | m_errorMonitor->SetDesiredFailureMsg( |
| 6029 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6030 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6031 | |
| 6032 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6033 | |
| 6034 | // Create an image |
| 6035 | VkImage image; |
| 6036 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6037 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6038 | const int32_t tex_width = 32; |
| 6039 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6040 | |
| 6041 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6042 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6043 | image_create_info.pNext = NULL; |
| 6044 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6045 | image_create_info.format = tex_format; |
| 6046 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6047 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6048 | image_create_info.extent.depth = 1; |
| 6049 | image_create_info.mipLevels = 1; |
| 6050 | image_create_info.arrayLayers = 1; |
| 6051 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6052 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6053 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6054 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6055 | |
| 6056 | // Introduce error by sending down a bogus width extent |
| 6057 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6058 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6059 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6060 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6061 | } |
| 6062 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 6063 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 6064 | m_errorMonitor->SetDesiredFailureMsg( |
| 6065 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6066 | "CreateImage extents is 0 for at least one required dimension"); |
| 6067 | |
| 6068 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6069 | |
| 6070 | // Create an image |
| 6071 | VkImage image; |
| 6072 | |
| 6073 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6074 | const int32_t tex_width = 32; |
| 6075 | const int32_t tex_height = 32; |
| 6076 | |
| 6077 | VkImageCreateInfo image_create_info = {}; |
| 6078 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6079 | image_create_info.pNext = NULL; |
| 6080 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6081 | image_create_info.format = tex_format; |
| 6082 | image_create_info.extent.width = tex_width; |
| 6083 | image_create_info.extent.height = tex_height; |
| 6084 | image_create_info.extent.depth = 1; |
| 6085 | image_create_info.mipLevels = 1; |
| 6086 | image_create_info.arrayLayers = 1; |
| 6087 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6088 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6089 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6090 | image_create_info.flags = 0; |
| 6091 | |
| 6092 | // Introduce error by sending down a bogus width extent |
| 6093 | image_create_info.extent.width = 0; |
| 6094 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 6095 | |
| 6096 | m_errorMonitor->VerifyFound(); |
| 6097 | } |
| 6098 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6099 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 6100 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6101 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6102 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6103 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6104 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6105 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6106 | |
| 6107 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6108 | vk_testing::Buffer buffer; |
| 6109 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 6110 | |
| 6111 | BeginCommandBuffer(); |
| 6112 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6113 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6114 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6115 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6116 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6117 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6118 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6119 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6120 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6121 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6122 | EndCommandBuffer(); |
| 6123 | } |
| 6124 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6125 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6126 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6127 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6128 | |
| 6129 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6130 | |
| 6131 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6132 | vk_testing::Buffer buffer; |
| 6133 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 6134 | |
| 6135 | BeginCommandBuffer(); |
| 6136 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6137 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6138 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6139 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6140 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6141 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6142 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6143 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6144 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6145 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6146 | m_errorMonitor->VerifyFound(); |
| 6147 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6148 | EndCommandBuffer(); |
| 6149 | } |
| 6150 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6151 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6152 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6153 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6154 | TEST_F(VkLayerTest, InvalidImageView) { |
| 6155 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6157 | m_errorMonitor->SetDesiredFailureMsg( |
| 6158 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6159 | "vkCreateImageView called with baseMipLevel 10 "); |
| 6160 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6161 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6162 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6163 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6164 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6165 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6166 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6167 | const int32_t tex_width = 32; |
| 6168 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6169 | |
| 6170 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6171 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6172 | image_create_info.pNext = NULL; |
| 6173 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6174 | image_create_info.format = tex_format; |
| 6175 | image_create_info.extent.width = tex_width; |
| 6176 | image_create_info.extent.height = tex_height; |
| 6177 | image_create_info.extent.depth = 1; |
| 6178 | image_create_info.mipLevels = 1; |
| 6179 | image_create_info.arrayLayers = 1; |
| 6180 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6181 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6182 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6183 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6184 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6185 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6186 | ASSERT_VK_SUCCESS(err); |
| 6187 | |
| 6188 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6189 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6190 | image_view_create_info.image = image; |
| 6191 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6192 | image_view_create_info.format = tex_format; |
| 6193 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6194 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 6195 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6196 | image_view_create_info.subresourceRange.aspectMask = |
| 6197 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6198 | |
| 6199 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6200 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6201 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6202 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6203 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6204 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6205 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6206 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 6207 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6208 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6209 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6210 | "vkCreateImageView: Color image " |
| 6211 | "formats must have ONLY the " |
| 6212 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6213 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6214 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6215 | |
| 6216 | // Create an image and try to create a view with an invalid aspectMask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6217 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6218 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6219 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6220 | const int32_t tex_width = 32; |
| 6221 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6222 | |
| 6223 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6224 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6225 | image_create_info.pNext = NULL; |
| 6226 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6227 | image_create_info.format = tex_format; |
| 6228 | image_create_info.extent.width = tex_width; |
| 6229 | image_create_info.extent.height = tex_height; |
| 6230 | image_create_info.extent.depth = 1; |
| 6231 | image_create_info.mipLevels = 1; |
| 6232 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6233 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6234 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6235 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6236 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6237 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6238 | ASSERT_VK_SUCCESS(err); |
| 6239 | |
| 6240 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6241 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6242 | image_view_create_info.image = image; |
| 6243 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6244 | image_view_create_info.format = tex_format; |
| 6245 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 6246 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6247 | // Cause an error by setting an invalid image aspect |
| 6248 | image_view_create_info.subresourceRange.aspectMask = |
| 6249 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6250 | |
| 6251 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6252 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6253 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6254 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6255 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6256 | } |
| 6257 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6258 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6259 | VkResult err; |
| 6260 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6261 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6262 | m_errorMonitor->SetDesiredFailureMsg( |
| 6263 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6264 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6265 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6266 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6267 | |
| 6268 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6269 | VkImage srcImage; |
| 6270 | VkImage dstImage; |
| 6271 | VkDeviceMemory srcMem; |
| 6272 | VkDeviceMemory destMem; |
| 6273 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6274 | |
| 6275 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6276 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6277 | image_create_info.pNext = NULL; |
| 6278 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6279 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6280 | image_create_info.extent.width = 32; |
| 6281 | image_create_info.extent.height = 32; |
| 6282 | image_create_info.extent.depth = 1; |
| 6283 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6284 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6285 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6286 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6287 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6288 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6289 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6290 | err = |
| 6291 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6292 | ASSERT_VK_SUCCESS(err); |
| 6293 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6294 | err = |
| 6295 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6296 | ASSERT_VK_SUCCESS(err); |
| 6297 | |
| 6298 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6299 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6300 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6301 | memAlloc.pNext = NULL; |
| 6302 | memAlloc.allocationSize = 0; |
| 6303 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6304 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6305 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6306 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6307 | pass = |
| 6308 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6309 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6310 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6311 | ASSERT_VK_SUCCESS(err); |
| 6312 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6313 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6314 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6315 | pass = |
| 6316 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6317 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6318 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6319 | ASSERT_VK_SUCCESS(err); |
| 6320 | |
| 6321 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6322 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6323 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6324 | ASSERT_VK_SUCCESS(err); |
| 6325 | |
| 6326 | BeginCommandBuffer(); |
| 6327 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6328 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6329 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6330 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6331 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6332 | copyRegion.srcOffset.x = 0; |
| 6333 | copyRegion.srcOffset.y = 0; |
| 6334 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6335 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6336 | copyRegion.dstSubresource.mipLevel = 0; |
| 6337 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6338 | // Introduce failure by forcing the dst layerCount to differ from src |
| 6339 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6340 | copyRegion.dstOffset.x = 0; |
| 6341 | copyRegion.dstOffset.y = 0; |
| 6342 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6343 | copyRegion.extent.width = 1; |
| 6344 | copyRegion.extent.height = 1; |
| 6345 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6346 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6347 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6348 | EndCommandBuffer(); |
| 6349 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6350 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6351 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6352 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6353 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6354 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6355 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6356 | } |
| 6357 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6358 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 6359 | VkResult err; |
| 6360 | bool pass; |
| 6361 | |
| 6362 | // Create color images with different format sizes and try to copy between them |
| 6363 | m_errorMonitor->SetDesiredFailureMsg( |
| 6364 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6365 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 6366 | |
| 6367 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6368 | |
| 6369 | // Create two images of different types and try to copy between them |
| 6370 | VkImage srcImage; |
| 6371 | VkImage dstImage; |
| 6372 | VkDeviceMemory srcMem; |
| 6373 | VkDeviceMemory destMem; |
| 6374 | VkMemoryRequirements memReqs; |
| 6375 | |
| 6376 | VkImageCreateInfo image_create_info = {}; |
| 6377 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6378 | image_create_info.pNext = NULL; |
| 6379 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6380 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6381 | image_create_info.extent.width = 32; |
| 6382 | image_create_info.extent.height = 32; |
| 6383 | image_create_info.extent.depth = 1; |
| 6384 | image_create_info.mipLevels = 1; |
| 6385 | image_create_info.arrayLayers = 1; |
| 6386 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6387 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6388 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6389 | image_create_info.flags = 0; |
| 6390 | |
| 6391 | err = |
| 6392 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 6393 | ASSERT_VK_SUCCESS(err); |
| 6394 | |
| 6395 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 6396 | // Introduce failure by creating second image with a different-sized format. |
| 6397 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 6398 | |
| 6399 | err = |
| 6400 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 6401 | ASSERT_VK_SUCCESS(err); |
| 6402 | |
| 6403 | // Allocate memory |
| 6404 | VkMemoryAllocateInfo memAlloc = {}; |
| 6405 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6406 | memAlloc.pNext = NULL; |
| 6407 | memAlloc.allocationSize = 0; |
| 6408 | memAlloc.memoryTypeIndex = 0; |
| 6409 | |
| 6410 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 6411 | memAlloc.allocationSize = memReqs.size; |
| 6412 | pass = |
| 6413 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 6414 | ASSERT_TRUE(pass); |
| 6415 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 6416 | ASSERT_VK_SUCCESS(err); |
| 6417 | |
| 6418 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 6419 | memAlloc.allocationSize = memReqs.size; |
| 6420 | pass = |
| 6421 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 6422 | ASSERT_TRUE(pass); |
| 6423 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 6424 | ASSERT_VK_SUCCESS(err); |
| 6425 | |
| 6426 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6427 | ASSERT_VK_SUCCESS(err); |
| 6428 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 6429 | ASSERT_VK_SUCCESS(err); |
| 6430 | |
| 6431 | BeginCommandBuffer(); |
| 6432 | VkImageCopy copyRegion; |
| 6433 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6434 | copyRegion.srcSubresource.mipLevel = 0; |
| 6435 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 6436 | copyRegion.srcSubresource.layerCount = 0; |
| 6437 | copyRegion.srcOffset.x = 0; |
| 6438 | copyRegion.srcOffset.y = 0; |
| 6439 | copyRegion.srcOffset.z = 0; |
| 6440 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6441 | copyRegion.dstSubresource.mipLevel = 0; |
| 6442 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6443 | copyRegion.dstSubresource.layerCount = 0; |
| 6444 | copyRegion.dstOffset.x = 0; |
| 6445 | copyRegion.dstOffset.y = 0; |
| 6446 | copyRegion.dstOffset.z = 0; |
| 6447 | copyRegion.extent.width = 1; |
| 6448 | copyRegion.extent.height = 1; |
| 6449 | copyRegion.extent.depth = 1; |
| 6450 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6451 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6452 | EndCommandBuffer(); |
| 6453 | |
| 6454 | m_errorMonitor->VerifyFound(); |
| 6455 | |
| 6456 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 6457 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 6458 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6459 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6460 | } |
| 6461 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6462 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 6463 | VkResult err; |
| 6464 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6465 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6466 | // 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] | 6467 | m_errorMonitor->SetDesiredFailureMsg( |
| 6468 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6469 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6470 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6471 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6472 | |
| 6473 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6474 | VkImage srcImage; |
| 6475 | VkImage dstImage; |
| 6476 | VkDeviceMemory srcMem; |
| 6477 | VkDeviceMemory destMem; |
| 6478 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6479 | |
| 6480 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6481 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6482 | image_create_info.pNext = NULL; |
| 6483 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6484 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6485 | image_create_info.extent.width = 32; |
| 6486 | image_create_info.extent.height = 32; |
| 6487 | image_create_info.extent.depth = 1; |
| 6488 | image_create_info.mipLevels = 1; |
| 6489 | image_create_info.arrayLayers = 1; |
| 6490 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6491 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6492 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6493 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6494 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6495 | err = |
| 6496 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6497 | ASSERT_VK_SUCCESS(err); |
| 6498 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame^] | 6499 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 6500 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6501 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6502 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6503 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6504 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6505 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6506 | err = |
| 6507 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6508 | ASSERT_VK_SUCCESS(err); |
| 6509 | |
| 6510 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6511 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6512 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6513 | memAlloc.pNext = NULL; |
| 6514 | memAlloc.allocationSize = 0; |
| 6515 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6516 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6517 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6518 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6519 | pass = |
| 6520 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6521 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6522 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6523 | ASSERT_VK_SUCCESS(err); |
| 6524 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6525 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6526 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6527 | pass = |
| 6528 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6529 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6530 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6531 | ASSERT_VK_SUCCESS(err); |
| 6532 | |
| 6533 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6534 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6535 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6536 | ASSERT_VK_SUCCESS(err); |
| 6537 | |
| 6538 | BeginCommandBuffer(); |
| 6539 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6540 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6541 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6542 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6543 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6544 | copyRegion.srcOffset.x = 0; |
| 6545 | copyRegion.srcOffset.y = 0; |
| 6546 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6547 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6548 | copyRegion.dstSubresource.mipLevel = 0; |
| 6549 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6550 | copyRegion.dstSubresource.layerCount = 0; |
| 6551 | copyRegion.dstOffset.x = 0; |
| 6552 | copyRegion.dstOffset.y = 0; |
| 6553 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6554 | copyRegion.extent.width = 1; |
| 6555 | copyRegion.extent.height = 1; |
| 6556 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6557 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6558 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6559 | EndCommandBuffer(); |
| 6560 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6561 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6562 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6563 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6564 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6565 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6566 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6567 | } |
| 6568 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6569 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 6570 | VkResult err; |
| 6571 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6572 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6573 | m_errorMonitor->SetDesiredFailureMsg( |
| 6574 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6575 | "vkCmdResolveImage called with source sample count less than 2."); |
| 6576 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6577 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6578 | |
| 6579 | // 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] | 6580 | VkImage srcImage; |
| 6581 | VkImage dstImage; |
| 6582 | VkDeviceMemory srcMem; |
| 6583 | VkDeviceMemory destMem; |
| 6584 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6585 | |
| 6586 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6587 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6588 | image_create_info.pNext = NULL; |
| 6589 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6590 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6591 | image_create_info.extent.width = 32; |
| 6592 | image_create_info.extent.height = 1; |
| 6593 | image_create_info.extent.depth = 1; |
| 6594 | image_create_info.mipLevels = 1; |
| 6595 | image_create_info.arrayLayers = 1; |
| 6596 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6597 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6598 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6599 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6600 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6601 | err = |
| 6602 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6603 | ASSERT_VK_SUCCESS(err); |
| 6604 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6605 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6606 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6607 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6608 | err = |
| 6609 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6610 | ASSERT_VK_SUCCESS(err); |
| 6611 | |
| 6612 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6613 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6614 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6615 | memAlloc.pNext = NULL; |
| 6616 | memAlloc.allocationSize = 0; |
| 6617 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6618 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6619 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6620 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6621 | pass = |
| 6622 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6623 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6624 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6625 | ASSERT_VK_SUCCESS(err); |
| 6626 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6627 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6628 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6629 | pass = |
| 6630 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6631 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6632 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6633 | ASSERT_VK_SUCCESS(err); |
| 6634 | |
| 6635 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6636 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6637 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6638 | ASSERT_VK_SUCCESS(err); |
| 6639 | |
| 6640 | BeginCommandBuffer(); |
| 6641 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6642 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6643 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6644 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6645 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6646 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6647 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6648 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6649 | resolveRegion.srcOffset.x = 0; |
| 6650 | resolveRegion.srcOffset.y = 0; |
| 6651 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6652 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6653 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6654 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6655 | resolveRegion.dstSubresource.layerCount = 0; |
| 6656 | resolveRegion.dstOffset.x = 0; |
| 6657 | resolveRegion.dstOffset.y = 0; |
| 6658 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6659 | resolveRegion.extent.width = 1; |
| 6660 | resolveRegion.extent.height = 1; |
| 6661 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6662 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6663 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6664 | EndCommandBuffer(); |
| 6665 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6666 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6667 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6668 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6669 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6670 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6671 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6672 | } |
| 6673 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6674 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 6675 | VkResult err; |
| 6676 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6677 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6678 | m_errorMonitor->SetDesiredFailureMsg( |
| 6679 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6680 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 6681 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6682 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6683 | |
| 6684 | // Create two images of sample count 2 and try to Resolve between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6685 | VkImage srcImage; |
| 6686 | VkImage dstImage; |
| 6687 | VkDeviceMemory srcMem; |
| 6688 | VkDeviceMemory destMem; |
| 6689 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6690 | |
| 6691 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6692 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6693 | image_create_info.pNext = NULL; |
| 6694 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6695 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6696 | image_create_info.extent.width = 32; |
| 6697 | image_create_info.extent.height = 1; |
| 6698 | image_create_info.extent.depth = 1; |
| 6699 | image_create_info.mipLevels = 1; |
| 6700 | image_create_info.arrayLayers = 1; |
| 6701 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6702 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6703 | // Note: Some implementations expect color attachment usage for any |
| 6704 | // multisample surface |
| 6705 | image_create_info.usage = |
| 6706 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6707 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6708 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6709 | err = |
| 6710 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6711 | ASSERT_VK_SUCCESS(err); |
| 6712 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6713 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6714 | // Note: Some implementations expect color attachment usage for any |
| 6715 | // multisample surface |
| 6716 | image_create_info.usage = |
| 6717 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6718 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6719 | err = |
| 6720 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6721 | ASSERT_VK_SUCCESS(err); |
| 6722 | |
| 6723 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6724 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6725 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6726 | memAlloc.pNext = NULL; |
| 6727 | memAlloc.allocationSize = 0; |
| 6728 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6729 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6730 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6731 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6732 | pass = |
| 6733 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6734 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6735 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6736 | ASSERT_VK_SUCCESS(err); |
| 6737 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6738 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6739 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6740 | pass = |
| 6741 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6742 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6743 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6744 | ASSERT_VK_SUCCESS(err); |
| 6745 | |
| 6746 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6747 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6748 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6749 | ASSERT_VK_SUCCESS(err); |
| 6750 | |
| 6751 | BeginCommandBuffer(); |
| 6752 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6753 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6754 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6755 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6756 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6757 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6758 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6759 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6760 | resolveRegion.srcOffset.x = 0; |
| 6761 | resolveRegion.srcOffset.y = 0; |
| 6762 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6763 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6764 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6765 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6766 | resolveRegion.dstSubresource.layerCount = 0; |
| 6767 | resolveRegion.dstOffset.x = 0; |
| 6768 | resolveRegion.dstOffset.y = 0; |
| 6769 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6770 | resolveRegion.extent.width = 1; |
| 6771 | resolveRegion.extent.height = 1; |
| 6772 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6773 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6774 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6775 | EndCommandBuffer(); |
| 6776 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6777 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6778 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6779 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6780 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6781 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6782 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6783 | } |
| 6784 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6785 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 6786 | VkResult err; |
| 6787 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6788 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6789 | m_errorMonitor->SetDesiredFailureMsg( |
| 6790 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6791 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 6792 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6793 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6794 | |
| 6795 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6796 | VkImage srcImage; |
| 6797 | VkImage dstImage; |
| 6798 | VkDeviceMemory srcMem; |
| 6799 | VkDeviceMemory destMem; |
| 6800 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6801 | |
| 6802 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6803 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6804 | image_create_info.pNext = NULL; |
| 6805 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6806 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6807 | image_create_info.extent.width = 32; |
| 6808 | image_create_info.extent.height = 1; |
| 6809 | image_create_info.extent.depth = 1; |
| 6810 | image_create_info.mipLevels = 1; |
| 6811 | image_create_info.arrayLayers = 1; |
| 6812 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6813 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6814 | // Note: Some implementations expect color attachment usage for any |
| 6815 | // multisample surface |
| 6816 | image_create_info.usage = |
| 6817 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6818 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6820 | err = |
| 6821 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6822 | ASSERT_VK_SUCCESS(err); |
| 6823 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6824 | // Set format to something other than source image |
| 6825 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 6826 | // Note: Some implementations expect color attachment usage for any |
| 6827 | // multisample surface |
| 6828 | image_create_info.usage = |
| 6829 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6830 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6831 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6832 | err = |
| 6833 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6834 | ASSERT_VK_SUCCESS(err); |
| 6835 | |
| 6836 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6837 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6838 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6839 | memAlloc.pNext = NULL; |
| 6840 | memAlloc.allocationSize = 0; |
| 6841 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6842 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6843 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6844 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6845 | pass = |
| 6846 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6847 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6848 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6849 | ASSERT_VK_SUCCESS(err); |
| 6850 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6851 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6852 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6853 | pass = |
| 6854 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6855 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6856 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6857 | ASSERT_VK_SUCCESS(err); |
| 6858 | |
| 6859 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6860 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6861 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6862 | ASSERT_VK_SUCCESS(err); |
| 6863 | |
| 6864 | BeginCommandBuffer(); |
| 6865 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6866 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6867 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6868 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6869 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6870 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6871 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6872 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6873 | resolveRegion.srcOffset.x = 0; |
| 6874 | resolveRegion.srcOffset.y = 0; |
| 6875 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6876 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6877 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6878 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6879 | resolveRegion.dstSubresource.layerCount = 0; |
| 6880 | resolveRegion.dstOffset.x = 0; |
| 6881 | resolveRegion.dstOffset.y = 0; |
| 6882 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6883 | resolveRegion.extent.width = 1; |
| 6884 | resolveRegion.extent.height = 1; |
| 6885 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6886 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6887 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6888 | EndCommandBuffer(); |
| 6889 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6890 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6891 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6892 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6893 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6894 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6895 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6896 | } |
| 6897 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6898 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 6899 | VkResult err; |
| 6900 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6901 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6902 | m_errorMonitor->SetDesiredFailureMsg( |
| 6903 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6904 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 6905 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6906 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6907 | |
| 6908 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6909 | VkImage srcImage; |
| 6910 | VkImage dstImage; |
| 6911 | VkDeviceMemory srcMem; |
| 6912 | VkDeviceMemory destMem; |
| 6913 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6914 | |
| 6915 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6916 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6917 | image_create_info.pNext = NULL; |
| 6918 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6919 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6920 | image_create_info.extent.width = 32; |
| 6921 | image_create_info.extent.height = 1; |
| 6922 | image_create_info.extent.depth = 1; |
| 6923 | image_create_info.mipLevels = 1; |
| 6924 | image_create_info.arrayLayers = 1; |
| 6925 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6926 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6927 | // Note: Some implementations expect color attachment usage for any |
| 6928 | // multisample surface |
| 6929 | image_create_info.usage = |
| 6930 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6931 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6932 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6933 | err = |
| 6934 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6935 | ASSERT_VK_SUCCESS(err); |
| 6936 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6937 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6938 | // Note: Some implementations expect color attachment usage for any |
| 6939 | // multisample surface |
| 6940 | image_create_info.usage = |
| 6941 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6942 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6943 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6944 | err = |
| 6945 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6946 | ASSERT_VK_SUCCESS(err); |
| 6947 | |
| 6948 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6949 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6950 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6951 | memAlloc.pNext = NULL; |
| 6952 | memAlloc.allocationSize = 0; |
| 6953 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6954 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6955 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6956 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6957 | pass = |
| 6958 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6959 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6960 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6961 | ASSERT_VK_SUCCESS(err); |
| 6962 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6963 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6964 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6965 | pass = |
| 6966 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6967 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6968 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6969 | ASSERT_VK_SUCCESS(err); |
| 6970 | |
| 6971 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6972 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6973 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6974 | ASSERT_VK_SUCCESS(err); |
| 6975 | |
| 6976 | BeginCommandBuffer(); |
| 6977 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6978 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6979 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6980 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6981 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6982 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6983 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6984 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6985 | resolveRegion.srcOffset.x = 0; |
| 6986 | resolveRegion.srcOffset.y = 0; |
| 6987 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6988 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6989 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6990 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6991 | resolveRegion.dstSubresource.layerCount = 0; |
| 6992 | resolveRegion.dstOffset.x = 0; |
| 6993 | resolveRegion.dstOffset.y = 0; |
| 6994 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6995 | resolveRegion.extent.width = 1; |
| 6996 | resolveRegion.extent.height = 1; |
| 6997 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6998 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6999 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7000 | EndCommandBuffer(); |
| 7001 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7002 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7003 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7004 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7005 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7006 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 7007 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7008 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7009 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7010 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7011 | // 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] | 7012 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 7013 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7014 | // The image format check comes 2nd in validation so we trigger it first, |
| 7015 | // 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] | 7016 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7017 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7018 | m_errorMonitor->SetDesiredFailureMsg( |
| 7019 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7020 | "Combination depth/stencil image formats can have only the "); |
| 7021 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7022 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7023 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7024 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7025 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 7026 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7027 | |
| 7028 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7029 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7030 | ds_pool_ci.pNext = NULL; |
| 7031 | ds_pool_ci.maxSets = 1; |
| 7032 | ds_pool_ci.poolSizeCount = 1; |
| 7033 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7034 | |
| 7035 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7036 | err = |
| 7037 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7038 | ASSERT_VK_SUCCESS(err); |
| 7039 | |
| 7040 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7041 | dsl_binding.binding = 0; |
| 7042 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 7043 | dsl_binding.descriptorCount = 1; |
| 7044 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7045 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7046 | |
| 7047 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7048 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7049 | ds_layout_ci.pNext = NULL; |
| 7050 | ds_layout_ci.bindingCount = 1; |
| 7051 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7052 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7053 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7054 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7055 | ASSERT_VK_SUCCESS(err); |
| 7056 | |
| 7057 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7058 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7059 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7060 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7061 | alloc_info.descriptorPool = ds_pool; |
| 7062 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7063 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7064 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7065 | ASSERT_VK_SUCCESS(err); |
| 7066 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7067 | VkImage image_bad; |
| 7068 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7069 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7070 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7071 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7072 | const int32_t tex_width = 32; |
| 7073 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7074 | |
| 7075 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7076 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7077 | image_create_info.pNext = NULL; |
| 7078 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7079 | image_create_info.format = tex_format_bad; |
| 7080 | image_create_info.extent.width = tex_width; |
| 7081 | image_create_info.extent.height = tex_height; |
| 7082 | image_create_info.extent.depth = 1; |
| 7083 | image_create_info.mipLevels = 1; |
| 7084 | image_create_info.arrayLayers = 1; |
| 7085 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7086 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7087 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 7088 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 7089 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7090 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7091 | err = |
| 7092 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7093 | ASSERT_VK_SUCCESS(err); |
| 7094 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7095 | image_create_info.usage = |
| 7096 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 7097 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 7098 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7099 | ASSERT_VK_SUCCESS(err); |
| 7100 | |
| 7101 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7102 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7103 | image_view_create_info.image = image_bad; |
| 7104 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7105 | image_view_create_info.format = tex_format_bad; |
| 7106 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 7107 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 7108 | image_view_create_info.subresourceRange.layerCount = 1; |
| 7109 | image_view_create_info.subresourceRange.levelCount = 1; |
| 7110 | image_view_create_info.subresourceRange.aspectMask = |
| 7111 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7112 | |
| 7113 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7114 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 7115 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7116 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7117 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7118 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7119 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 7120 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7121 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7122 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7123 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7124 | #endif // IMAGE_TESTS |
| 7125 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7126 | int main(int argc, char **argv) { |
| 7127 | int result; |
| 7128 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 7129 | #ifdef ANDROID |
| 7130 | int vulkanSupport = InitVulkan(); |
| 7131 | if (vulkanSupport == 0) |
| 7132 | return 1; |
| 7133 | #endif |
| 7134 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7135 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 7136 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7137 | |
| 7138 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 7139 | |
| 7140 | result = RUN_ALL_TESTS(); |
| 7141 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 7142 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7143 | return result; |
| 7144 | } |