Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5 | * Copyright (c) 2015-2016 Google, Inc. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12 | * |
| 13 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 14 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 15 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 16 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 17 | * Author: Mike Stroyan <mike@LunarG.com> |
| 18 | * Author: Tobin Ehlis <tobine@google.com> |
| 19 | * Author: Tony Barbour <tony@LunarG.com> |
| 20 | */ |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 21 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 22 | #ifdef ANDROID |
| 23 | #include "vulkan_wrapper.h" |
| 24 | #else |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 25 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 26 | #endif |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 27 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 28 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 29 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 30 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 31 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 32 | #define GLM_FORCE_RADIANS |
| 33 | #include "glm/glm.hpp" |
| 34 | #include <glm/gtc/matrix_transform.hpp> |
| 35 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 36 | #define MEM_TRACKER_TESTS 1 |
| 37 | #define OBJ_TRACKER_TESTS 1 |
| 38 | #define DRAW_STATE_TESTS 1 |
| 39 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 40 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 41 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 42 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 43 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 44 | //-------------------------------------------------------------------------------------- |
| 45 | // Mesh and VertexFormat Data |
| 46 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 47 | struct Vertex { |
| 48 | float posX, posY, posZ, posW; // Position data |
| 49 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 50 | }; |
| 51 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 52 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 53 | |
| 54 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 55 | BsoFailNone = 0x00000000, |
| 56 | BsoFailLineWidth = 0x00000001, |
| 57 | BsoFailDepthBias = 0x00000002, |
| 58 | BsoFailViewport = 0x00000004, |
| 59 | BsoFailScissor = 0x00000008, |
| 60 | BsoFailBlend = 0x00000010, |
| 61 | BsoFailDepthBounds = 0x00000020, |
| 62 | BsoFailStencilReadMask = 0x00000040, |
| 63 | BsoFailStencilWriteMask = 0x00000080, |
| 64 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 65 | } BsoFailSelect; |
| 66 | |
| 67 | struct vktriangle_vs_uniform { |
| 68 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 69 | float mvp[4][4]; |
| 70 | float position[3][4]; |
| 71 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 72 | }; |
| 73 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 74 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 75 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 76 | "vec2 vertices[3];\n" |
| 77 | "out gl_PerVertex {\n" |
| 78 | " vec4 gl_Position;\n" |
| 79 | "};\n" |
| 80 | "void main() {\n" |
| 81 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 82 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 83 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 84 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 85 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 86 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 87 | static const char bindStateFragShaderText[] = |
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 | "\n" |
| 90 | "layout(location = 0) out vec4 uFragColor;\n" |
| 91 | "void main(){\n" |
| 92 | " uFragColor = vec4(0,1,0,1);\n" |
| 93 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 94 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 95 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 96 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 97 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 98 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 99 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 100 | // ******************************************************** |
| 101 | // ErrorMonitor Usage: |
| 102 | // |
| 103 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 104 | // encountered log messages. Passing NULL will match all log messages. |
| 105 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 106 | // |
| 107 | // Call DesiredMsgFound to determine if the desired failure message |
| 108 | // was encountered. |
| 109 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 110 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 111 | public: |
| 112 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 113 | test_platform_thread_create_mutex(&m_mutex); |
| 114 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 115 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 116 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 117 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 118 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 119 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 120 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 121 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 122 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 123 | m_failureMsg.clear(); |
| 124 | m_otherMsgs.clear(); |
| 125 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 126 | m_msgFound = VK_FALSE; |
| 127 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 128 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 129 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 130 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 131 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 132 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 133 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 134 | if (m_bailout != NULL) { |
| 135 | *m_bailout = true; |
| 136 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 137 | string errorString(msgString); |
| 138 | if (msgFlags & m_msgFlags) { |
| 139 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 140 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 141 | m_otherMsgs.push_back(m_failureMsg); |
| 142 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 143 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 144 | m_msgFound = VK_TRUE; |
| 145 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 146 | } else { |
| 147 | m_otherMsgs.push_back(errorString); |
| 148 | } |
| 149 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 150 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 151 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 152 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 153 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 154 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 155 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 156 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 158 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 159 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 160 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 161 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 162 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 163 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 164 | cout << "Other error messages logged for this test were:" << endl; |
| 165 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 166 | cout << " " << *iter << endl; |
| 167 | } |
| 168 | } |
| 169 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 170 | /* helpers */ |
| 171 | |
| 172 | void ExpectSuccess() { |
| 173 | // match anything |
| 174 | SetDesiredFailureMsg(~0u, ""); |
| 175 | } |
| 176 | |
| 177 | void VerifyFound() { |
| 178 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 179 | // any other messages. |
| 180 | if (!DesiredMsgFound()) { |
| 181 | DumpFailureMsgs(); |
| 182 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | void VerifyNotFound() { |
| 187 | // ExpectSuccess() configured us to match anything. Any error is a |
| 188 | // failure. |
| 189 | if (DesiredMsgFound()) { |
| 190 | DumpFailureMsgs(); |
| 191 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 192 | } |
| 193 | } |
| 194 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 195 | private: |
| 196 | VkFlags m_msgFlags; |
| 197 | string m_desiredMsg; |
| 198 | string m_failureMsg; |
| 199 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 200 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 201 | bool *m_bailout; |
| 202 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 203 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 204 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 205 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 206 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 207 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 208 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 209 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 210 | (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] | 211 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 212 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 213 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 214 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 215 | return false; |
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 | class VkLayerTest : public VkRenderFramework { |
| 219 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 220 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 221 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 222 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 223 | BsoFailSelect failMask); |
| 224 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 225 | VkPipelineObj &pipelineobj, |
| 226 | VkDescriptorSetObj &descriptorSet, |
| 227 | BsoFailSelect failMask); |
| 228 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 229 | VkDescriptorSetObj &descriptorSet, |
| 230 | BsoFailSelect failMask) { |
| 231 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 232 | failMask); |
| 233 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 234 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 235 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 236 | VkResult BeginCommandBuffer() { |
| 237 | return BeginCommandBuffer(*m_commandBuffer); |
| 238 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 239 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 240 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 241 | uint32_t firstVertex, uint32_t firstInstance) { |
| 242 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 243 | firstInstance); |
| 244 | } |
| 245 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 246 | uint32_t firstIndex, int32_t vertexOffset, |
| 247 | uint32_t firstInstance) { |
| 248 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 249 | vertexOffset, firstInstance); |
| 250 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 251 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 252 | void QueueCommandBuffer(const VkFence &fence) { |
| 253 | m_commandBuffer->QueueCommandBuffer(fence); |
| 254 | } |
| 255 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 256 | VkDeviceSize offset, uint32_t binding) { |
| 257 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 258 | } |
| 259 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 260 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 261 | } |
| 262 | |
| 263 | protected: |
| 264 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 265 | |
| 266 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 267 | std::vector<const char *> instance_layer_names; |
| 268 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 269 | std::vector<const char *> instance_extension_names; |
| 270 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 271 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 272 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 273 | /* |
| 274 | * Since CreateDbgMsgCallback is an instance level extension call |
| 275 | * any extension / layer that utilizes that feature also needs |
| 276 | * to be enabled at create instance time. |
| 277 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 278 | // Use Threading layer first to protect others from |
| 279 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 280 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 281 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 282 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 283 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 284 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 285 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 287 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 288 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 289 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 290 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 291 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 292 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 293 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 295 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 296 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 297 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 298 | this->app_info.pApplicationName = "layer_tests"; |
| 299 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 300 | this->app_info.pEngineName = "unittest"; |
| 301 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 302 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 303 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 304 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 305 | InitFramework(instance_layer_names, device_layer_names, |
| 306 | instance_extension_names, device_extension_names, |
| 307 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | virtual void TearDown() { |
| 311 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 312 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 313 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 314 | } |
| 315 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 316 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 317 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 318 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 319 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 320 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 321 | |
| 322 | /* |
| 323 | * For render test all drawing happens in a single render pass |
| 324 | * on a single command buffer. |
| 325 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 326 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 327 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | return result; |
| 331 | } |
| 332 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 333 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 334 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 335 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 336 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 337 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 338 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 339 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 340 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 341 | |
| 342 | return result; |
| 343 | } |
| 344 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 345 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 346 | const char *fragShaderText, |
| 347 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 348 | // Create identity matrix |
| 349 | int i; |
| 350 | struct vktriangle_vs_uniform data; |
| 351 | |
| 352 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 353 | glm::mat4 View = glm::mat4(1.0f); |
| 354 | glm::mat4 Model = glm::mat4(1.0f); |
| 355 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 356 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 357 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 358 | |
| 359 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 360 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 361 | static const Vertex tri_data[] = { |
| 362 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 363 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 364 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 365 | }; |
| 366 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 367 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 368 | data.position[i][0] = tri_data[i].posX; |
| 369 | data.position[i][1] = tri_data[i].posY; |
| 370 | data.position[i][2] = tri_data[i].posZ; |
| 371 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 372 | data.color[i][0] = tri_data[i].r; |
| 373 | data.color[i][1] = tri_data[i].g; |
| 374 | data.color[i][2] = tri_data[i].b; |
| 375 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 379 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 380 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 381 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 382 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 383 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 384 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 385 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 386 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 387 | |
| 388 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 389 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 390 | pipelineobj.AddShader(&vs); |
| 391 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 392 | if (failMask & BsoFailLineWidth) { |
| 393 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 394 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 395 | ia_state.sType = |
| 396 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 397 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 398 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 399 | } |
| 400 | if (failMask & BsoFailDepthBias) { |
| 401 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 402 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 403 | rs_state.sType = |
| 404 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 405 | rs_state.depthBiasEnable = VK_TRUE; |
| 406 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 407 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 408 | // Viewport and scissors must stay in synch or other errors will occur than |
| 409 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 410 | if (failMask & BsoFailViewport) { |
| 411 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 412 | m_viewports.clear(); |
| 413 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 414 | } |
| 415 | if (failMask & BsoFailScissor) { |
| 416 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 417 | m_scissors.clear(); |
| 418 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 419 | } |
| 420 | if (failMask & BsoFailBlend) { |
| 421 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 422 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 423 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 424 | att_state.blendEnable = VK_TRUE; |
| 425 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 426 | } |
| 427 | if (failMask & BsoFailDepthBounds) { |
| 428 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 429 | } |
| 430 | if (failMask & BsoFailStencilReadMask) { |
| 431 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 432 | } |
| 433 | if (failMask & BsoFailStencilWriteMask) { |
| 434 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 435 | } |
| 436 | if (failMask & BsoFailStencilReference) { |
| 437 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 438 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 439 | |
| 440 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 441 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 442 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 443 | |
| 444 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 445 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 446 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 447 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 448 | |
| 449 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 450 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 451 | |
| 452 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 453 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 454 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 455 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 456 | } |
| 457 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 458 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 459 | VkPipelineObj &pipelineobj, |
| 460 | VkDescriptorSetObj &descriptorSet, |
| 461 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 462 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 463 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 464 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 465 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 466 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 467 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 468 | } |
| 469 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 470 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 471 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 472 | // correctly |
| 473 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 474 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 475 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 476 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 477 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 478 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 479 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 480 | |
| 481 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 482 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 483 | ds_ci.pNext = NULL; |
| 484 | ds_ci.depthTestEnable = VK_FALSE; |
| 485 | ds_ci.depthWriteEnable = VK_TRUE; |
| 486 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 487 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 488 | if (failMask & BsoFailDepthBounds) { |
| 489 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
| 490 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 491 | ds_ci.stencilTestEnable = VK_TRUE; |
| 492 | ds_ci.front = stencil; |
| 493 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 494 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 495 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 496 | pipelineobj.SetViewport(m_viewports); |
| 497 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 498 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 499 | VkResult err = pipelineobj.CreateVKPipeline( |
| 500 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 501 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 502 | commandBuffer->BindPipeline(pipelineobj); |
| 503 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | // ******************************************************************************************************************** |
| 507 | // ******************************************************************************************************************** |
| 508 | // ******************************************************************************************************************** |
| 509 | // ******************************************************************************************************************** |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 510 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 511 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 512 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 513 | { |
| 514 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 515 | VkFenceCreateInfo fenceInfo = {}; |
| 516 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 517 | fenceInfo.pNext = NULL; |
| 518 | fenceInfo.flags = 0; |
| 519 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 520 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 521 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 522 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 523 | |
| 524 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 525 | vk_testing::Buffer buffer; |
| 526 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 527 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 528 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 529 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 530 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 531 | |
| 532 | testFence.init(*m_device, fenceInfo); |
| 533 | |
| 534 | // Bypass framework since it does the waits automatically |
| 535 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 536 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 537 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 538 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 539 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 540 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 541 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 542 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 543 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 544 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 545 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 546 | |
| 547 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 548 | ASSERT_VK_SUCCESS( err ); |
| 549 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 550 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 551 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 552 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 553 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 554 | } |
| 555 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 556 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 557 | { |
| 558 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 559 | VkFenceCreateInfo fenceInfo = {}; |
| 560 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 561 | fenceInfo.pNext = NULL; |
| 562 | fenceInfo.flags = 0; |
| 563 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 564 | 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] | 565 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 566 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 567 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 568 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 569 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 570 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 571 | 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] | 572 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 573 | |
| 574 | testFence.init(*m_device, fenceInfo); |
| 575 | |
| 576 | // Bypass framework since it does the waits automatically |
| 577 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 578 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 579 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 580 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 581 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 582 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 583 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 584 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 585 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 586 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 587 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 588 | |
| 589 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 590 | ASSERT_VK_SUCCESS( err ); |
| 591 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 592 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 593 | VkCommandBufferBeginInfo info = {}; |
| 594 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 595 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 596 | info.renderPass = VK_NULL_HANDLE; |
| 597 | info.subpass = 0; |
| 598 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 599 | info.occlusionQueryEnable = VK_FALSE; |
| 600 | info.queryFlags = 0; |
| 601 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 602 | |
| 603 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 604 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 605 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 606 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 607 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 608 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 609 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 610 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 611 | VkResult err; |
| 612 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 613 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 614 | m_errorMonitor->SetDesiredFailureMsg( |
| 615 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 616 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 617 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 618 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 619 | |
| 620 | // 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] | 621 | VkImage image; |
| 622 | VkDeviceMemory mem; |
| 623 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 624 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 625 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 626 | const int32_t tex_width = 32; |
| 627 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 628 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 629 | VkImageCreateInfo image_create_info = {}; |
| 630 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 631 | image_create_info.pNext = NULL; |
| 632 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 633 | image_create_info.format = tex_format; |
| 634 | image_create_info.extent.width = tex_width; |
| 635 | image_create_info.extent.height = tex_height; |
| 636 | image_create_info.extent.depth = 1; |
| 637 | image_create_info.mipLevels = 1; |
| 638 | image_create_info.arrayLayers = 1; |
| 639 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 640 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 641 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 642 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 643 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 644 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 645 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 646 | mem_alloc.pNext = NULL; |
| 647 | mem_alloc.allocationSize = 0; |
| 648 | // Introduce failure, do NOT set memProps to |
| 649 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 650 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 651 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 652 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 653 | ASSERT_VK_SUCCESS(err); |
| 654 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 655 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 656 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 657 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 658 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 659 | pass = |
| 660 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 661 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 662 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 663 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 664 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 665 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 666 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 667 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 668 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 669 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 670 | ASSERT_VK_SUCCESS(err); |
| 671 | |
| 672 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 673 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 674 | ASSERT_VK_SUCCESS(err); |
| 675 | |
| 676 | // Map memory as if to initialize the image |
| 677 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 678 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 679 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 680 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 681 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 682 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 683 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 684 | } |
| 685 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 686 | TEST_F(VkLayerTest, RebindMemory) { |
| 687 | VkResult err; |
| 688 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 689 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 690 | m_errorMonitor->SetDesiredFailureMsg( |
| 691 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 692 | "which has already been bound to mem object"); |
| 693 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 694 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 695 | |
| 696 | // 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] | 697 | VkImage image; |
| 698 | VkDeviceMemory mem1; |
| 699 | VkDeviceMemory mem2; |
| 700 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 701 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 702 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 703 | const int32_t tex_width = 32; |
| 704 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 705 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 706 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 707 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 708 | image_create_info.pNext = NULL; |
| 709 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 710 | image_create_info.format = tex_format; |
| 711 | image_create_info.extent.width = tex_width; |
| 712 | image_create_info.extent.height = tex_height; |
| 713 | image_create_info.extent.depth = 1; |
| 714 | image_create_info.mipLevels = 1; |
| 715 | image_create_info.arrayLayers = 1; |
| 716 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 717 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 718 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 719 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 720 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 721 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 722 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 723 | mem_alloc.pNext = NULL; |
| 724 | mem_alloc.allocationSize = 0; |
| 725 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 726 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 727 | // Introduce failure, do NOT set memProps to |
| 728 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 729 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 730 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 731 | ASSERT_VK_SUCCESS(err); |
| 732 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 733 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 734 | |
| 735 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 736 | pass = |
| 737 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 738 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 739 | |
| 740 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 741 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 742 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 743 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 744 | ASSERT_VK_SUCCESS(err); |
| 745 | |
| 746 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 747 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 748 | ASSERT_VK_SUCCESS(err); |
| 749 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 750 | // Introduce validation failure, try to bind a different memory object to |
| 751 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 752 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 753 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 754 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 755 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 756 | vkDestroyImage(m_device->device(), image, NULL); |
| 757 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 758 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 759 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 760 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 761 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 762 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 763 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 764 | m_errorMonitor->SetDesiredFailureMsg( |
| 765 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 766 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 767 | |
| 768 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 769 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 770 | fenceInfo.pNext = NULL; |
| 771 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 772 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 773 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 774 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 775 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 776 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 777 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 778 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 779 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 780 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 781 | |
| 782 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 783 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 784 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 785 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 786 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 787 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 788 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 789 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 790 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 791 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 792 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 793 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 794 | |
| 795 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 796 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 797 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 798 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 799 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame^] | 800 | // This is a positive test. We used to expect error in this case but spec now |
| 801 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 802 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame^] | 803 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 804 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 805 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 806 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 807 | fenceInfo.pNext = NULL; |
| 808 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 809 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 810 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 811 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame^] | 812 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 813 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 814 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame^] | 815 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 816 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 817 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 818 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 819 | #if 0 |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 820 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 821 | { |
| 822 | // Initiate Draw w/o a PSO bound |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 823 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 824 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 825 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 826 | |
| 827 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 828 | VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 829 | BeginCommandBuffer(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 830 | |
| 831 | const VkExtent3D e3d = { |
| 832 | .width = 128, |
| 833 | .height = 128, |
| 834 | .depth = 1, |
| 835 | }; |
| 836 | const VkImageCreateInfo ici = { |
| 837 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 838 | .pNext = NULL, |
| 839 | .imageType = VK_IMAGE_TYPE_2D, |
| 840 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 841 | .extent = e3d, |
| 842 | .mipLevels = 1, |
| 843 | .arraySize = 1, |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 844 | .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 845 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | 660f0ca | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 846 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 847 | .flags = 0, |
| 848 | }; |
| 849 | |
| 850 | VkImage dsi; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 851 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 852 | VkDepthStencilView dsv; |
| 853 | const VkDepthStencilViewCreateInfo dsvci = { |
| 854 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 855 | .pNext = NULL, |
| 856 | .image = dsi, |
| 857 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 4a26189 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 858 | .baseArrayLayer = 0, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 859 | .arraySize = 1, |
| 860 | .flags = 0, |
| 861 | }; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 862 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 863 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 864 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 865 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 866 | #endif // 0 |
| 867 | #endif // MEM_TRACKER_TESTS |
| 868 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 869 | #if OBJ_TRACKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 870 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 871 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 872 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 873 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 874 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 875 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 876 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 877 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 878 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 879 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 880 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 881 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 882 | |
| 883 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 884 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 885 | ds_pool_ci.pNext = NULL; |
| 886 | ds_pool_ci.maxSets = 1; |
| 887 | ds_pool_ci.poolSizeCount = 1; |
| 888 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 889 | |
| 890 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 891 | err = |
| 892 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 893 | ASSERT_VK_SUCCESS(err); |
| 894 | |
| 895 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 896 | dsl_binding.binding = 0; |
| 897 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 898 | dsl_binding.descriptorCount = 1; |
| 899 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 900 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 901 | |
| 902 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 903 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 904 | ds_layout_ci.pNext = NULL; |
| 905 | ds_layout_ci.bindingCount = 1; |
| 906 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 907 | |
| 908 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 909 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 910 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 911 | ASSERT_VK_SUCCESS(err); |
| 912 | |
| 913 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 914 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 915 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 916 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 917 | alloc_info.descriptorPool = ds_pool; |
| 918 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 919 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 920 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 921 | ASSERT_VK_SUCCESS(err); |
| 922 | |
| 923 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 924 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 925 | pipeline_layout_ci.pNext = NULL; |
| 926 | pipeline_layout_ci.setLayoutCount = 1; |
| 927 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 928 | |
| 929 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 930 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 931 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 932 | ASSERT_VK_SUCCESS(err); |
| 933 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 934 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 935 | |
| 936 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 937 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 938 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 939 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 940 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 941 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 942 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 943 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 944 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 945 | } |
| 946 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 947 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 948 | VkResult err; |
| 949 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 950 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 951 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 952 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 953 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 954 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 955 | |
| 956 | // 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] | 957 | VkImage image; |
| 958 | VkDeviceMemory mem; |
| 959 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 960 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 961 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 962 | const int32_t tex_width = 32; |
| 963 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 964 | |
| 965 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 966 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 967 | image_create_info.pNext = NULL; |
| 968 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 969 | image_create_info.format = tex_format; |
| 970 | image_create_info.extent.width = tex_width; |
| 971 | image_create_info.extent.height = tex_height; |
| 972 | image_create_info.extent.depth = 1; |
| 973 | image_create_info.mipLevels = 1; |
| 974 | image_create_info.arrayLayers = 1; |
| 975 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 976 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 977 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 978 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 979 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 980 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 981 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 982 | mem_alloc.pNext = NULL; |
| 983 | mem_alloc.allocationSize = 0; |
| 984 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 985 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 986 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 987 | ASSERT_VK_SUCCESS(err); |
| 988 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 989 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 990 | |
| 991 | mem_alloc.allocationSize = mem_reqs.size; |
| 992 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 993 | pass = |
| 994 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 995 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 996 | |
| 997 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 998 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 999 | ASSERT_VK_SUCCESS(err); |
| 1000 | |
| 1001 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1002 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1003 | |
| 1004 | // Try to bind free memory that has been freed |
| 1005 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1006 | // This may very well return an error. |
| 1007 | (void)err; |
| 1008 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1009 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1010 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1011 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1012 | } |
| 1013 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1014 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1015 | VkResult err; |
| 1016 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1017 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1018 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1019 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1020 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1021 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1022 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1023 | // Create an image object, allocate memory, destroy the object and then try |
| 1024 | // to bind it |
| 1025 | VkImage image; |
| 1026 | VkDeviceMemory mem; |
| 1027 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1028 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1029 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1030 | const int32_t tex_width = 32; |
| 1031 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1032 | |
| 1033 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1034 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1035 | image_create_info.pNext = NULL; |
| 1036 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1037 | image_create_info.format = tex_format; |
| 1038 | image_create_info.extent.width = tex_width; |
| 1039 | image_create_info.extent.height = tex_height; |
| 1040 | image_create_info.extent.depth = 1; |
| 1041 | image_create_info.mipLevels = 1; |
| 1042 | image_create_info.arrayLayers = 1; |
| 1043 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1044 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1045 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1046 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1047 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1048 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1049 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1050 | mem_alloc.pNext = NULL; |
| 1051 | mem_alloc.allocationSize = 0; |
| 1052 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1053 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1054 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1055 | ASSERT_VK_SUCCESS(err); |
| 1056 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1057 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1058 | |
| 1059 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1060 | pass = |
| 1061 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1062 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1063 | |
| 1064 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1065 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1066 | ASSERT_VK_SUCCESS(err); |
| 1067 | |
| 1068 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1069 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1070 | ASSERT_VK_SUCCESS(err); |
| 1071 | |
| 1072 | // Now Try to bind memory to this destroyed object |
| 1073 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1074 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1075 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1076 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1077 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1078 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1079 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1080 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1081 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1082 | #endif // OBJ_TRACKER_TESTS |
| 1083 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1084 | #if DRAW_STATE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1085 | TEST_F(VkLayerTest, LineWidthStateNotBound) { |
| 1086 | m_errorMonitor->SetDesiredFailureMsg( |
| 1087 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1088 | "Dynamic line width state not set for this command buffer"); |
| 1089 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1090 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line " |
| 1091 | "width state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1092 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1093 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1094 | BsoFailLineWidth); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1095 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1096 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1097 | } |
| 1098 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1099 | TEST_F(VkLayerTest, DepthBiasStateNotBound) { |
| 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 depth bias 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 depth " |
| 1105 | "bias 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 | BsoFailDepthBias); |
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 | // Disable these two tests until we can sort out how to track multiple layer |
| 1114 | // errors |
| 1115 | TEST_F(VkLayerTest, ViewportStateNotBound) { |
| 1116 | m_errorMonitor->SetDesiredFailureMsg( |
| 1117 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1118 | "Dynamic viewport state not set for this command buffer"); |
| 1119 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1120 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport " |
| 1121 | "state object is not bound beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1122 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1123 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1124 | BsoFailViewport); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1125 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1126 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1127 | } |
| 1128 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1129 | TEST_F(VkLayerTest, ScissorStateNotBound) { |
| 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 scissor 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 | BsoFailScissor); |
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, BlendStateNotBound) { |
| 1144 | m_errorMonitor->SetDesiredFailureMsg( |
| 1145 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 1146 | "Dynamic blend constants state not set for this command buffer"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1147 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1148 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend " |
| 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 | BsoFailBlend); |
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, DepthBoundsStateNotBound) { |
| 1158 | m_errorMonitor->SetDesiredFailureMsg( |
| 1159 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1160 | "Dynamic depth bounds state not set for this command buffer"); |
| 1161 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1162 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth " |
| 1163 | "bounds 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 | BsoFailDepthBounds); |
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, StencilReadMaskNotSet) { |
| 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 stencil read mask state not set for this command buffer"); |
| 1175 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1176 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1177 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1178 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1179 | "read mask is not set beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1180 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1181 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1182 | BsoFailStencilReadMask); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1183 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1184 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1185 | } |
| 1186 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1187 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) { |
| 1188 | m_errorMonitor->SetDesiredFailureMsg( |
| 1189 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1190 | "Dynamic stencil write mask state not set for this command buffer"); |
| 1191 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1192 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1193 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1194 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil " |
| 1195 | "write mask is not set beforehand"); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1197 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 1198 | BsoFailStencilWriteMask); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1199 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1200 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1201 | } |
| 1202 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1203 | TEST_F(VkLayerTest, StencilReferenceNotSet) { |
| 1204 | m_errorMonitor->SetDesiredFailureMsg( |
| 1205 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1206 | "Dynamic stencil reference state not set for this command buffer"); |
| 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 | "reference 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 | BsoFailStencilReference); |
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, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1218 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1219 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1220 | m_errorMonitor->SetDesiredFailureMsg( |
| 1221 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1222 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 1223 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1224 | |
| 1225 | VkFenceCreateInfo fenceInfo = {}; |
| 1226 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1227 | fenceInfo.pNext = NULL; |
| 1228 | fenceInfo.flags = 0; |
| 1229 | |
| 1230 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1231 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1232 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1233 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1234 | // We luck out b/c by default the framework creates CB w/ the |
| 1235 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1236 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1237 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 1238 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1239 | EndCommandBuffer(); |
| 1240 | |
| 1241 | testFence.init(*m_device, fenceInfo); |
| 1242 | |
| 1243 | // Bypass framework since it does the waits automatically |
| 1244 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1245 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1246 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1247 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1248 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1249 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1250 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1251 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1252 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1253 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1254 | submit_info.pSignalSemaphores = NULL; |
| 1255 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1256 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 1257 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1258 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1259 | // Cause validation error by re-submitting cmd buffer that should only be |
| 1260 | // submitted once |
| 1261 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1262 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1263 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1264 | } |
| 1265 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1266 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1267 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1268 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1269 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1270 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1271 | "Unable to allocate 1 descriptors of " |
| 1272 | "type " |
| 1273 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1274 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1275 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1276 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1277 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1278 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 1279 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1280 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1281 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1282 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1283 | |
| 1284 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1285 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1286 | ds_pool_ci.pNext = NULL; |
| 1287 | ds_pool_ci.flags = 0; |
| 1288 | ds_pool_ci.maxSets = 1; |
| 1289 | ds_pool_ci.poolSizeCount = 1; |
| 1290 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1291 | |
| 1292 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1293 | err = |
| 1294 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1295 | ASSERT_VK_SUCCESS(err); |
| 1296 | |
| 1297 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1298 | dsl_binding.binding = 0; |
| 1299 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1300 | dsl_binding.descriptorCount = 1; |
| 1301 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1302 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1303 | |
| 1304 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1305 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1306 | ds_layout_ci.pNext = NULL; |
| 1307 | ds_layout_ci.bindingCount = 1; |
| 1308 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1309 | |
| 1310 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1311 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1312 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1313 | ASSERT_VK_SUCCESS(err); |
| 1314 | |
| 1315 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1316 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1317 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1318 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1319 | alloc_info.descriptorPool = ds_pool; |
| 1320 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1321 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1322 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1323 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1324 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1325 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1326 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1327 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1328 | } |
| 1329 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1330 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 1331 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1332 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1333 | m_errorMonitor->SetDesiredFailureMsg( |
| 1334 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1335 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 1336 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1337 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1338 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1339 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1340 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1341 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1342 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1343 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1344 | |
| 1345 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1346 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1347 | ds_pool_ci.pNext = NULL; |
| 1348 | ds_pool_ci.maxSets = 1; |
| 1349 | ds_pool_ci.poolSizeCount = 1; |
| 1350 | ds_pool_ci.flags = 0; |
| 1351 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1352 | // app can only call vkResetDescriptorPool on this pool.; |
| 1353 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1354 | |
| 1355 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1356 | err = |
| 1357 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1358 | ASSERT_VK_SUCCESS(err); |
| 1359 | |
| 1360 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1361 | dsl_binding.binding = 0; |
| 1362 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1363 | dsl_binding.descriptorCount = 1; |
| 1364 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1365 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1366 | |
| 1367 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1368 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1369 | ds_layout_ci.pNext = NULL; |
| 1370 | ds_layout_ci.bindingCount = 1; |
| 1371 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1372 | |
| 1373 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1374 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1375 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1376 | ASSERT_VK_SUCCESS(err); |
| 1377 | |
| 1378 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1379 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1380 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1381 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1382 | alloc_info.descriptorPool = ds_pool; |
| 1383 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1384 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1385 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1386 | ASSERT_VK_SUCCESS(err); |
| 1387 | |
| 1388 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1389 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1390 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1391 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1392 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1393 | } |
| 1394 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1395 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 1396 | // Attempt to clear Descriptor Pool with bad object. |
| 1397 | // ObjectTracker should catch this. |
| 1398 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1399 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
| 1400 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1401 | vkResetDescriptorPool(device(), badPool, 0); |
| 1402 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1403 | } |
| 1404 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1405 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 1406 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 1407 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1408 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 1409 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
| 1410 | VkDescriptorSet badSet = (VkDescriptorSet)0xbaad6001; |
| 1411 | VkResult err; |
| 1412 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1413 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 1414 | |
| 1415 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1416 | |
| 1417 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 1418 | layout_bindings[0].binding = 0; |
| 1419 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1420 | layout_bindings[0].descriptorCount = 1; |
| 1421 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 1422 | layout_bindings[0].pImmutableSamplers = NULL; |
| 1423 | |
| 1424 | VkDescriptorSetLayout descriptor_set_layout; |
| 1425 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 1426 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1427 | dslci.pNext = NULL; |
| 1428 | dslci.bindingCount = 1; |
| 1429 | dslci.pBindings = layout_bindings; |
| 1430 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
| 1431 | assert(!err); |
| 1432 | |
| 1433 | VkPipelineLayout pipeline_layout; |
| 1434 | VkPipelineLayoutCreateInfo plci = {}; |
| 1435 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1436 | plci.pNext = NULL; |
| 1437 | plci.setLayoutCount = 1; |
| 1438 | plci.pSetLayouts = &descriptor_set_layout; |
| 1439 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 1440 | assert(!err); |
| 1441 | |
| 1442 | BeginCommandBuffer(); |
| 1443 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 1444 | pipeline_layout, 0, 1, &badSet, 0, NULL); |
| 1445 | m_errorMonitor->VerifyFound(); |
| 1446 | EndCommandBuffer(); |
| 1447 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 1448 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1449 | } |
| 1450 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1451 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 1452 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 1453 | // ObjectTracker should catch this. |
| 1454 | VkDescriptorSetLayout bad_layout = (VkDescriptorSetLayout)0xbaad6001; |
| 1455 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1456 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 1457 | |
| 1458 | VkPipelineLayout pipeline_layout; |
| 1459 | VkPipelineLayoutCreateInfo plci = {}; |
| 1460 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1461 | plci.pNext = NULL; |
| 1462 | plci.setLayoutCount = 1; |
| 1463 | plci.pSetLayouts = &bad_layout; |
| 1464 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 1465 | |
| 1466 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1467 | } |
| 1468 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1469 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 1470 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 1471 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1472 | // Create a valid cmd buffer |
| 1473 | // call vkCmdBindPipeline w/ false Pipeline |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 1474 | VkPipeline bad_pipeline = (VkPipeline)0xbaad6001; |
| 1475 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1476 | "Invalid VkPipeline Object 0xbaad6001"); |
| 1477 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1478 | BeginCommandBuffer(); |
| 1479 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1480 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 1481 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1482 | } |
| 1483 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1484 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 1485 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 1486 | // CommandBuffer |
| 1487 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1488 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 1489 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1490 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1491 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1492 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1493 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1494 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1495 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1496 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1497 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1498 | |
| 1499 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1500 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1501 | ds_pool_ci.pNext = NULL; |
| 1502 | ds_pool_ci.maxSets = 1; |
| 1503 | ds_pool_ci.poolSizeCount = 1; |
| 1504 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1505 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1506 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1507 | err = |
| 1508 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1509 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1510 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1511 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1512 | dsl_binding.binding = 0; |
| 1513 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1514 | dsl_binding.descriptorCount = 1; |
| 1515 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1516 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1517 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1518 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1519 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1520 | ds_layout_ci.pNext = NULL; |
| 1521 | ds_layout_ci.bindingCount = 1; |
| 1522 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1523 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1524 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1525 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1526 | ASSERT_VK_SUCCESS(err); |
| 1527 | |
| 1528 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1529 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1530 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1531 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1532 | alloc_info.descriptorPool = ds_pool; |
| 1533 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1534 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1535 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1536 | ASSERT_VK_SUCCESS(err); |
| 1537 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1538 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1539 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1540 | pipeline_layout_ci.pNext = NULL; |
| 1541 | pipeline_layout_ci.setLayoutCount = 1; |
| 1542 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1543 | |
| 1544 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1545 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1546 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1547 | ASSERT_VK_SUCCESS(err); |
| 1548 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1549 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 1550 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 1551 | // 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] | 1552 | // on more devices |
| 1553 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 1554 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1555 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1556 | VkPipelineObj pipe(m_device); |
| 1557 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1558 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 1559 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1560 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1561 | |
| 1562 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1563 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1564 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1565 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1566 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1567 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1568 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1569 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1570 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1571 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1572 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1573 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1574 | } |
| 1575 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1576 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1577 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1578 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1579 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1580 | m_errorMonitor->SetDesiredFailureMsg( |
| 1581 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1582 | "Attempt to update descriptor with invalid bufferView "); |
| 1583 | |
| 1584 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1585 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1586 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1587 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1588 | |
| 1589 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1590 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1591 | ds_pool_ci.pNext = NULL; |
| 1592 | ds_pool_ci.maxSets = 1; |
| 1593 | ds_pool_ci.poolSizeCount = 1; |
| 1594 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1595 | |
| 1596 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1597 | err = |
| 1598 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1599 | ASSERT_VK_SUCCESS(err); |
| 1600 | |
| 1601 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1602 | dsl_binding.binding = 0; |
| 1603 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1604 | dsl_binding.descriptorCount = 1; |
| 1605 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1606 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1607 | |
| 1608 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1609 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1610 | ds_layout_ci.pNext = NULL; |
| 1611 | ds_layout_ci.bindingCount = 1; |
| 1612 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1613 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1614 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1615 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1616 | ASSERT_VK_SUCCESS(err); |
| 1617 | |
| 1618 | VkDescriptorSet descriptorSet; |
| 1619 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1620 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1621 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1622 | alloc_info.descriptorPool = ds_pool; |
| 1623 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1624 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1625 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1626 | ASSERT_VK_SUCCESS(err); |
| 1627 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1628 | VkBufferView view = |
| 1629 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1630 | VkWriteDescriptorSet descriptor_write; |
| 1631 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1632 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1633 | descriptor_write.dstSet = descriptorSet; |
| 1634 | descriptor_write.dstBinding = 0; |
| 1635 | descriptor_write.descriptorCount = 1; |
| 1636 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1637 | descriptor_write.pTexelBufferView = &view; |
| 1638 | |
| 1639 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1640 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1641 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1642 | |
| 1643 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1644 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1645 | } |
| 1646 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1647 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 1648 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 1649 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1650 | // 1. No dynamicOffset supplied |
| 1651 | // 2. Too many dynamicOffsets supplied |
| 1652 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1653 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1654 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1655 | " requires 1 dynamicOffsets, but only " |
| 1656 | "0 dynamicOffsets are left in " |
| 1657 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1658 | |
| 1659 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1660 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1661 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1662 | |
| 1663 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1664 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1665 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1666 | |
| 1667 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1668 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1669 | ds_pool_ci.pNext = NULL; |
| 1670 | ds_pool_ci.maxSets = 1; |
| 1671 | ds_pool_ci.poolSizeCount = 1; |
| 1672 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1673 | |
| 1674 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1675 | err = |
| 1676 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1677 | ASSERT_VK_SUCCESS(err); |
| 1678 | |
| 1679 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1680 | dsl_binding.binding = 0; |
| 1681 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1682 | dsl_binding.descriptorCount = 1; |
| 1683 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1684 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1685 | |
| 1686 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1687 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1688 | ds_layout_ci.pNext = NULL; |
| 1689 | ds_layout_ci.bindingCount = 1; |
| 1690 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1691 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1692 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1693 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1694 | ASSERT_VK_SUCCESS(err); |
| 1695 | |
| 1696 | VkDescriptorSet descriptorSet; |
| 1697 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1698 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1699 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1700 | alloc_info.descriptorPool = ds_pool; |
| 1701 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1702 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1703 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1704 | ASSERT_VK_SUCCESS(err); |
| 1705 | |
| 1706 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1707 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1708 | pipeline_layout_ci.pNext = NULL; |
| 1709 | pipeline_layout_ci.setLayoutCount = 1; |
| 1710 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1711 | |
| 1712 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1713 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1714 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1715 | ASSERT_VK_SUCCESS(err); |
| 1716 | |
| 1717 | // Create a buffer to update the descriptor with |
| 1718 | uint32_t qfi = 0; |
| 1719 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1720 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1721 | buffCI.size = 1024; |
| 1722 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1723 | buffCI.queueFamilyIndexCount = 1; |
| 1724 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1725 | |
| 1726 | VkBuffer dyub; |
| 1727 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 1728 | ASSERT_VK_SUCCESS(err); |
| 1729 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 1730 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1731 | buffInfo.buffer = dyub; |
| 1732 | buffInfo.offset = 0; |
| 1733 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1734 | |
| 1735 | VkWriteDescriptorSet descriptor_write; |
| 1736 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1737 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1738 | descriptor_write.dstSet = descriptorSet; |
| 1739 | descriptor_write.dstBinding = 0; |
| 1740 | descriptor_write.descriptorCount = 1; |
| 1741 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1742 | descriptor_write.pBufferInfo = &buffInfo; |
| 1743 | |
| 1744 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1745 | |
| 1746 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1747 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1748 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1749 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1750 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1751 | uint32_t pDynOff[2] = {512, 756}; |
| 1752 | // 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] | 1753 | m_errorMonitor->SetDesiredFailureMsg( |
| 1754 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1755 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1756 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1757 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1758 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 1759 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1760 | // Finally cause error due to dynamicOffset being too big |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1761 | m_errorMonitor->SetDesiredFailureMsg( |
| 1762 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1763 | " from its update, this oversteps its buffer ("); |
| 1764 | // Create PSO to be used for draw-time errors below |
| 1765 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 1766 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1767 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 1768 | "out gl_PerVertex { \n" |
| 1769 | " vec4 gl_Position;\n" |
| 1770 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1771 | "void main(){\n" |
| 1772 | " gl_Position = vec4(1);\n" |
| 1773 | "}\n"; |
| 1774 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 1775 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1776 | "\n" |
| 1777 | "layout(location=0) out vec4 x;\n" |
| 1778 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 1779 | "void main(){\n" |
| 1780 | " x = vec4(bar.y);\n" |
| 1781 | "}\n"; |
| 1782 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1783 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 1784 | VkPipelineObj pipe(m_device); |
| 1785 | pipe.AddShader(&vs); |
| 1786 | pipe.AddShader(&fs); |
| 1787 | pipe.AddColorAttachment(); |
| 1788 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 1789 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1790 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1791 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1792 | // This update should succeed, but offset size of 512 will overstep buffer |
| 1793 | // /w range 1024 & size 1024 |
| 1794 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 1795 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 1796 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 1797 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1798 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1799 | |
| 1800 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1801 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1802 | } |
| 1803 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 1804 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 1805 | // Hit push constant error cases: |
| 1806 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 1807 | // 2. Incorrectly set push constant size to 0 |
| 1808 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 1809 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 1810 | VkResult err; |
| 1811 | m_errorMonitor->SetDesiredFailureMsg( |
| 1812 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1813 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 1814 | |
| 1815 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1816 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1817 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1818 | |
| 1819 | VkPushConstantRange pc_range = {}; |
| 1820 | pc_range.size = 0xFFFFFFFFu; |
| 1821 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 1822 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1823 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1824 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 1825 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 1826 | |
| 1827 | VkPipelineLayout pipeline_layout; |
| 1828 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1829 | &pipeline_layout); |
| 1830 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1831 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 1832 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 1833 | pc_range.size = 0; |
| 1834 | m_errorMonitor->SetDesiredFailureMsg( |
| 1835 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1836 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 1837 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1838 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1839 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 1840 | pc_range.size = 1; |
| 1841 | m_errorMonitor->SetDesiredFailureMsg( |
| 1842 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1843 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 1844 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1845 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1846 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 1847 | // Cause error due to bad size in vkCmdPushConstants() call |
| 1848 | m_errorMonitor->SetDesiredFailureMsg( |
| 1849 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1850 | "vkCmdPushConstants() call has push constants with offset "); |
| 1851 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 1852 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 1853 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1854 | &pipeline_layout); |
| 1855 | ASSERT_VK_SUCCESS(err); |
| 1856 | BeginCommandBuffer(); |
| 1857 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 1858 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1859 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 1860 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1861 | } |
| 1862 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1863 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1864 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1865 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1866 | |
| 1867 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1868 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1869 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1870 | |
| 1871 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 1872 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1873 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1874 | ds_type_count[0].descriptorCount = 10; |
| 1875 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 1876 | ds_type_count[1].descriptorCount = 2; |
| 1877 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 1878 | ds_type_count[2].descriptorCount = 2; |
| 1879 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1880 | ds_type_count[3].descriptorCount = 5; |
| 1881 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 1882 | // type |
| 1883 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 1884 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 1885 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1886 | |
| 1887 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1888 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1889 | ds_pool_ci.pNext = NULL; |
| 1890 | ds_pool_ci.maxSets = 5; |
| 1891 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 1892 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1893 | |
| 1894 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1895 | err = |
| 1896 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1897 | ASSERT_VK_SUCCESS(err); |
| 1898 | |
| 1899 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 1900 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1901 | dsl_binding[0].binding = 0; |
| 1902 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1903 | dsl_binding[0].descriptorCount = 5; |
| 1904 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 1905 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1906 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1907 | // Create layout identical to set0 layout but w/ different stageFlags |
| 1908 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1909 | dsl_fs_stage_only.binding = 0; |
| 1910 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1911 | dsl_fs_stage_only.descriptorCount = 5; |
| 1912 | dsl_fs_stage_only.stageFlags = |
| 1913 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 1914 | // bind time |
| 1915 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1916 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1917 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1918 | ds_layout_ci.pNext = NULL; |
| 1919 | ds_layout_ci.bindingCount = 1; |
| 1920 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1921 | static const uint32_t NUM_LAYOUTS = 4; |
| 1922 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1923 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1924 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 1925 | // layout for error case |
| 1926 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1927 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1928 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1929 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1930 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1931 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1932 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1933 | dsl_binding[0].binding = 0; |
| 1934 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1935 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 1936 | dsl_binding[1].binding = 1; |
| 1937 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 1938 | dsl_binding[1].descriptorCount = 2; |
| 1939 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 1940 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 1941 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1942 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1943 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1944 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1945 | ASSERT_VK_SUCCESS(err); |
| 1946 | dsl_binding[0].binding = 0; |
| 1947 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1948 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1949 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1950 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1951 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1952 | ASSERT_VK_SUCCESS(err); |
| 1953 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1954 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1955 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1956 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1957 | ASSERT_VK_SUCCESS(err); |
| 1958 | |
| 1959 | static const uint32_t NUM_SETS = 4; |
| 1960 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 1961 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1962 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1963 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1964 | alloc_info.descriptorPool = ds_pool; |
| 1965 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1966 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1967 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1968 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1969 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1970 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1971 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1972 | err = |
| 1973 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1974 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1975 | |
| 1976 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1977 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1978 | pipeline_layout_ci.pNext = NULL; |
| 1979 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 1980 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1981 | |
| 1982 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1983 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1984 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1985 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1986 | // Create pipelineLayout with only one setLayout |
| 1987 | pipeline_layout_ci.setLayoutCount = 1; |
| 1988 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1989 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1990 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1991 | ASSERT_VK_SUCCESS(err); |
| 1992 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 1993 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 1994 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1995 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1996 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1997 | ASSERT_VK_SUCCESS(err); |
| 1998 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 1999 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 2000 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2001 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2002 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2003 | ASSERT_VK_SUCCESS(err); |
| 2004 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 2005 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 2006 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2007 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2008 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2009 | ASSERT_VK_SUCCESS(err); |
| 2010 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 2011 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 2012 | pl_bad_s0[0] = ds_layout_fs_only; |
| 2013 | pl_bad_s0[1] = ds_layout[1]; |
| 2014 | pipeline_layout_ci.setLayoutCount = 2; |
| 2015 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 2016 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2017 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2018 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2019 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2020 | |
| 2021 | // Create a buffer to update the descriptor with |
| 2022 | uint32_t qfi = 0; |
| 2023 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2024 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2025 | buffCI.size = 1024; |
| 2026 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 2027 | buffCI.queueFamilyIndexCount = 1; |
| 2028 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2029 | |
| 2030 | VkBuffer dyub; |
| 2031 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 2032 | ASSERT_VK_SUCCESS(err); |
| 2033 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 2034 | static const uint32_t NUM_BUFFS = 5; |
| 2035 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2036 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2037 | buffInfo[i].buffer = dyub; |
| 2038 | buffInfo[i].offset = 0; |
| 2039 | buffInfo[i].range = 1024; |
| 2040 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2041 | VkImage image; |
| 2042 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2043 | const int32_t tex_width = 32; |
| 2044 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2045 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2046 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2047 | image_create_info.pNext = NULL; |
| 2048 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2049 | image_create_info.format = tex_format; |
| 2050 | image_create_info.extent.width = tex_width; |
| 2051 | image_create_info.extent.height = tex_height; |
| 2052 | image_create_info.extent.depth = 1; |
| 2053 | image_create_info.mipLevels = 1; |
| 2054 | image_create_info.arrayLayers = 1; |
| 2055 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2056 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2057 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2058 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2059 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 2060 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2061 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2062 | VkMemoryRequirements memReqs; |
| 2063 | VkDeviceMemory imageMem; |
| 2064 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2065 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2066 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2067 | memAlloc.pNext = NULL; |
| 2068 | memAlloc.allocationSize = 0; |
| 2069 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2070 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 2071 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2072 | pass = |
| 2073 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 2074 | ASSERT_TRUE(pass); |
| 2075 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 2076 | ASSERT_VK_SUCCESS(err); |
| 2077 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 2078 | ASSERT_VK_SUCCESS(err); |
| 2079 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2080 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2081 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2082 | image_view_create_info.image = image; |
| 2083 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2084 | image_view_create_info.format = tex_format; |
| 2085 | image_view_create_info.subresourceRange.layerCount = 1; |
| 2086 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 2087 | image_view_create_info.subresourceRange.levelCount = 1; |
| 2088 | image_view_create_info.subresourceRange.aspectMask = |
| 2089 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2090 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2091 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2092 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 2093 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2094 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2095 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2096 | imageInfo[0].imageView = view; |
| 2097 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2098 | imageInfo[1].imageView = view; |
| 2099 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2100 | imageInfo[2].imageView = view; |
| 2101 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2102 | imageInfo[3].imageView = view; |
| 2103 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2104 | |
| 2105 | static const uint32_t NUM_SET_UPDATES = 3; |
| 2106 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 2107 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2108 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 2109 | descriptor_write[0].dstBinding = 0; |
| 2110 | descriptor_write[0].descriptorCount = 5; |
| 2111 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2112 | descriptor_write[0].pBufferInfo = buffInfo; |
| 2113 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2114 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 2115 | descriptor_write[1].dstBinding = 0; |
| 2116 | descriptor_write[1].descriptorCount = 2; |
| 2117 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 2118 | descriptor_write[1].pImageInfo = imageInfo; |
| 2119 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2120 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 2121 | descriptor_write[2].dstBinding = 1; |
| 2122 | descriptor_write[2].descriptorCount = 2; |
| 2123 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2124 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2125 | |
| 2126 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2127 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2128 | // Create PSO to be used for draw-time errors below |
| 2129 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 2130 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2131 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2132 | "out gl_PerVertex {\n" |
| 2133 | " vec4 gl_Position;\n" |
| 2134 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2135 | "void main(){\n" |
| 2136 | " gl_Position = vec4(1);\n" |
| 2137 | "}\n"; |
| 2138 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 2139 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2140 | "\n" |
| 2141 | "layout(location=0) out vec4 x;\n" |
| 2142 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 2143 | "void main(){\n" |
| 2144 | " x = vec4(bar.y);\n" |
| 2145 | "}\n"; |
| 2146 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2147 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2148 | VkPipelineObj pipe(m_device); |
| 2149 | pipe.AddShader(&vs); |
| 2150 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2151 | pipe.AddColorAttachment(); |
| 2152 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2153 | |
| 2154 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2155 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2156 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2157 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2158 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 2159 | // of PSO |
| 2160 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 2161 | // cmd_pipeline.c |
| 2162 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 2163 | // cmd_bind_graphics_pipeline() |
| 2164 | // TODO : Want to cause various binding incompatibility issues here to test |
| 2165 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2166 | // First cause various verify_layout_compatibility() fails |
| 2167 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2168 | // verify_set_layout_compatibility fail cases: |
| 2169 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2170 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2171 | " due to: invalid VkPipelineLayout "); |
| 2172 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2173 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2174 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 2175 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2176 | m_errorMonitor->VerifyFound(); |
| 2177 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2178 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2179 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2180 | " attempting to bind set to index 1"); |
| 2181 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2182 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 2183 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2184 | m_errorMonitor->VerifyFound(); |
| 2185 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2186 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2187 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 2188 | // descriptors |
| 2189 | m_errorMonitor->SetDesiredFailureMsg( |
| 2190 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2191 | ", but corresponding set being bound has 5 descriptors."); |
| 2192 | vkCmdBindDescriptorSets( |
| 2193 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2194 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2195 | m_errorMonitor->VerifyFound(); |
| 2196 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2197 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 2198 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2199 | m_errorMonitor->SetDesiredFailureMsg( |
| 2200 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2201 | " descriptor from pipelineLayout is type 'VK_DESCRIPTOR_TYPE_SAMPLER'"); |
| 2202 | vkCmdBindDescriptorSets( |
| 2203 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2204 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2205 | m_errorMonitor->VerifyFound(); |
| 2206 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2207 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 2208 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2209 | m_errorMonitor->SetDesiredFailureMsg( |
| 2210 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2211 | " descriptor from pipelineLayout has stageFlags "); |
| 2212 | vkCmdBindDescriptorSets( |
| 2213 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2214 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2215 | m_errorMonitor->VerifyFound(); |
| 2216 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2217 | // Cause INFO messages due to disturbing previously bound Sets |
| 2218 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2219 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2220 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2221 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2222 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2223 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2224 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2225 | " previously bound as set #0 was disturbed "); |
| 2226 | vkCmdBindDescriptorSets( |
| 2227 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2228 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2229 | m_errorMonitor->VerifyFound(); |
| 2230 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2231 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2232 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2233 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2234 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2235 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2236 | " newly bound as set #0 so set #1 and " |
| 2237 | "any subsequent sets were disturbed "); |
| 2238 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2239 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2240 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2241 | m_errorMonitor->VerifyFound(); |
| 2242 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2243 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2244 | // 1. Error due to not binding required set (we actually use same code as |
| 2245 | // above to disturb set0) |
| 2246 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2247 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2248 | 2, &descriptorSet[0], 0, NULL); |
| 2249 | vkCmdBindDescriptorSets( |
| 2250 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2251 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 2252 | m_errorMonitor->SetDesiredFailureMsg( |
| 2253 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2254 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2255 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2256 | m_errorMonitor->VerifyFound(); |
| 2257 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 2258 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2259 | // 2. Error due to bound set not being compatible with PSO's |
| 2260 | // VkPipelineLayout (diff stageFlags in this case) |
| 2261 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2262 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2263 | 2, &descriptorSet[0], 0, NULL); |
| 2264 | m_errorMonitor->SetDesiredFailureMsg( |
| 2265 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2266 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2267 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2268 | m_errorMonitor->VerifyFound(); |
| 2269 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2270 | // Remaining clean-up |
| 2271 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2272 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2273 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 2274 | } |
| 2275 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
| 2276 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, descriptorSet); |
| 2277 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2278 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2279 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2280 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2281 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2282 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2283 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2284 | m_errorMonitor->SetDesiredFailureMsg( |
| 2285 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2286 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2287 | |
| 2288 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2289 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2290 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2291 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2292 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2293 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2294 | } |
| 2295 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2296 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 2297 | VkResult err; |
| 2298 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2299 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2300 | m_errorMonitor->SetDesiredFailureMsg( |
| 2301 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 2302 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2303 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2304 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2305 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2306 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2307 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2308 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2309 | cmd.commandPool = m_commandPool; |
| 2310 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2311 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2312 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2313 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2314 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2315 | |
| 2316 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2317 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2318 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2319 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2320 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2321 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 2322 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2323 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2324 | |
| 2325 | // The error should be caught by validation of the BeginCommandBuffer call |
| 2326 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 2327 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2328 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2329 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2330 | } |
| 2331 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2332 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2333 | // Cause error due to Begin while recording CB |
| 2334 | // Then cause 2 errors for attempting to reset CB w/o having |
| 2335 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 2336 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2337 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2338 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2339 | |
| 2340 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2341 | |
| 2342 | // Calls AllocateCommandBuffers |
| 2343 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 2344 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2345 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 2346 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2347 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2348 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2349 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2350 | cmd_buf_info.pNext = NULL; |
| 2351 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2352 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2353 | |
| 2354 | // Begin CB to transition to recording state |
| 2355 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2356 | // Can't re-begin. This should trigger error |
| 2357 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2358 | m_errorMonitor->VerifyFound(); |
| 2359 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2360 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2361 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2362 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 2363 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 2364 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2365 | m_errorMonitor->VerifyFound(); |
| 2366 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2367 | m_errorMonitor->SetDesiredFailureMsg( |
| 2368 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2369 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2370 | // Transition CB to RECORDED state |
| 2371 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 2372 | // Now attempting to Begin will implicitly reset, which triggers error |
| 2373 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2374 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2375 | } |
| 2376 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2377 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2378 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2379 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2380 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2381 | m_errorMonitor->SetDesiredFailureMsg( |
| 2382 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2383 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 2384 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2385 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2386 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2387 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2388 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2389 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2390 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2391 | |
| 2392 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2393 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2394 | ds_pool_ci.pNext = NULL; |
| 2395 | ds_pool_ci.maxSets = 1; |
| 2396 | ds_pool_ci.poolSizeCount = 1; |
| 2397 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2398 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2399 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2400 | err = |
| 2401 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2402 | ASSERT_VK_SUCCESS(err); |
| 2403 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2404 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2405 | dsl_binding.binding = 0; |
| 2406 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2407 | dsl_binding.descriptorCount = 1; |
| 2408 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2409 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2410 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2411 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2412 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2413 | ds_layout_ci.pNext = NULL; |
| 2414 | ds_layout_ci.bindingCount = 1; |
| 2415 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2416 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2417 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2418 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2419 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2420 | ASSERT_VK_SUCCESS(err); |
| 2421 | |
| 2422 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2423 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2424 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2425 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2426 | alloc_info.descriptorPool = ds_pool; |
| 2427 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2428 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2429 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2430 | ASSERT_VK_SUCCESS(err); |
| 2431 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2432 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2433 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2434 | pipeline_layout_ci.setLayoutCount = 1; |
| 2435 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2436 | |
| 2437 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2438 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2439 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2440 | ASSERT_VK_SUCCESS(err); |
| 2441 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2442 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2443 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2444 | |
| 2445 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2446 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2447 | vp_state_ci.scissorCount = 1; |
| 2448 | vp_state_ci.pScissors = ≻ |
| 2449 | vp_state_ci.viewportCount = 1; |
| 2450 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2451 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2452 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 2453 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 2454 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 2455 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 2456 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 2457 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 2458 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 2459 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 2460 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2461 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2462 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2463 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2464 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2465 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2466 | gp_ci.layout = pipeline_layout; |
| 2467 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2468 | |
| 2469 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2470 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2471 | pc_ci.initialDataSize = 0; |
| 2472 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2473 | |
| 2474 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2475 | VkPipelineCache pipelineCache; |
| 2476 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2477 | err = |
| 2478 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2479 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2480 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2481 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2482 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2483 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2484 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2485 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2486 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2487 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2488 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2489 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2490 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 2491 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 2492 | { |
| 2493 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2494 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2495 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2496 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2497 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 2498 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2499 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2500 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2501 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2502 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2503 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2504 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2505 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2506 | |
| 2507 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2508 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2509 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2510 | ds_pool_ci.poolSizeCount = 1; |
| 2511 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2512 | |
| 2513 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2514 | err = vkCreateDescriptorPool(m_device->device(), |
| 2515 | 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] | 2516 | ASSERT_VK_SUCCESS(err); |
| 2517 | |
| 2518 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2519 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2520 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2521 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2522 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2523 | dsl_binding.pImmutableSamplers = NULL; |
| 2524 | |
| 2525 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2526 | ds_layout_ci.sType = |
| 2527 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2528 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2529 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 2530 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2531 | |
| 2532 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2533 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2534 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2535 | ASSERT_VK_SUCCESS(err); |
| 2536 | |
| 2537 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2538 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 2539 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2540 | ASSERT_VK_SUCCESS(err); |
| 2541 | |
| 2542 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2543 | pipeline_layout_ci.sType = |
| 2544 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2545 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2546 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2547 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2548 | |
| 2549 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2550 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2551 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2552 | ASSERT_VK_SUCCESS(err); |
| 2553 | |
| 2554 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 2555 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 2556 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2557 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 2558 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2559 | // 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] | 2560 | VkShaderObj |
| 2561 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 2562 | this); |
| 2563 | VkShaderObj |
| 2564 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 2565 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2566 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2567 | shaderStages[0].sType = |
| 2568 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2569 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2570 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2571 | shaderStages[1].sType = |
| 2572 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2573 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2574 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2575 | shaderStages[2].sType = |
| 2576 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2577 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2578 | shaderStages[2].shader = te.handle(); |
| 2579 | |
| 2580 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2581 | iaCI.sType = |
| 2582 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2583 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2584 | |
| 2585 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 2586 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 2587 | tsCI.patchControlPoints = 0; // This will cause an error |
| 2588 | |
| 2589 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2590 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2591 | gp_ci.pNext = NULL; |
| 2592 | gp_ci.stageCount = 3; |
| 2593 | gp_ci.pStages = shaderStages; |
| 2594 | gp_ci.pVertexInputState = NULL; |
| 2595 | gp_ci.pInputAssemblyState = &iaCI; |
| 2596 | gp_ci.pTessellationState = &tsCI; |
| 2597 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2598 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2599 | gp_ci.pMultisampleState = NULL; |
| 2600 | gp_ci.pDepthStencilState = NULL; |
| 2601 | gp_ci.pColorBlendState = NULL; |
| 2602 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2603 | gp_ci.layout = pipeline_layout; |
| 2604 | gp_ci.renderPass = renderPass(); |
| 2605 | |
| 2606 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2607 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2608 | pc_ci.pNext = NULL; |
| 2609 | pc_ci.initialSize = 0; |
| 2610 | pc_ci.initialData = 0; |
| 2611 | pc_ci.maxSize = 0; |
| 2612 | |
| 2613 | VkPipeline pipeline; |
| 2614 | VkPipelineCache pipelineCache; |
| 2615 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2616 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 2617 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2618 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2619 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2620 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2621 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2622 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2623 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2624 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2625 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2626 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2627 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2628 | } |
| 2629 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2630 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2631 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2632 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2633 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2634 | m_errorMonitor->SetDesiredFailureMsg( |
| 2635 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2636 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2637 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2638 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2639 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2640 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2641 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2642 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2643 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2644 | |
| 2645 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2646 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2647 | ds_pool_ci.maxSets = 1; |
| 2648 | ds_pool_ci.poolSizeCount = 1; |
| 2649 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2650 | |
| 2651 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2652 | err = |
| 2653 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2654 | ASSERT_VK_SUCCESS(err); |
| 2655 | |
| 2656 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2657 | dsl_binding.binding = 0; |
| 2658 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2659 | dsl_binding.descriptorCount = 1; |
| 2660 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2661 | |
| 2662 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2663 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2664 | ds_layout_ci.bindingCount = 1; |
| 2665 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2666 | |
| 2667 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2668 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2669 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2670 | ASSERT_VK_SUCCESS(err); |
| 2671 | |
| 2672 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2673 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2674 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2675 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2676 | alloc_info.descriptorPool = ds_pool; |
| 2677 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2678 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2679 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2680 | ASSERT_VK_SUCCESS(err); |
| 2681 | |
| 2682 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2683 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2684 | pipeline_layout_ci.setLayoutCount = 1; |
| 2685 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2686 | |
| 2687 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2688 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2689 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2690 | ASSERT_VK_SUCCESS(err); |
| 2691 | |
| 2692 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2693 | |
| 2694 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2695 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2696 | vp_state_ci.scissorCount = 0; |
| 2697 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2698 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2699 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2700 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 2701 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 2702 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 2703 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 2704 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 2705 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 2706 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 2707 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 2708 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2709 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2710 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2711 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2712 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 2713 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2714 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 2715 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2716 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2717 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2718 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2719 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2720 | |
| 2721 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2722 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2723 | gp_ci.stageCount = 2; |
| 2724 | gp_ci.pStages = shaderStages; |
| 2725 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2726 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2727 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2728 | gp_ci.layout = pipeline_layout; |
| 2729 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2730 | |
| 2731 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2732 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2733 | |
| 2734 | VkPipeline pipeline; |
| 2735 | VkPipelineCache pipelineCache; |
| 2736 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2737 | err = |
| 2738 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2739 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2740 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2741 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2742 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2743 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2744 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2745 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2746 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2747 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2748 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2749 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2750 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 2751 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2752 | // 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] | 2753 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2754 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2755 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2756 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2757 | m_errorMonitor->SetDesiredFailureMsg( |
| 2758 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2759 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2760 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2761 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2762 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2763 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2764 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2765 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2766 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2767 | |
| 2768 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2769 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2770 | ds_pool_ci.maxSets = 1; |
| 2771 | ds_pool_ci.poolSizeCount = 1; |
| 2772 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2773 | |
| 2774 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2775 | err = |
| 2776 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2777 | ASSERT_VK_SUCCESS(err); |
| 2778 | |
| 2779 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2780 | dsl_binding.binding = 0; |
| 2781 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2782 | dsl_binding.descriptorCount = 1; |
| 2783 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2784 | |
| 2785 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2786 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2787 | ds_layout_ci.bindingCount = 1; |
| 2788 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2789 | |
| 2790 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2791 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2792 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2793 | ASSERT_VK_SUCCESS(err); |
| 2794 | |
| 2795 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2796 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2797 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2798 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2799 | alloc_info.descriptorPool = ds_pool; |
| 2800 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2801 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2802 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2803 | ASSERT_VK_SUCCESS(err); |
| 2804 | |
| 2805 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2806 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2807 | pipeline_layout_ci.setLayoutCount = 1; |
| 2808 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2809 | |
| 2810 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2811 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2812 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2813 | ASSERT_VK_SUCCESS(err); |
| 2814 | |
| 2815 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2816 | // Set scissor as dynamic to avoid second error |
| 2817 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2818 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2819 | dyn_state_ci.dynamicStateCount = 1; |
| 2820 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2821 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2822 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2823 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2824 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2825 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 2826 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2827 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 2828 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2829 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2830 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2831 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2832 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2833 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2834 | |
| 2835 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 2836 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 2837 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 2838 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 2839 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 2840 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 2841 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 2842 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 2843 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2844 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2845 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2846 | gp_ci.stageCount = 2; |
| 2847 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 2848 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2849 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 2850 | // should cause validation error |
| 2851 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2852 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2853 | gp_ci.layout = pipeline_layout; |
| 2854 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2855 | |
| 2856 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2857 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2858 | |
| 2859 | VkPipeline pipeline; |
| 2860 | VkPipelineCache pipelineCache; |
| 2861 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2862 | err = |
| 2863 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2864 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2865 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 2866 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2867 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2868 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2869 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2870 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2871 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2872 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2873 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2874 | } |
| 2875 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2876 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 2877 | // count |
| 2878 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 2879 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2880 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2881 | m_errorMonitor->SetDesiredFailureMsg( |
| 2882 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2883 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 2884 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2885 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2886 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2887 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2888 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2889 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2890 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2891 | |
| 2892 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2893 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2894 | ds_pool_ci.maxSets = 1; |
| 2895 | ds_pool_ci.poolSizeCount = 1; |
| 2896 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2897 | |
| 2898 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2899 | err = |
| 2900 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2901 | ASSERT_VK_SUCCESS(err); |
| 2902 | |
| 2903 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2904 | dsl_binding.binding = 0; |
| 2905 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2906 | dsl_binding.descriptorCount = 1; |
| 2907 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2908 | |
| 2909 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2910 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2911 | ds_layout_ci.bindingCount = 1; |
| 2912 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2913 | |
| 2914 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2915 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2916 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2917 | ASSERT_VK_SUCCESS(err); |
| 2918 | |
| 2919 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2920 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2921 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2922 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2923 | alloc_info.descriptorPool = ds_pool; |
| 2924 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2925 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2926 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2927 | ASSERT_VK_SUCCESS(err); |
| 2928 | |
| 2929 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2930 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2931 | pipeline_layout_ci.setLayoutCount = 1; |
| 2932 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2933 | |
| 2934 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2935 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2936 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2937 | ASSERT_VK_SUCCESS(err); |
| 2938 | |
| 2939 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2940 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2941 | vp_state_ci.viewportCount = 1; |
| 2942 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2943 | vp_state_ci.scissorCount = 1; |
| 2944 | vp_state_ci.pScissors = |
| 2945 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2946 | |
| 2947 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2948 | // Set scissor as dynamic to avoid that error |
| 2949 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2950 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2951 | dyn_state_ci.dynamicStateCount = 1; |
| 2952 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2953 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2954 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2955 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2956 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2957 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 2958 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2959 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 2960 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2961 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2962 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2963 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2964 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2965 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2966 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2967 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2968 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2969 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2970 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2971 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2972 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2973 | |
| 2974 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2975 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2976 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2977 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2978 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2979 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2980 | rs_ci.pNext = nullptr; |
| 2981 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 2982 | VkPipelineColorBlendAttachmentState att = {}; |
| 2983 | att.blendEnable = VK_FALSE; |
| 2984 | att.colorWriteMask = 0xf; |
| 2985 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2986 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2987 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2988 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 2989 | cb_ci.attachmentCount = 1; |
| 2990 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2991 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2992 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2993 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2994 | gp_ci.stageCount = 2; |
| 2995 | gp_ci.pStages = shaderStages; |
| 2996 | gp_ci.pVertexInputState = &vi_ci; |
| 2997 | gp_ci.pInputAssemblyState = &ia_ci; |
| 2998 | gp_ci.pViewportState = &vp_state_ci; |
| 2999 | gp_ci.pRasterizationState = &rs_ci; |
| 3000 | gp_ci.pColorBlendState = &cb_ci; |
| 3001 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3002 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3003 | gp_ci.layout = pipeline_layout; |
| 3004 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3005 | |
| 3006 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3007 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3008 | |
| 3009 | VkPipeline pipeline; |
| 3010 | VkPipelineCache pipelineCache; |
| 3011 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3012 | err = |
| 3013 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3014 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3015 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3016 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3017 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3018 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3019 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3020 | // 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] | 3021 | // First need to successfully create the PSO from above by setting |
| 3022 | // pViewports |
| 3023 | m_errorMonitor->SetDesiredFailureMsg( |
| 3024 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3025 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 3026 | "scissorCount is 1. These counts must match."); |
| 3027 | |
| 3028 | VkViewport vp = {}; // Just need dummy vp to point to |
| 3029 | vp_state_ci.pViewports = &vp; |
| 3030 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3031 | &gp_ci, NULL, &pipeline); |
| 3032 | ASSERT_VK_SUCCESS(err); |
| 3033 | BeginCommandBuffer(); |
| 3034 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3035 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 3036 | VkRect2D scissors[2] = {}; // don't care about data |
| 3037 | // Count of 2 doesn't match PSO count of 1 |
| 3038 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 3039 | Draw(1, 0, 0, 0); |
| 3040 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3041 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3042 | |
| 3043 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3044 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3045 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3046 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3047 | } |
| 3048 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 3049 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 3050 | // viewportCount |
| 3051 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 3052 | VkResult err; |
| 3053 | |
| 3054 | m_errorMonitor->SetDesiredFailureMsg( |
| 3055 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3056 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 3057 | |
| 3058 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3059 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3060 | |
| 3061 | VkDescriptorPoolSize ds_type_count = {}; |
| 3062 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3063 | ds_type_count.descriptorCount = 1; |
| 3064 | |
| 3065 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3066 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3067 | ds_pool_ci.maxSets = 1; |
| 3068 | ds_pool_ci.poolSizeCount = 1; |
| 3069 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 3070 | |
| 3071 | VkDescriptorPool ds_pool; |
| 3072 | err = |
| 3073 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 3074 | ASSERT_VK_SUCCESS(err); |
| 3075 | |
| 3076 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3077 | dsl_binding.binding = 0; |
| 3078 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3079 | dsl_binding.descriptorCount = 1; |
| 3080 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3081 | |
| 3082 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3083 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3084 | ds_layout_ci.bindingCount = 1; |
| 3085 | ds_layout_ci.pBindings = &dsl_binding; |
| 3086 | |
| 3087 | VkDescriptorSetLayout ds_layout; |
| 3088 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3089 | &ds_layout); |
| 3090 | ASSERT_VK_SUCCESS(err); |
| 3091 | |
| 3092 | VkDescriptorSet descriptorSet; |
| 3093 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 3094 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 3095 | alloc_info.descriptorSetCount = 1; |
| 3096 | alloc_info.descriptorPool = ds_pool; |
| 3097 | alloc_info.pSetLayouts = &ds_layout; |
| 3098 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3099 | &descriptorSet); |
| 3100 | ASSERT_VK_SUCCESS(err); |
| 3101 | |
| 3102 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3103 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3104 | pipeline_layout_ci.setLayoutCount = 1; |
| 3105 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3106 | |
| 3107 | VkPipelineLayout pipeline_layout; |
| 3108 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3109 | &pipeline_layout); |
| 3110 | ASSERT_VK_SUCCESS(err); |
| 3111 | |
| 3112 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 3113 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3114 | vp_state_ci.scissorCount = 1; |
| 3115 | vp_state_ci.pScissors = |
| 3116 | NULL; // Null scissor w/ count of 1 should cause error |
| 3117 | vp_state_ci.viewportCount = 1; |
| 3118 | vp_state_ci.pViewports = |
| 3119 | NULL; // vp is dynamic (below) so this won't cause error |
| 3120 | |
| 3121 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 3122 | // Set scissor as dynamic to avoid that error |
| 3123 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 3124 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3125 | dyn_state_ci.dynamicStateCount = 1; |
| 3126 | dyn_state_ci.pDynamicStates = &vp_state; |
| 3127 | |
| 3128 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 3129 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 3130 | |
| 3131 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3132 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3133 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3134 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3135 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3136 | // but add it to be able to run on more devices |
| 3137 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3138 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 3139 | |
| 3140 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 3141 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 3142 | vi_ci.pNext = nullptr; |
| 3143 | vi_ci.vertexBindingDescriptionCount = 0; |
| 3144 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 3145 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 3146 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 3147 | |
| 3148 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 3149 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 3150 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 3151 | |
| 3152 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 3153 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3154 | rs_ci.pNext = nullptr; |
| 3155 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3156 | VkPipelineColorBlendAttachmentState att = {}; |
| 3157 | att.blendEnable = VK_FALSE; |
| 3158 | att.colorWriteMask = 0xf; |
| 3159 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3160 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 3161 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 3162 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3163 | cb_ci.attachmentCount = 1; |
| 3164 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3165 | |
| 3166 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 3167 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3168 | gp_ci.stageCount = 2; |
| 3169 | gp_ci.pStages = shaderStages; |
| 3170 | gp_ci.pVertexInputState = &vi_ci; |
| 3171 | gp_ci.pInputAssemblyState = &ia_ci; |
| 3172 | gp_ci.pViewportState = &vp_state_ci; |
| 3173 | gp_ci.pRasterizationState = &rs_ci; |
| 3174 | gp_ci.pColorBlendState = &cb_ci; |
| 3175 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3176 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3177 | gp_ci.layout = pipeline_layout; |
| 3178 | gp_ci.renderPass = renderPass(); |
| 3179 | |
| 3180 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 3181 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3182 | |
| 3183 | VkPipeline pipeline; |
| 3184 | VkPipelineCache pipelineCache; |
| 3185 | |
| 3186 | err = |
| 3187 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 3188 | ASSERT_VK_SUCCESS(err); |
| 3189 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3190 | &gp_ci, NULL, &pipeline); |
| 3191 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3192 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3193 | |
| 3194 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 3195 | // First need to successfully create the PSO from above by setting |
| 3196 | // pViewports |
| 3197 | m_errorMonitor->SetDesiredFailureMsg( |
| 3198 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3199 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 3200 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3201 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3202 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 3203 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3204 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3205 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3206 | ASSERT_VK_SUCCESS(err); |
| 3207 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3208 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3209 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3210 | VkViewport viewports[2] = {}; // don't care about data |
| 3211 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 3212 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3213 | Draw(1, 0, 0, 0); |
| 3214 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3215 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3216 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3217 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3218 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3219 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3220 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3221 | } |
| 3222 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3223 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3224 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3225 | m_errorMonitor->SetDesiredFailureMsg( |
| 3226 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3227 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3228 | |
| 3229 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3230 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3231 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3232 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3233 | // Don't care about RenderPass handle b/c error should be flagged before |
| 3234 | // that |
| 3235 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 3236 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3237 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3238 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3239 | } |
| 3240 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3241 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3242 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3243 | m_errorMonitor->SetDesiredFailureMsg( |
| 3244 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3245 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3246 | |
| 3247 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3248 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3249 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3250 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3251 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 3252 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3253 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3254 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 3255 | rp_begin.pNext = NULL; |
| 3256 | rp_begin.renderPass = renderPass(); |
| 3257 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3258 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3259 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 3260 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3261 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3262 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3263 | } |
| 3264 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3265 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3266 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3267 | m_errorMonitor->SetDesiredFailureMsg( |
| 3268 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3269 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3270 | |
| 3271 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3272 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3273 | |
| 3274 | // Renderpass is started here |
| 3275 | BeginCommandBuffer(); |
| 3276 | |
| 3277 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3278 | vk_testing::Buffer dstBuffer; |
| 3279 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3280 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3281 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3282 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3283 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3284 | } |
| 3285 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3286 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3287 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3288 | m_errorMonitor->SetDesiredFailureMsg( |
| 3289 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3290 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3291 | |
| 3292 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3293 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3294 | |
| 3295 | // Renderpass is started here |
| 3296 | BeginCommandBuffer(); |
| 3297 | |
| 3298 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3299 | vk_testing::Buffer dstBuffer; |
| 3300 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3301 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3302 | VkDeviceSize dstOffset = 0; |
| 3303 | VkDeviceSize dataSize = 1024; |
| 3304 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3305 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3306 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 3307 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3308 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3309 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3310 | } |
| 3311 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3312 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3313 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3314 | m_errorMonitor->SetDesiredFailureMsg( |
| 3315 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3316 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3317 | |
| 3318 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3319 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3320 | |
| 3321 | // Renderpass is started here |
| 3322 | BeginCommandBuffer(); |
| 3323 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 3324 | VkClearColorValue clear_color; |
| 3325 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3326 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 3327 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3328 | const int32_t tex_width = 32; |
| 3329 | const int32_t tex_height = 32; |
| 3330 | VkImageCreateInfo image_create_info = {}; |
| 3331 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3332 | image_create_info.pNext = NULL; |
| 3333 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3334 | image_create_info.format = tex_format; |
| 3335 | image_create_info.extent.width = tex_width; |
| 3336 | image_create_info.extent.height = tex_height; |
| 3337 | image_create_info.extent.depth = 1; |
| 3338 | image_create_info.mipLevels = 1; |
| 3339 | image_create_info.arrayLayers = 1; |
| 3340 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3341 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3342 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3343 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3344 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3345 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 3346 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3347 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3348 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 3349 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3350 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3351 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 3352 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3353 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3354 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3355 | } |
| 3356 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3357 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3358 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3359 | m_errorMonitor->SetDesiredFailureMsg( |
| 3360 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3361 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3362 | |
| 3363 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3364 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3365 | |
| 3366 | // Renderpass is started here |
| 3367 | BeginCommandBuffer(); |
| 3368 | |
| 3369 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 3370 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3371 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 3372 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3373 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3374 | image_create_info.extent.width = 64; |
| 3375 | image_create_info.extent.height = 64; |
| 3376 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3377 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3378 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3379 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3380 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 3381 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3382 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3383 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 3384 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3385 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3386 | vkCmdClearDepthStencilImage( |
| 3387 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 3388 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 3389 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3390 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3391 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3392 | } |
| 3393 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3394 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3395 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3396 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3397 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3398 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3399 | "vkCmdClearAttachments: This call " |
| 3400 | "must be issued inside an active " |
| 3401 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3402 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3403 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3404 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3405 | |
| 3406 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3407 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3408 | ASSERT_VK_SUCCESS(err); |
| 3409 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3410 | VkClearAttachment color_attachment; |
| 3411 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3412 | color_attachment.clearValue.color.float32[0] = 0; |
| 3413 | color_attachment.clearValue.color.float32[1] = 0; |
| 3414 | color_attachment.clearValue.color.float32[2] = 0; |
| 3415 | color_attachment.clearValue.color.float32[3] = 0; |
| 3416 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3417 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 3418 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 3419 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3420 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3421 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3422 | } |
| 3423 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3424 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3425 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3426 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3427 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3428 | m_errorMonitor->SetDesiredFailureMsg( |
| 3429 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3430 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 3431 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3432 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3433 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3434 | uint32_t qfi = 0; |
| 3435 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3436 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3437 | buffCI.size = 1024; |
| 3438 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 3439 | buffCI.queueFamilyIndexCount = 1; |
| 3440 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3441 | |
| 3442 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3443 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3444 | ASSERT_VK_SUCCESS(err); |
| 3445 | |
| 3446 | BeginCommandBuffer(); |
| 3447 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3448 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3449 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3450 | // 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] | 3451 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 3452 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3453 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3454 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3455 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3456 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3457 | } |
| 3458 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3459 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 3460 | // Create an out-of-range queueFamilyIndex |
| 3461 | m_errorMonitor->SetDesiredFailureMsg( |
| 3462 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 3463 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3464 | |
| 3465 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3466 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3467 | VkBufferCreateInfo buffCI = {}; |
| 3468 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3469 | buffCI.size = 1024; |
| 3470 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 3471 | buffCI.queueFamilyIndexCount = 1; |
| 3472 | // Introduce failure by specifying invalid queue_family_index |
| 3473 | uint32_t qfi = 777; |
| 3474 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 3475 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3476 | |
| 3477 | VkBuffer ib; |
| 3478 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 3479 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3480 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 3481 | } |
| 3482 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3483 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 3484 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 3485 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3486 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3487 | m_errorMonitor->SetDesiredFailureMsg( |
| 3488 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3489 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3490 | |
| 3491 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3492 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3493 | |
| 3494 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3495 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3496 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 3497 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3498 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3499 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3500 | } |
| 3501 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3502 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3503 | // 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] | 3504 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3505 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3506 | m_errorMonitor->SetDesiredFailureMsg( |
| 3507 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Write descriptor update has descriptor " |
| 3508 | "type VK_DESCRIPTOR_TYPE_SAMPLER that " |
| 3509 | "does not match "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3510 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3511 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3512 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3513 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3514 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3515 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3516 | |
| 3517 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3518 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3519 | ds_pool_ci.pNext = NULL; |
| 3520 | ds_pool_ci.maxSets = 1; |
| 3521 | ds_pool_ci.poolSizeCount = 1; |
| 3522 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3523 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3524 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3525 | err = |
| 3526 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3527 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3528 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3529 | dsl_binding.binding = 0; |
| 3530 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3531 | dsl_binding.descriptorCount = 1; |
| 3532 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3533 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3534 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3535 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3536 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3537 | ds_layout_ci.pNext = NULL; |
| 3538 | ds_layout_ci.bindingCount = 1; |
| 3539 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3540 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3541 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3542 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3543 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3544 | ASSERT_VK_SUCCESS(err); |
| 3545 | |
| 3546 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3547 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3548 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3549 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3550 | alloc_info.descriptorPool = ds_pool; |
| 3551 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3552 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3553 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3554 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3555 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3556 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3557 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3558 | sampler_ci.pNext = NULL; |
| 3559 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3560 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3561 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3562 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3563 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3564 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3565 | sampler_ci.mipLodBias = 1.0; |
| 3566 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3567 | sampler_ci.maxAnisotropy = 1; |
| 3568 | sampler_ci.compareEnable = VK_FALSE; |
| 3569 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3570 | sampler_ci.minLod = 1.0; |
| 3571 | sampler_ci.maxLod = 1.0; |
| 3572 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3573 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3574 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3575 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3576 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3577 | ASSERT_VK_SUCCESS(err); |
| 3578 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3579 | VkDescriptorImageInfo info = {}; |
| 3580 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3581 | |
| 3582 | VkWriteDescriptorSet descriptor_write; |
| 3583 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3584 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3585 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3586 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3587 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3588 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3589 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3590 | |
| 3591 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3592 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3593 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3594 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3595 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3596 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3597 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3598 | } |
| 3599 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3600 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3601 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3602 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3603 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3604 | m_errorMonitor->SetDesiredFailureMsg( |
| 3605 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Descriptor update type of " |
| 3606 | "VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET " |
| 3607 | "is out of bounds for matching binding"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3608 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3609 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3610 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3611 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3612 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3613 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3614 | |
| 3615 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3616 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3617 | ds_pool_ci.pNext = NULL; |
| 3618 | ds_pool_ci.maxSets = 1; |
| 3619 | ds_pool_ci.poolSizeCount = 1; |
| 3620 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3621 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3622 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3623 | err = |
| 3624 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3625 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3626 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3627 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3628 | dsl_binding.binding = 0; |
| 3629 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3630 | dsl_binding.descriptorCount = 1; |
| 3631 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3632 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3633 | |
| 3634 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3635 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3636 | ds_layout_ci.pNext = NULL; |
| 3637 | ds_layout_ci.bindingCount = 1; |
| 3638 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3639 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3640 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3641 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3642 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3643 | ASSERT_VK_SUCCESS(err); |
| 3644 | |
| 3645 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3646 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3647 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3648 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3649 | alloc_info.descriptorPool = ds_pool; |
| 3650 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3651 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3652 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3653 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3654 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3655 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3656 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3657 | sampler_ci.pNext = NULL; |
| 3658 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3659 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3660 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3661 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3662 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3663 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3664 | sampler_ci.mipLodBias = 1.0; |
| 3665 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3666 | sampler_ci.maxAnisotropy = 1; |
| 3667 | sampler_ci.compareEnable = VK_FALSE; |
| 3668 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3669 | sampler_ci.minLod = 1.0; |
| 3670 | sampler_ci.maxLod = 1.0; |
| 3671 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3672 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3673 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3674 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3675 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3676 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3677 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3678 | VkDescriptorImageInfo info = {}; |
| 3679 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3680 | |
| 3681 | VkWriteDescriptorSet descriptor_write; |
| 3682 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3683 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3684 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3685 | descriptor_write.dstArrayElement = |
| 3686 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3687 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3688 | // 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] | 3689 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3690 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3691 | |
| 3692 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3693 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3694 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3695 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3696 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3697 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3698 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3699 | } |
| 3700 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3701 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 3702 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 3703 | // index 2 |
| 3704 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3705 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3706 | m_errorMonitor->SetDesiredFailureMsg( |
| 3707 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3708 | " does not have binding to match update binding "); |
| 3709 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3710 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3711 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3712 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3713 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3714 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3715 | |
| 3716 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3717 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3718 | ds_pool_ci.pNext = NULL; |
| 3719 | ds_pool_ci.maxSets = 1; |
| 3720 | ds_pool_ci.poolSizeCount = 1; |
| 3721 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3722 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3723 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3724 | err = |
| 3725 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3726 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3727 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3728 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3729 | dsl_binding.binding = 0; |
| 3730 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3731 | dsl_binding.descriptorCount = 1; |
| 3732 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3733 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3734 | |
| 3735 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3736 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3737 | ds_layout_ci.pNext = NULL; |
| 3738 | ds_layout_ci.bindingCount = 1; |
| 3739 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3740 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3741 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3742 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3743 | ASSERT_VK_SUCCESS(err); |
| 3744 | |
| 3745 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3746 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3747 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3748 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3749 | alloc_info.descriptorPool = ds_pool; |
| 3750 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3751 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3752 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3753 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3754 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3755 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3756 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3757 | sampler_ci.pNext = NULL; |
| 3758 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3759 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3760 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3761 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3762 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3763 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3764 | sampler_ci.mipLodBias = 1.0; |
| 3765 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3766 | sampler_ci.maxAnisotropy = 1; |
| 3767 | sampler_ci.compareEnable = VK_FALSE; |
| 3768 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3769 | sampler_ci.minLod = 1.0; |
| 3770 | sampler_ci.maxLod = 1.0; |
| 3771 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3772 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3773 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3774 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3775 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3776 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3777 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3778 | VkDescriptorImageInfo info = {}; |
| 3779 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3780 | |
| 3781 | VkWriteDescriptorSet descriptor_write; |
| 3782 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3783 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3784 | descriptor_write.dstSet = descriptorSet; |
| 3785 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3786 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3787 | // 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] | 3788 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3789 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3790 | |
| 3791 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3792 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3793 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3794 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3795 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3796 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3797 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3798 | } |
| 3799 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3800 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 3801 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 3802 | // types |
| 3803 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3804 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3805 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3806 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3807 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3808 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3809 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3810 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3811 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3812 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3813 | |
| 3814 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3815 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3816 | ds_pool_ci.pNext = NULL; |
| 3817 | ds_pool_ci.maxSets = 1; |
| 3818 | ds_pool_ci.poolSizeCount = 1; |
| 3819 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3820 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3821 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3822 | err = |
| 3823 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3824 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3825 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3826 | dsl_binding.binding = 0; |
| 3827 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3828 | dsl_binding.descriptorCount = 1; |
| 3829 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3830 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3831 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3832 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3833 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3834 | ds_layout_ci.pNext = NULL; |
| 3835 | ds_layout_ci.bindingCount = 1; |
| 3836 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3837 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3838 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3839 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3840 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3841 | ASSERT_VK_SUCCESS(err); |
| 3842 | |
| 3843 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3844 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3845 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3846 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3847 | alloc_info.descriptorPool = ds_pool; |
| 3848 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3849 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3850 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3851 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3852 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3853 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3854 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3855 | sampler_ci.pNext = NULL; |
| 3856 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3857 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3858 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 3859 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3860 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3861 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3862 | sampler_ci.mipLodBias = 1.0; |
| 3863 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 3864 | sampler_ci.maxAnisotropy = 1; |
| 3865 | sampler_ci.compareEnable = VK_FALSE; |
| 3866 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3867 | sampler_ci.minLod = 1.0; |
| 3868 | sampler_ci.maxLod = 1.0; |
| 3869 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3870 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3871 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3872 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3873 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3874 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3875 | VkDescriptorImageInfo info = {}; |
| 3876 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3877 | |
| 3878 | VkWriteDescriptorSet descriptor_write; |
| 3879 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3880 | descriptor_write.sType = |
| 3881 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3882 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3883 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3884 | // 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] | 3885 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3886 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3887 | |
| 3888 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3889 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3890 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3891 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3892 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3893 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3894 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3895 | } |
| 3896 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3897 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3898 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3899 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3900 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3901 | m_errorMonitor->SetDesiredFailureMsg( |
| 3902 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3903 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 3904 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3905 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3906 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 3907 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3908 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3909 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3910 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3911 | |
| 3912 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3913 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3914 | ds_pool_ci.pNext = NULL; |
| 3915 | ds_pool_ci.maxSets = 1; |
| 3916 | ds_pool_ci.poolSizeCount = 1; |
| 3917 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3918 | |
| 3919 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3920 | err = |
| 3921 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3922 | ASSERT_VK_SUCCESS(err); |
| 3923 | |
| 3924 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3925 | dsl_binding.binding = 0; |
| 3926 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3927 | dsl_binding.descriptorCount = 1; |
| 3928 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3929 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3930 | |
| 3931 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3932 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3933 | ds_layout_ci.pNext = NULL; |
| 3934 | ds_layout_ci.bindingCount = 1; |
| 3935 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3936 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3937 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3938 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3939 | ASSERT_VK_SUCCESS(err); |
| 3940 | |
| 3941 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3942 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3943 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3944 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3945 | alloc_info.descriptorPool = ds_pool; |
| 3946 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3947 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3948 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3949 | ASSERT_VK_SUCCESS(err); |
| 3950 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3951 | VkSampler sampler = |
| 3952 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3953 | |
| 3954 | VkDescriptorImageInfo descriptor_info; |
| 3955 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3956 | descriptor_info.sampler = sampler; |
| 3957 | |
| 3958 | VkWriteDescriptorSet descriptor_write; |
| 3959 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3960 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3961 | descriptor_write.dstSet = descriptorSet; |
| 3962 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3963 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3964 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3965 | descriptor_write.pImageInfo = &descriptor_info; |
| 3966 | |
| 3967 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3968 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3969 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3970 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3971 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3972 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3973 | } |
| 3974 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3975 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 3976 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 3977 | // imageView |
| 3978 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3979 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3980 | m_errorMonitor->SetDesiredFailureMsg( |
| 3981 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3982 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 3983 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3984 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3985 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3986 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3987 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3988 | |
| 3989 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3990 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3991 | ds_pool_ci.pNext = NULL; |
| 3992 | ds_pool_ci.maxSets = 1; |
| 3993 | ds_pool_ci.poolSizeCount = 1; |
| 3994 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3995 | |
| 3996 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3997 | err = |
| 3998 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3999 | ASSERT_VK_SUCCESS(err); |
| 4000 | |
| 4001 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4002 | dsl_binding.binding = 0; |
| 4003 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4004 | dsl_binding.descriptorCount = 1; |
| 4005 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4006 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4007 | |
| 4008 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4009 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4010 | ds_layout_ci.pNext = NULL; |
| 4011 | ds_layout_ci.bindingCount = 1; |
| 4012 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4013 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4014 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4015 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4016 | ASSERT_VK_SUCCESS(err); |
| 4017 | |
| 4018 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4019 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4020 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4021 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4022 | alloc_info.descriptorPool = ds_pool; |
| 4023 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4024 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4025 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4026 | ASSERT_VK_SUCCESS(err); |
| 4027 | |
| 4028 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4029 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4030 | sampler_ci.pNext = NULL; |
| 4031 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4032 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4033 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4034 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4035 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4036 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4037 | sampler_ci.mipLodBias = 1.0; |
| 4038 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4039 | sampler_ci.maxAnisotropy = 1; |
| 4040 | sampler_ci.compareEnable = VK_FALSE; |
| 4041 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4042 | sampler_ci.minLod = 1.0; |
| 4043 | sampler_ci.maxLod = 1.0; |
| 4044 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4045 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4046 | |
| 4047 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4048 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4049 | ASSERT_VK_SUCCESS(err); |
| 4050 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4051 | VkImageView view = |
| 4052 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4053 | |
| 4054 | VkDescriptorImageInfo descriptor_info; |
| 4055 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 4056 | descriptor_info.sampler = sampler; |
| 4057 | descriptor_info.imageView = view; |
| 4058 | |
| 4059 | VkWriteDescriptorSet descriptor_write; |
| 4060 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4061 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4062 | descriptor_write.dstSet = descriptorSet; |
| 4063 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4064 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4065 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 4066 | descriptor_write.pImageInfo = &descriptor_info; |
| 4067 | |
| 4068 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4069 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4070 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4071 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4072 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4073 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4074 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 4075 | } |
| 4076 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4077 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 4078 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 4079 | // into the other |
| 4080 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4081 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4082 | m_errorMonitor->SetDesiredFailureMsg( |
| 4083 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Copy descriptor update index 0, update " |
| 4084 | "count #1, has src update descriptor " |
| 4085 | "type VK_DESCRIPTOR_TYPE_SAMPLER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4086 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4087 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4088 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4089 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4090 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4091 | ds_type_count[0].descriptorCount = 1; |
| 4092 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4093 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4094 | |
| 4095 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4096 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4097 | ds_pool_ci.pNext = NULL; |
| 4098 | ds_pool_ci.maxSets = 1; |
| 4099 | ds_pool_ci.poolSizeCount = 2; |
| 4100 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4101 | |
| 4102 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4103 | err = |
| 4104 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4105 | ASSERT_VK_SUCCESS(err); |
| 4106 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4107 | dsl_binding[0].binding = 0; |
| 4108 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4109 | dsl_binding[0].descriptorCount = 1; |
| 4110 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4111 | dsl_binding[0].pImmutableSamplers = NULL; |
| 4112 | dsl_binding[1].binding = 1; |
| 4113 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4114 | dsl_binding[1].descriptorCount = 1; |
| 4115 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 4116 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4117 | |
| 4118 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4119 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4120 | ds_layout_ci.pNext = NULL; |
| 4121 | ds_layout_ci.bindingCount = 2; |
| 4122 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4123 | |
| 4124 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4125 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4126 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4127 | ASSERT_VK_SUCCESS(err); |
| 4128 | |
| 4129 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4130 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4131 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4132 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4133 | alloc_info.descriptorPool = ds_pool; |
| 4134 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4135 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4136 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4137 | ASSERT_VK_SUCCESS(err); |
| 4138 | |
| 4139 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4140 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 4141 | sampler_ci.pNext = NULL; |
| 4142 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 4143 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 4144 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 4145 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4146 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4147 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 4148 | sampler_ci.mipLodBias = 1.0; |
| 4149 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 4150 | sampler_ci.maxAnisotropy = 1; |
| 4151 | sampler_ci.compareEnable = VK_FALSE; |
| 4152 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4153 | sampler_ci.minLod = 1.0; |
| 4154 | sampler_ci.maxLod = 1.0; |
| 4155 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4156 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4157 | |
| 4158 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4159 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4160 | ASSERT_VK_SUCCESS(err); |
| 4161 | |
| 4162 | VkDescriptorImageInfo info = {}; |
| 4163 | info.sampler = sampler; |
| 4164 | |
| 4165 | VkWriteDescriptorSet descriptor_write; |
| 4166 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 4167 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4168 | descriptor_write.dstSet = descriptorSet; |
| 4169 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4170 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4171 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4172 | descriptor_write.pImageInfo = &info; |
| 4173 | // This write update should succeed |
| 4174 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4175 | // Now perform a copy update that fails due to type mismatch |
| 4176 | VkCopyDescriptorSet copy_ds_update; |
| 4177 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4178 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4179 | copy_ds_update.srcSet = descriptorSet; |
| 4180 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4181 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4182 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4183 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4184 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4185 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4186 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4187 | // 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] | 4188 | m_errorMonitor->SetDesiredFailureMsg( |
| 4189 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4190 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4191 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4192 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4193 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4194 | copy_ds_update.srcBinding = |
| 4195 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4196 | copy_ds_update.dstSet = descriptorSet; |
| 4197 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4198 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4199 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4200 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4201 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4202 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4203 | // 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] | 4204 | m_errorMonitor->SetDesiredFailureMsg( |
| 4205 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4206 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 4207 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4208 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4209 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4210 | copy_ds_update.srcSet = descriptorSet; |
| 4211 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4212 | copy_ds_update.dstSet = descriptorSet; |
| 4213 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4214 | copy_ds_update.descriptorCount = |
| 4215 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4216 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4217 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4218 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4219 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4220 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4221 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4222 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4223 | } |
| 4224 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4225 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 4226 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 4227 | // sampleCount |
| 4228 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4229 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4230 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4231 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4232 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4233 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4234 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4235 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4236 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4237 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4238 | |
| 4239 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4240 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4241 | ds_pool_ci.pNext = NULL; |
| 4242 | ds_pool_ci.maxSets = 1; |
| 4243 | ds_pool_ci.poolSizeCount = 1; |
| 4244 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4245 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4246 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4247 | err = |
| 4248 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4249 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4250 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4251 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4252 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4253 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4254 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4255 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4256 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4257 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4258 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4259 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4260 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4261 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4262 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4263 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4264 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4265 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4266 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4267 | ASSERT_VK_SUCCESS(err); |
| 4268 | |
| 4269 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4270 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4271 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4272 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4273 | alloc_info.descriptorPool = ds_pool; |
| 4274 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4275 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4276 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4277 | ASSERT_VK_SUCCESS(err); |
| 4278 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4279 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4280 | pipe_ms_state_ci.sType = |
| 4281 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4282 | pipe_ms_state_ci.pNext = NULL; |
| 4283 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 4284 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4285 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4286 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4287 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4288 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4289 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4290 | pipeline_layout_ci.pNext = NULL; |
| 4291 | pipeline_layout_ci.setLayoutCount = 1; |
| 4292 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4293 | |
| 4294 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4295 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4296 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4297 | ASSERT_VK_SUCCESS(err); |
| 4298 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4299 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4300 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4301 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4302 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4303 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4304 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4305 | VkPipelineObj pipe(m_device); |
| 4306 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4307 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4308 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4309 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4310 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4311 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4312 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4313 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4314 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4315 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4316 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4317 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4318 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4319 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4320 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4321 | } |
Tobin Ehlis | 0f10db5 | 2016-04-04 10:00:21 -0600 | [diff] [blame] | 4322 | #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] | 4323 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 4324 | // Create Pipeline where the number of blend attachments doesn't match the |
| 4325 | // number of color attachments. In this case, we don't add any color |
| 4326 | // blend attachments even though we have a color attachment. |
| 4327 | VkResult err; |
| 4328 | |
| 4329 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4330 | "Mismatch between blend state attachment"); |
| 4331 | |
| 4332 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4333 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4334 | VkDescriptorPoolSize ds_type_count = {}; |
| 4335 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4336 | ds_type_count.descriptorCount = 1; |
| 4337 | |
| 4338 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4339 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4340 | ds_pool_ci.pNext = NULL; |
| 4341 | ds_pool_ci.maxSets = 1; |
| 4342 | ds_pool_ci.poolSizeCount = 1; |
| 4343 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4344 | |
| 4345 | VkDescriptorPool ds_pool; |
| 4346 | err = |
| 4347 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4348 | ASSERT_VK_SUCCESS(err); |
| 4349 | |
| 4350 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4351 | dsl_binding.binding = 0; |
| 4352 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4353 | dsl_binding.descriptorCount = 1; |
| 4354 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4355 | dsl_binding.pImmutableSamplers = NULL; |
| 4356 | |
| 4357 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4358 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4359 | ds_layout_ci.pNext = NULL; |
| 4360 | ds_layout_ci.bindingCount = 1; |
| 4361 | ds_layout_ci.pBindings = &dsl_binding; |
| 4362 | |
| 4363 | VkDescriptorSetLayout ds_layout; |
| 4364 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4365 | &ds_layout); |
| 4366 | ASSERT_VK_SUCCESS(err); |
| 4367 | |
| 4368 | VkDescriptorSet descriptorSet; |
| 4369 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4370 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4371 | alloc_info.descriptorSetCount = 1; |
| 4372 | alloc_info.descriptorPool = ds_pool; |
| 4373 | alloc_info.pSetLayouts = &ds_layout; |
| 4374 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4375 | &descriptorSet); |
| 4376 | ASSERT_VK_SUCCESS(err); |
| 4377 | |
| 4378 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4379 | pipe_ms_state_ci.sType = |
| 4380 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4381 | pipe_ms_state_ci.pNext = NULL; |
| 4382 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 4383 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4384 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4385 | pipe_ms_state_ci.pSampleMask = NULL; |
| 4386 | |
| 4387 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4388 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4389 | pipeline_layout_ci.pNext = NULL; |
| 4390 | pipeline_layout_ci.setLayoutCount = 1; |
| 4391 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4392 | |
| 4393 | VkPipelineLayout pipeline_layout; |
| 4394 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4395 | &pipeline_layout); |
| 4396 | ASSERT_VK_SUCCESS(err); |
| 4397 | |
| 4398 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4399 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4400 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4401 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4402 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4403 | // but add it to be able to run on more devices |
| 4404 | VkPipelineObj pipe(m_device); |
| 4405 | pipe.AddShader(&vs); |
| 4406 | pipe.AddShader(&fs); |
| 4407 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4408 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4409 | |
| 4410 | BeginCommandBuffer(); |
| 4411 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4412 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4413 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4414 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4415 | |
| 4416 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4417 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4418 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4419 | } |
Tony Barbour | 4e81a20 | 2016-04-04 11:09:40 -0600 | [diff] [blame] | 4420 | #endif //ADD_BACK_IN_WHEN_CHECK_IS_BACK |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4421 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 4422 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 4423 | // to issuing a Draw |
| 4424 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4425 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4426 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 4427 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4428 | "vkCmdClearAttachments() issued on CB object "); |
| 4429 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4430 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4431 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4432 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4433 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4434 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4435 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4436 | |
| 4437 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4438 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4439 | ds_pool_ci.pNext = NULL; |
| 4440 | ds_pool_ci.maxSets = 1; |
| 4441 | ds_pool_ci.poolSizeCount = 1; |
| 4442 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4443 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4444 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4445 | err = |
| 4446 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4447 | ASSERT_VK_SUCCESS(err); |
| 4448 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4449 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4450 | dsl_binding.binding = 0; |
| 4451 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4452 | dsl_binding.descriptorCount = 1; |
| 4453 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4454 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4455 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4456 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4457 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4458 | ds_layout_ci.pNext = NULL; |
| 4459 | ds_layout_ci.bindingCount = 1; |
| 4460 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4461 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4462 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4463 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4464 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4465 | ASSERT_VK_SUCCESS(err); |
| 4466 | |
| 4467 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4468 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4469 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4470 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4471 | alloc_info.descriptorPool = ds_pool; |
| 4472 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4473 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4474 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4475 | ASSERT_VK_SUCCESS(err); |
| 4476 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4477 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4478 | pipe_ms_state_ci.sType = |
| 4479 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4480 | pipe_ms_state_ci.pNext = NULL; |
| 4481 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 4482 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4483 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4484 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4485 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4486 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4487 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4488 | pipeline_layout_ci.pNext = NULL; |
| 4489 | pipeline_layout_ci.setLayoutCount = 1; |
| 4490 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4491 | |
| 4492 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4493 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4494 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4495 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4496 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4497 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4498 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4499 | // 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] | 4500 | // on more devices |
| 4501 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4502 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4503 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4504 | VkPipelineObj pipe(m_device); |
| 4505 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4506 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4507 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4508 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4509 | |
| 4510 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4511 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4512 | // Main thing we care about for this test is that the VkImage obj we're |
| 4513 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4514 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4515 | VkClearAttachment color_attachment; |
| 4516 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4517 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 4518 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 4519 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 4520 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 4521 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4522 | VkClearRect clear_rect = { |
| 4523 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4524 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4525 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 4526 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4527 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4528 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4529 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4530 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4531 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4532 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4533 | } |
| 4534 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4535 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 4536 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4537 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4538 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4539 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 4540 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4541 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4542 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4543 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4544 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4545 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4546 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4547 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4548 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4549 | |
| 4550 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4551 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4552 | ds_pool_ci.pNext = NULL; |
| 4553 | ds_pool_ci.maxSets = 1; |
| 4554 | ds_pool_ci.poolSizeCount = 1; |
| 4555 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4556 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4557 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4558 | err = |
| 4559 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4560 | ASSERT_VK_SUCCESS(err); |
| 4561 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4562 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4563 | dsl_binding.binding = 0; |
| 4564 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4565 | dsl_binding.descriptorCount = 1; |
| 4566 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4567 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4568 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4569 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4570 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4571 | ds_layout_ci.pNext = NULL; |
| 4572 | ds_layout_ci.bindingCount = 1; |
| 4573 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4574 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4575 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4576 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4577 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4578 | ASSERT_VK_SUCCESS(err); |
| 4579 | |
| 4580 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4581 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4582 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4583 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4584 | alloc_info.descriptorPool = ds_pool; |
| 4585 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4586 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4587 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4588 | ASSERT_VK_SUCCESS(err); |
| 4589 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4590 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4591 | pipe_ms_state_ci.sType = |
| 4592 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4593 | pipe_ms_state_ci.pNext = NULL; |
| 4594 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 4595 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4596 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 4597 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4598 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4599 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4600 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4601 | pipeline_layout_ci.pNext = NULL; |
| 4602 | pipeline_layout_ci.setLayoutCount = 1; |
| 4603 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4604 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4605 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4606 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4607 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4608 | ASSERT_VK_SUCCESS(err); |
| 4609 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4610 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4611 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4612 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4613 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4614 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4615 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4616 | VkPipelineObj pipe(m_device); |
| 4617 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4618 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4619 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4620 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4621 | pipe.SetViewport(m_viewports); |
| 4622 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4623 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4624 | |
| 4625 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4626 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4627 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4628 | // Don't care about actual data, just need to get to draw to flag error |
| 4629 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4630 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 4631 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4632 | 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] | 4633 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4634 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4635 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4636 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4637 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4638 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4639 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4640 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4641 | #endif // DRAW_STATE_TESTS |
| 4642 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 4643 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4644 | #if GTEST_IS_THREADSAFE |
| 4645 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4646 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4647 | VkEvent event; |
| 4648 | bool bailout; |
| 4649 | }; |
| 4650 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4651 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 4652 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4653 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4654 | for (int i = 0; i < 10000; i++) { |
| 4655 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 4656 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4657 | if (data->bailout) { |
| 4658 | break; |
| 4659 | } |
| 4660 | } |
| 4661 | return NULL; |
| 4662 | } |
| 4663 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4664 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4665 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4666 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4667 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4668 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4669 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4670 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4671 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4672 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4673 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4674 | // Calls AllocateCommandBuffers |
| 4675 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4676 | |
| 4677 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4678 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4679 | |
| 4680 | VkEventCreateInfo event_info; |
| 4681 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4682 | VkResult err; |
| 4683 | |
| 4684 | memset(&event_info, 0, sizeof(event_info)); |
| 4685 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 4686 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4687 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4688 | ASSERT_VK_SUCCESS(err); |
| 4689 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4690 | err = vkResetEvent(device(), event); |
| 4691 | ASSERT_VK_SUCCESS(err); |
| 4692 | |
| 4693 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4694 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4695 | data.event = event; |
| 4696 | data.bailout = false; |
| 4697 | m_errorMonitor->SetBailout(&data.bailout); |
| 4698 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4699 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4700 | // Add many entries to command buffer from this thread at the same time. |
| 4701 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4702 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4703 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4704 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4705 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 4706 | m_errorMonitor->SetBailout(NULL); |
| 4707 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4708 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4709 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4710 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4711 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4712 | #endif // GTEST_IS_THREADSAFE |
| 4713 | #endif // THREADING_TESTS |
| 4714 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4715 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4716 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4717 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4718 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4719 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4720 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4721 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4722 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4723 | VkShaderModule module; |
| 4724 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4725 | struct icd_spv_header spv; |
| 4726 | |
| 4727 | spv.magic = ICD_SPV_MAGIC; |
| 4728 | spv.version = ICD_SPV_VERSION; |
| 4729 | spv.gen_magic = 0; |
| 4730 | |
| 4731 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4732 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4733 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4734 | moduleCreateInfo.codeSize = 4; |
| 4735 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4736 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4737 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4738 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4739 | } |
| 4740 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4741 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4742 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4743 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4744 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4745 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4746 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4747 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4748 | VkShaderModule module; |
| 4749 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4750 | struct icd_spv_header spv; |
| 4751 | |
| 4752 | spv.magic = ~ICD_SPV_MAGIC; |
| 4753 | spv.version = ICD_SPV_VERSION; |
| 4754 | spv.gen_magic = 0; |
| 4755 | |
| 4756 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4757 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4758 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4759 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4760 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4761 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4762 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4763 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4764 | } |
| 4765 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4766 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4767 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4768 | "Shader is not SPIR-V"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4769 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4770 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4771 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4772 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4773 | VkShaderModule module; |
| 4774 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4775 | struct icd_spv_header spv; |
| 4776 | |
| 4777 | spv.magic = ICD_SPV_MAGIC; |
| 4778 | spv.version = ~ICD_SPV_VERSION; |
| 4779 | spv.gen_magic = 0; |
| 4780 | |
| 4781 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4782 | moduleCreateInfo.pNext = NULL; |
| 4783 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4784 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4785 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4786 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4787 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4788 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4789 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4790 | } |
| 4791 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4792 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4793 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4794 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4795 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4796 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4797 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4798 | |
| 4799 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4800 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4801 | "\n" |
| 4802 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4803 | "out gl_PerVertex {\n" |
| 4804 | " vec4 gl_Position;\n" |
| 4805 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4806 | "void main(){\n" |
| 4807 | " gl_Position = vec4(1);\n" |
| 4808 | " x = 0;\n" |
| 4809 | "}\n"; |
| 4810 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4811 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4812 | "\n" |
| 4813 | "layout(location=0) out vec4 color;\n" |
| 4814 | "void main(){\n" |
| 4815 | " color = vec4(1);\n" |
| 4816 | "}\n"; |
| 4817 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4818 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4819 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4820 | |
| 4821 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4822 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4823 | pipe.AddShader(&vs); |
| 4824 | pipe.AddShader(&fs); |
| 4825 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4826 | VkDescriptorSetObj descriptorSet(m_device); |
| 4827 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4828 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4829 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4830 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4831 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4832 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4833 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4834 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4835 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4836 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4837 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4838 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4839 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4840 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4841 | |
| 4842 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4843 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4844 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4845 | "out gl_PerVertex {\n" |
| 4846 | " vec4 gl_Position;\n" |
| 4847 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4848 | "void main(){\n" |
| 4849 | " gl_Position = vec4(1);\n" |
| 4850 | "}\n"; |
| 4851 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4852 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4853 | "\n" |
| 4854 | "layout(location=0) in float x;\n" |
| 4855 | "layout(location=0) out vec4 color;\n" |
| 4856 | "void main(){\n" |
| 4857 | " color = vec4(x);\n" |
| 4858 | "}\n"; |
| 4859 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4860 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4861 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4862 | |
| 4863 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4864 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4865 | pipe.AddShader(&vs); |
| 4866 | pipe.AddShader(&fs); |
| 4867 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4868 | VkDescriptorSetObj descriptorSet(m_device); |
| 4869 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4870 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4871 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4872 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4873 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4874 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4875 | } |
| 4876 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4877 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 4878 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4879 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 4880 | |
| 4881 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4882 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4883 | |
| 4884 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4885 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 4886 | "\n" |
| 4887 | "out gl_PerVertex {\n" |
| 4888 | " vec4 gl_Position;\n" |
| 4889 | "};\n" |
| 4890 | "void main(){\n" |
| 4891 | " gl_Position = vec4(1);\n" |
| 4892 | "}\n"; |
| 4893 | char const *fsSource = |
| 4894 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 4895 | "\n" |
| 4896 | "in block { layout(location=0) float x; } ins;\n" |
| 4897 | "layout(location=0) out vec4 color;\n" |
| 4898 | "void main(){\n" |
| 4899 | " color = vec4(ins.x);\n" |
| 4900 | "}\n"; |
| 4901 | |
| 4902 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4903 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4904 | |
| 4905 | VkPipelineObj pipe(m_device); |
| 4906 | pipe.AddColorAttachment(); |
| 4907 | pipe.AddShader(&vs); |
| 4908 | pipe.AddShader(&fs); |
| 4909 | |
| 4910 | VkDescriptorSetObj descriptorSet(m_device); |
| 4911 | descriptorSet.AppendDummy(); |
| 4912 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 4913 | |
| 4914 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4915 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4916 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 4917 | } |
| 4918 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4919 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 4920 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 4921 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4922 | "output arr[2] of float32' vs 'ptr to " |
| 4923 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 4924 | |
| 4925 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4926 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4927 | |
| 4928 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4929 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 4930 | "\n" |
| 4931 | "layout(location=0) out float x[2];\n" |
| 4932 | "out gl_PerVertex {\n" |
| 4933 | " vec4 gl_Position;\n" |
| 4934 | "};\n" |
| 4935 | "void main(){\n" |
| 4936 | " x[0] = 0; x[1] = 0;\n" |
| 4937 | " gl_Position = vec4(1);\n" |
| 4938 | "}\n"; |
| 4939 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4940 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 4941 | "\n" |
| 4942 | "layout(location=0) in float x[3];\n" |
| 4943 | "layout(location=0) out vec4 color;\n" |
| 4944 | "void main(){\n" |
| 4945 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 4946 | "}\n"; |
| 4947 | |
| 4948 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4949 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4950 | |
| 4951 | VkPipelineObj pipe(m_device); |
| 4952 | pipe.AddColorAttachment(); |
| 4953 | pipe.AddShader(&vs); |
| 4954 | pipe.AddShader(&fs); |
| 4955 | |
| 4956 | VkDescriptorSetObj descriptorSet(m_device); |
| 4957 | descriptorSet.AppendDummy(); |
| 4958 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 4959 | |
| 4960 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4961 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4962 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 4963 | } |
| 4964 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4965 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4966 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4967 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4968 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4969 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4970 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4971 | |
| 4972 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4973 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4974 | "\n" |
| 4975 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4976 | "out gl_PerVertex {\n" |
| 4977 | " vec4 gl_Position;\n" |
| 4978 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4979 | "void main(){\n" |
| 4980 | " x = 0;\n" |
| 4981 | " gl_Position = vec4(1);\n" |
| 4982 | "}\n"; |
| 4983 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 4984 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4985 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4986 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4987 | "layout(location=0) out vec4 color;\n" |
| 4988 | "void main(){\n" |
| 4989 | " color = vec4(x);\n" |
| 4990 | "}\n"; |
| 4991 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4992 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4993 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4994 | |
| 4995 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4996 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4997 | pipe.AddShader(&vs); |
| 4998 | pipe.AddShader(&fs); |
| 4999 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5000 | VkDescriptorSetObj descriptorSet(m_device); |
| 5001 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5002 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5003 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5004 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5005 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5006 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 5007 | } |
| 5008 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5009 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5010 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5011 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5012 | |
| 5013 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5014 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5015 | |
| 5016 | char const *vsSource = |
| 5017 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5018 | "\n" |
| 5019 | "out block { layout(location=0) int x; } outs;\n" |
| 5020 | "out gl_PerVertex {\n" |
| 5021 | " vec4 gl_Position;\n" |
| 5022 | "};\n" |
| 5023 | "void main(){\n" |
| 5024 | " outs.x = 0;\n" |
| 5025 | " gl_Position = vec4(1);\n" |
| 5026 | "}\n"; |
| 5027 | char const *fsSource = |
| 5028 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5029 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5030 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5031 | "layout(location=0) out vec4 color;\n" |
| 5032 | "void main(){\n" |
| 5033 | " color = vec4(ins.x);\n" |
| 5034 | "}\n"; |
| 5035 | |
| 5036 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5037 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5038 | |
| 5039 | VkPipelineObj pipe(m_device); |
| 5040 | pipe.AddColorAttachment(); |
| 5041 | pipe.AddShader(&vs); |
| 5042 | pipe.AddShader(&fs); |
| 5043 | |
| 5044 | VkDescriptorSetObj descriptorSet(m_device); |
| 5045 | descriptorSet.AppendDummy(); |
| 5046 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5047 | |
| 5048 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5049 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5050 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5051 | } |
| 5052 | |
| 5053 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 5054 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5055 | "location 0.0 which is not written by vertex shader"); |
| 5056 | |
| 5057 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5058 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5059 | |
| 5060 | char const *vsSource = |
| 5061 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5062 | "\n" |
| 5063 | "out block { layout(location=1) float x; } outs;\n" |
| 5064 | "out gl_PerVertex {\n" |
| 5065 | " vec4 gl_Position;\n" |
| 5066 | "};\n" |
| 5067 | "void main(){\n" |
| 5068 | " outs.x = 0;\n" |
| 5069 | " gl_Position = vec4(1);\n" |
| 5070 | "}\n"; |
| 5071 | char const *fsSource = |
| 5072 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5073 | "\n" |
| 5074 | "in block { layout(location=0) float x; } ins;\n" |
| 5075 | "layout(location=0) out vec4 color;\n" |
| 5076 | "void main(){\n" |
| 5077 | " color = vec4(ins.x);\n" |
| 5078 | "}\n"; |
| 5079 | |
| 5080 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5081 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5082 | |
| 5083 | VkPipelineObj pipe(m_device); |
| 5084 | pipe.AddColorAttachment(); |
| 5085 | pipe.AddShader(&vs); |
| 5086 | pipe.AddShader(&fs); |
| 5087 | |
| 5088 | VkDescriptorSetObj descriptorSet(m_device); |
| 5089 | descriptorSet.AppendDummy(); |
| 5090 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5091 | |
| 5092 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5093 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5094 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5095 | } |
| 5096 | |
| 5097 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 5098 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5099 | "location 0.1 which is not written by vertex shader"); |
| 5100 | |
| 5101 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5102 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5103 | |
| 5104 | char const *vsSource = |
| 5105 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5106 | "\n" |
| 5107 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 5108 | "out gl_PerVertex {\n" |
| 5109 | " vec4 gl_Position;\n" |
| 5110 | "};\n" |
| 5111 | "void main(){\n" |
| 5112 | " outs.x = 0;\n" |
| 5113 | " gl_Position = vec4(1);\n" |
| 5114 | "}\n"; |
| 5115 | char const *fsSource = |
| 5116 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 5117 | "\n" |
| 5118 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 5119 | "layout(location=0) out vec4 color;\n" |
| 5120 | "void main(){\n" |
| 5121 | " color = vec4(ins.x);\n" |
| 5122 | "}\n"; |
| 5123 | |
| 5124 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5125 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5126 | |
| 5127 | VkPipelineObj pipe(m_device); |
| 5128 | pipe.AddColorAttachment(); |
| 5129 | pipe.AddShader(&vs); |
| 5130 | pipe.AddShader(&fs); |
| 5131 | |
| 5132 | VkDescriptorSetObj descriptorSet(m_device); |
| 5133 | descriptorSet.AppendDummy(); |
| 5134 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5135 | |
| 5136 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5137 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5138 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 5139 | } |
| 5140 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5141 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5142 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5143 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5144 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5145 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5146 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5147 | |
| 5148 | VkVertexInputBindingDescription input_binding; |
| 5149 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5150 | |
| 5151 | VkVertexInputAttributeDescription input_attrib; |
| 5152 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5153 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5154 | |
| 5155 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5156 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5157 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5158 | "out gl_PerVertex {\n" |
| 5159 | " vec4 gl_Position;\n" |
| 5160 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5161 | "void main(){\n" |
| 5162 | " gl_Position = vec4(1);\n" |
| 5163 | "}\n"; |
| 5164 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5165 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5166 | "\n" |
| 5167 | "layout(location=0) out vec4 color;\n" |
| 5168 | "void main(){\n" |
| 5169 | " color = vec4(1);\n" |
| 5170 | "}\n"; |
| 5171 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5172 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5173 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5174 | |
| 5175 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5176 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5177 | pipe.AddShader(&vs); |
| 5178 | pipe.AddShader(&fs); |
| 5179 | |
| 5180 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5181 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5182 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5183 | VkDescriptorSetObj descriptorSet(m_device); |
| 5184 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5185 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5186 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5187 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5188 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5189 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 5190 | } |
| 5191 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5192 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5193 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5194 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5195 | |
| 5196 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5197 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5198 | |
| 5199 | VkVertexInputBindingDescription input_binding; |
| 5200 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5201 | |
| 5202 | VkVertexInputAttributeDescription input_attrib; |
| 5203 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5204 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5205 | |
| 5206 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5207 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5208 | "\n" |
| 5209 | "layout(location=1) in float x;\n" |
| 5210 | "out gl_PerVertex {\n" |
| 5211 | " vec4 gl_Position;\n" |
| 5212 | "};\n" |
| 5213 | "void main(){\n" |
| 5214 | " gl_Position = vec4(x);\n" |
| 5215 | "}\n"; |
| 5216 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5217 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5218 | "\n" |
| 5219 | "layout(location=0) out vec4 color;\n" |
| 5220 | "void main(){\n" |
| 5221 | " color = vec4(1);\n" |
| 5222 | "}\n"; |
| 5223 | |
| 5224 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5225 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5226 | |
| 5227 | VkPipelineObj pipe(m_device); |
| 5228 | pipe.AddColorAttachment(); |
| 5229 | pipe.AddShader(&vs); |
| 5230 | pipe.AddShader(&fs); |
| 5231 | |
| 5232 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5233 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5234 | |
| 5235 | VkDescriptorSetObj descriptorSet(m_device); |
| 5236 | descriptorSet.AppendDummy(); |
| 5237 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5238 | |
| 5239 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5240 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5241 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 5242 | } |
| 5243 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5244 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 5245 | m_errorMonitor->SetDesiredFailureMsg( |
| 5246 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5247 | "VS consumes input at location 0 but not provided"); |
| 5248 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5249 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5250 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5251 | |
| 5252 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5253 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5254 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5255 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5256 | "out gl_PerVertex {\n" |
| 5257 | " vec4 gl_Position;\n" |
| 5258 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5259 | "void main(){\n" |
| 5260 | " gl_Position = x;\n" |
| 5261 | "}\n"; |
| 5262 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5263 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5264 | "\n" |
| 5265 | "layout(location=0) out vec4 color;\n" |
| 5266 | "void main(){\n" |
| 5267 | " color = vec4(1);\n" |
| 5268 | "}\n"; |
| 5269 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5270 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5271 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5272 | |
| 5273 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5274 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5275 | pipe.AddShader(&vs); |
| 5276 | pipe.AddShader(&fs); |
| 5277 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5278 | VkDescriptorSetObj descriptorSet(m_device); |
| 5279 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5280 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5281 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5282 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5283 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5284 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 5285 | } |
| 5286 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5287 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 5288 | m_errorMonitor->SetDesiredFailureMsg( |
| 5289 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5290 | "location 0 does not match VS input type"); |
| 5291 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5292 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5293 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5294 | |
| 5295 | VkVertexInputBindingDescription input_binding; |
| 5296 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5297 | |
| 5298 | VkVertexInputAttributeDescription input_attrib; |
| 5299 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5300 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5301 | |
| 5302 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5303 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5304 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5305 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5306 | "out gl_PerVertex {\n" |
| 5307 | " vec4 gl_Position;\n" |
| 5308 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5309 | "void main(){\n" |
| 5310 | " gl_Position = vec4(x);\n" |
| 5311 | "}\n"; |
| 5312 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5313 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5314 | "\n" |
| 5315 | "layout(location=0) out vec4 color;\n" |
| 5316 | "void main(){\n" |
| 5317 | " color = vec4(1);\n" |
| 5318 | "}\n"; |
| 5319 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5320 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5321 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5322 | |
| 5323 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5324 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5325 | pipe.AddShader(&vs); |
| 5326 | pipe.AddShader(&fs); |
| 5327 | |
| 5328 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5329 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5330 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5331 | VkDescriptorSetObj descriptorSet(m_device); |
| 5332 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5333 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5334 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5335 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5336 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5337 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 5338 | } |
| 5339 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 5340 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 5341 | m_errorMonitor->SetDesiredFailureMsg( |
| 5342 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5343 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 5344 | |
| 5345 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5346 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5347 | |
| 5348 | char const *vsSource = |
| 5349 | "#version 450\n" |
| 5350 | "\n" |
| 5351 | "out gl_PerVertex {\n" |
| 5352 | " vec4 gl_Position;\n" |
| 5353 | "};\n" |
| 5354 | "void main(){\n" |
| 5355 | " gl_Position = vec4(1);\n" |
| 5356 | "}\n"; |
| 5357 | char const *fsSource = |
| 5358 | "#version 450\n" |
| 5359 | "\n" |
| 5360 | "layout(location=0) out vec4 color;\n" |
| 5361 | "void main(){\n" |
| 5362 | " color = vec4(1);\n" |
| 5363 | "}\n"; |
| 5364 | |
| 5365 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5366 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5367 | |
| 5368 | VkPipelineObj pipe(m_device); |
| 5369 | pipe.AddColorAttachment(); |
| 5370 | pipe.AddShader(&vs); |
| 5371 | pipe.AddShader(&vs); |
| 5372 | pipe.AddShader(&fs); |
| 5373 | |
| 5374 | VkDescriptorSetObj descriptorSet(m_device); |
| 5375 | descriptorSet.AppendDummy(); |
| 5376 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5377 | |
| 5378 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5379 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5380 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 5381 | } |
| 5382 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5383 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5384 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5385 | |
| 5386 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5387 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5388 | |
| 5389 | VkVertexInputBindingDescription input_binding; |
| 5390 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5391 | |
| 5392 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5393 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5394 | |
| 5395 | for (int i = 0; i < 2; i++) { |
| 5396 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5397 | input_attribs[i].location = i; |
| 5398 | } |
| 5399 | |
| 5400 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5401 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5402 | "\n" |
| 5403 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5404 | "out gl_PerVertex {\n" |
| 5405 | " vec4 gl_Position;\n" |
| 5406 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5407 | "void main(){\n" |
| 5408 | " gl_Position = x[0] + x[1];\n" |
| 5409 | "}\n"; |
| 5410 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5411 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5412 | "\n" |
| 5413 | "layout(location=0) out vec4 color;\n" |
| 5414 | "void main(){\n" |
| 5415 | " color = vec4(1);\n" |
| 5416 | "}\n"; |
| 5417 | |
| 5418 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5419 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5420 | |
| 5421 | VkPipelineObj pipe(m_device); |
| 5422 | pipe.AddColorAttachment(); |
| 5423 | pipe.AddShader(&vs); |
| 5424 | pipe.AddShader(&fs); |
| 5425 | |
| 5426 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5427 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5428 | |
| 5429 | VkDescriptorSetObj descriptorSet(m_device); |
| 5430 | descriptorSet.AppendDummy(); |
| 5431 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5432 | |
| 5433 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5434 | |
| 5435 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5436 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5437 | } |
| 5438 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5439 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 5440 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5441 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5442 | |
| 5443 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5444 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5445 | |
| 5446 | VkVertexInputBindingDescription input_binding; |
| 5447 | memset(&input_binding, 0, sizeof(input_binding)); |
| 5448 | |
| 5449 | VkVertexInputAttributeDescription input_attribs[2]; |
| 5450 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5451 | |
| 5452 | for (int i = 0; i < 2; i++) { |
| 5453 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 5454 | input_attribs[i].location = i; |
| 5455 | } |
| 5456 | |
| 5457 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5458 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5459 | "\n" |
| 5460 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5461 | "out gl_PerVertex {\n" |
| 5462 | " vec4 gl_Position;\n" |
| 5463 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5464 | "void main(){\n" |
| 5465 | " gl_Position = x[0] + x[1];\n" |
| 5466 | "}\n"; |
| 5467 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5468 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5469 | "\n" |
| 5470 | "layout(location=0) out vec4 color;\n" |
| 5471 | "void main(){\n" |
| 5472 | " color = vec4(1);\n" |
| 5473 | "}\n"; |
| 5474 | |
| 5475 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5476 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5477 | |
| 5478 | VkPipelineObj pipe(m_device); |
| 5479 | pipe.AddColorAttachment(); |
| 5480 | pipe.AddShader(&vs); |
| 5481 | pipe.AddShader(&fs); |
| 5482 | |
| 5483 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 5484 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 5485 | |
| 5486 | VkDescriptorSetObj descriptorSet(m_device); |
| 5487 | descriptorSet.AppendDummy(); |
| 5488 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5489 | |
| 5490 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5491 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5492 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5493 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 5494 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5495 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 5496 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5497 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5498 | |
| 5499 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5500 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5501 | |
| 5502 | char const *vsSource = |
| 5503 | "#version 450\n" |
| 5504 | "out gl_PerVertex {\n" |
| 5505 | " vec4 gl_Position;\n" |
| 5506 | "};\n" |
| 5507 | "void main(){\n" |
| 5508 | " gl_Position = vec4(0);\n" |
| 5509 | "}\n"; |
| 5510 | char const *fsSource = |
| 5511 | "#version 450\n" |
| 5512 | "\n" |
| 5513 | "layout(location=0) out vec4 color;\n" |
| 5514 | "void main(){\n" |
| 5515 | " color = vec4(1);\n" |
| 5516 | "}\n"; |
| 5517 | |
| 5518 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5519 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5520 | |
| 5521 | VkPipelineObj pipe(m_device); |
| 5522 | pipe.AddColorAttachment(); |
| 5523 | pipe.AddShader(&vs); |
| 5524 | pipe.AddShader(&fs); |
| 5525 | |
| 5526 | VkDescriptorSetObj descriptorSet(m_device); |
| 5527 | descriptorSet.AppendDummy(); |
| 5528 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5529 | |
| 5530 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5531 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5532 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5533 | } |
| 5534 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 5535 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 5536 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5537 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 5538 | |
| 5539 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 5540 | |
| 5541 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5542 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5543 | |
| 5544 | char const *vsSource = |
| 5545 | "#version 450\n" |
| 5546 | "out gl_PerVertex {\n" |
| 5547 | " vec4 gl_Position;\n" |
| 5548 | "};\n" |
| 5549 | "layout(location=0) out vec3 x;\n" |
| 5550 | "layout(location=1) out ivec3 y;\n" |
| 5551 | "layout(location=2) out vec3 z;\n" |
| 5552 | "void main(){\n" |
| 5553 | " gl_Position = vec4(0);\n" |
| 5554 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 5555 | "}\n"; |
| 5556 | char const *fsSource = |
| 5557 | "#version 450\n" |
| 5558 | "\n" |
| 5559 | "layout(location=0) out vec4 color;\n" |
| 5560 | "layout(location=0) in float x;\n" |
| 5561 | "layout(location=1) flat in int y;\n" |
| 5562 | "layout(location=2) in vec2 z;\n" |
| 5563 | "void main(){\n" |
| 5564 | " color = vec4(1 + x + y + z.x);\n" |
| 5565 | "}\n"; |
| 5566 | |
| 5567 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5568 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5569 | |
| 5570 | VkPipelineObj pipe(m_device); |
| 5571 | pipe.AddColorAttachment(); |
| 5572 | pipe.AddShader(&vs); |
| 5573 | pipe.AddShader(&fs); |
| 5574 | |
| 5575 | VkDescriptorSetObj descriptorSet(m_device); |
| 5576 | descriptorSet.AppendDummy(); |
| 5577 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5578 | |
| 5579 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5580 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5581 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 5582 | } |
| 5583 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5584 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 5585 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5586 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5587 | |
| 5588 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5589 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5590 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 5591 | if (!m_device->phy().features().tessellationShader) { |
| 5592 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 5593 | return; |
| 5594 | } |
| 5595 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5596 | char const *vsSource = |
| 5597 | "#version 450\n" |
| 5598 | "void main(){}\n"; |
| 5599 | char const *tcsSource = |
| 5600 | "#version 450\n" |
| 5601 | "layout(location=0) out int x[];\n" |
| 5602 | "layout(vertices=3) out;\n" |
| 5603 | "void main(){\n" |
| 5604 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 5605 | " gl_TessLevelInner[0] = 1;\n" |
| 5606 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 5607 | "}\n"; |
| 5608 | char const *tesSource = |
| 5609 | "#version 450\n" |
| 5610 | "layout(triangles, equal_spacing, cw) in;\n" |
| 5611 | "layout(location=0) in int x[];\n" |
| 5612 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 5613 | "void main(){\n" |
| 5614 | " gl_Position.xyz = gl_TessCoord;\n" |
| 5615 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 5616 | "}\n"; |
| 5617 | char const *fsSource = |
| 5618 | "#version 450\n" |
| 5619 | "layout(location=0) out vec4 color;\n" |
| 5620 | "void main(){\n" |
| 5621 | " color = vec4(1);\n" |
| 5622 | "}\n"; |
| 5623 | |
| 5624 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5625 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 5626 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 5627 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5628 | |
| 5629 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 5630 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 5631 | nullptr, |
| 5632 | 0, |
| 5633 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 5634 | VK_FALSE}; |
| 5635 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 5636 | VkPipelineTessellationStateCreateInfo tsci{ |
| 5637 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 5638 | nullptr, |
| 5639 | 0, |
| 5640 | 3}; |
| 5641 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5642 | VkPipelineObj pipe(m_device); |
| 5643 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 5644 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5645 | pipe.AddColorAttachment(); |
| 5646 | pipe.AddShader(&vs); |
| 5647 | pipe.AddShader(&tcs); |
| 5648 | pipe.AddShader(&tes); |
| 5649 | pipe.AddShader(&fs); |
| 5650 | |
| 5651 | VkDescriptorSetObj descriptorSet(m_device); |
| 5652 | descriptorSet.AppendDummy(); |
| 5653 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5654 | |
| 5655 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5656 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5657 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 5658 | } |
| 5659 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 5660 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 5661 | { |
| 5662 | m_errorMonitor->ExpectSuccess(); |
| 5663 | |
| 5664 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5665 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5666 | |
| 5667 | if (!m_device->phy().features().geometryShader) { |
| 5668 | printf("Device does not support geometry shaders; skipped.\n"); |
| 5669 | return; |
| 5670 | } |
| 5671 | |
| 5672 | char const *vsSource = |
| 5673 | "#version 450\n" |
| 5674 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 5675 | "void main(){\n" |
| 5676 | " vs_out.x = vec4(1);\n" |
| 5677 | "}\n"; |
| 5678 | char const *gsSource = |
| 5679 | "#version 450\n" |
| 5680 | "layout(triangles) in;\n" |
| 5681 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 5682 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 5683 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 5684 | "void main() {\n" |
| 5685 | " gl_Position = gs_in[0].x;\n" |
| 5686 | " EmitVertex();\n" |
| 5687 | "}\n"; |
| 5688 | char const *fsSource = |
| 5689 | "#version 450\n" |
| 5690 | "layout(location=0) out vec4 color;\n" |
| 5691 | "void main(){\n" |
| 5692 | " color = vec4(1);\n" |
| 5693 | "}\n"; |
| 5694 | |
| 5695 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5696 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 5697 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5698 | |
| 5699 | VkPipelineObj pipe(m_device); |
| 5700 | pipe.AddColorAttachment(); |
| 5701 | pipe.AddShader(&vs); |
| 5702 | pipe.AddShader(&gs); |
| 5703 | pipe.AddShader(&fs); |
| 5704 | |
| 5705 | VkDescriptorSetObj descriptorSet(m_device); |
| 5706 | descriptorSet.AppendDummy(); |
| 5707 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5708 | |
| 5709 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5710 | |
| 5711 | m_errorMonitor->VerifyNotFound(); |
| 5712 | } |
| 5713 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 5714 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 5715 | { |
| 5716 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5717 | "is per-vertex in tessellation control shader stage " |
| 5718 | "but per-patch in tessellation evaluation shader stage"); |
| 5719 | |
| 5720 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5721 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5722 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 5723 | if (!m_device->phy().features().tessellationShader) { |
| 5724 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 5725 | return; |
| 5726 | } |
| 5727 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 5728 | char const *vsSource = |
| 5729 | "#version 450\n" |
| 5730 | "void main(){}\n"; |
| 5731 | char const *tcsSource = |
| 5732 | "#version 450\n" |
| 5733 | "layout(location=0) out int x[];\n" |
| 5734 | "layout(vertices=3) out;\n" |
| 5735 | "void main(){\n" |
| 5736 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 5737 | " gl_TessLevelInner[0] = 1;\n" |
| 5738 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 5739 | "}\n"; |
| 5740 | char const *tesSource = |
| 5741 | "#version 450\n" |
| 5742 | "layout(triangles, equal_spacing, cw) in;\n" |
| 5743 | "layout(location=0) patch in int x;\n" |
| 5744 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 5745 | "void main(){\n" |
| 5746 | " gl_Position.xyz = gl_TessCoord;\n" |
| 5747 | " gl_Position.w = x;\n" |
| 5748 | "}\n"; |
| 5749 | char const *fsSource = |
| 5750 | "#version 450\n" |
| 5751 | "layout(location=0) out vec4 color;\n" |
| 5752 | "void main(){\n" |
| 5753 | " color = vec4(1);\n" |
| 5754 | "}\n"; |
| 5755 | |
| 5756 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5757 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 5758 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 5759 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5760 | |
| 5761 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 5762 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 5763 | nullptr, |
| 5764 | 0, |
| 5765 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 5766 | VK_FALSE}; |
| 5767 | |
| 5768 | VkPipelineTessellationStateCreateInfo tsci{ |
| 5769 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 5770 | nullptr, |
| 5771 | 0, |
| 5772 | 3}; |
| 5773 | |
| 5774 | VkPipelineObj pipe(m_device); |
| 5775 | pipe.SetInputAssembly(&iasci); |
| 5776 | pipe.SetTessellation(&tsci); |
| 5777 | pipe.AddColorAttachment(); |
| 5778 | pipe.AddShader(&vs); |
| 5779 | pipe.AddShader(&tcs); |
| 5780 | pipe.AddShader(&tes); |
| 5781 | pipe.AddShader(&fs); |
| 5782 | |
| 5783 | VkDescriptorSetObj descriptorSet(m_device); |
| 5784 | descriptorSet.AppendDummy(); |
| 5785 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5786 | |
| 5787 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5788 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5789 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 5790 | } |
| 5791 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5792 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 5793 | m_errorMonitor->SetDesiredFailureMsg( |
| 5794 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5795 | "Duplicate vertex input binding descriptions for binding 0"); |
| 5796 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5797 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5798 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5799 | |
| 5800 | /* Two binding descriptions for binding 0 */ |
| 5801 | VkVertexInputBindingDescription input_bindings[2]; |
| 5802 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 5803 | |
| 5804 | VkVertexInputAttributeDescription input_attrib; |
| 5805 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 5806 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 5807 | |
| 5808 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5809 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5810 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5811 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5812 | "out gl_PerVertex {\n" |
| 5813 | " vec4 gl_Position;\n" |
| 5814 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5815 | "void main(){\n" |
| 5816 | " gl_Position = vec4(x);\n" |
| 5817 | "}\n"; |
| 5818 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5819 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5820 | "\n" |
| 5821 | "layout(location=0) out vec4 color;\n" |
| 5822 | "void main(){\n" |
| 5823 | " color = vec4(1);\n" |
| 5824 | "}\n"; |
| 5825 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5826 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5827 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5828 | |
| 5829 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5830 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5831 | pipe.AddShader(&vs); |
| 5832 | pipe.AddShader(&fs); |
| 5833 | |
| 5834 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 5835 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5836 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5837 | VkDescriptorSetObj descriptorSet(m_device); |
| 5838 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5839 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5840 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5841 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5842 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5843 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5844 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 5845 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 5846 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 5847 | m_errorMonitor->ExpectSuccess(); |
| 5848 | |
| 5849 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5850 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5851 | |
| 5852 | if (!m_device->phy().features().tessellationShader) { |
| 5853 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 5854 | return; |
| 5855 | } |
| 5856 | |
| 5857 | VkVertexInputBindingDescription input_bindings[1]; |
| 5858 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 5859 | |
| 5860 | VkVertexInputAttributeDescription input_attribs[4]; |
| 5861 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 5862 | input_attribs[0].location = 0; |
| 5863 | input_attribs[0].offset = 0; |
| 5864 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 5865 | input_attribs[1].location = 2; |
| 5866 | input_attribs[1].offset = 32; |
| 5867 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 5868 | input_attribs[2].location = 4; |
| 5869 | input_attribs[2].offset = 64; |
| 5870 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 5871 | input_attribs[3].location = 6; |
| 5872 | input_attribs[3].offset = 96; |
| 5873 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 5874 | |
| 5875 | char const *vsSource = |
| 5876 | "#version 450\n" |
| 5877 | "\n" |
| 5878 | "layout(location=0) in dmat4 x;\n" |
| 5879 | "out gl_PerVertex {\n" |
| 5880 | " vec4 gl_Position;\n" |
| 5881 | "};\n" |
| 5882 | "void main(){\n" |
| 5883 | " gl_Position = vec4(x[0][0]);\n" |
| 5884 | "}\n"; |
| 5885 | char const *fsSource = |
| 5886 | "#version 450\n" |
| 5887 | "\n" |
| 5888 | "layout(location=0) out vec4 color;\n" |
| 5889 | "void main(){\n" |
| 5890 | " color = vec4(1);\n" |
| 5891 | "}\n"; |
| 5892 | |
| 5893 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5894 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 5895 | |
| 5896 | VkPipelineObj pipe(m_device); |
| 5897 | pipe.AddColorAttachment(); |
| 5898 | pipe.AddShader(&vs); |
| 5899 | pipe.AddShader(&fs); |
| 5900 | |
| 5901 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 5902 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 5903 | |
| 5904 | VkDescriptorSetObj descriptorSet(m_device); |
| 5905 | descriptorSet.AppendDummy(); |
| 5906 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 5907 | |
| 5908 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5909 | |
| 5910 | m_errorMonitor->VerifyNotFound(); |
| 5911 | } |
| 5912 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5913 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5914 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5915 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5916 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5917 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5918 | |
| 5919 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5920 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5921 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5922 | "out gl_PerVertex {\n" |
| 5923 | " vec4 gl_Position;\n" |
| 5924 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5925 | "void main(){\n" |
| 5926 | " gl_Position = vec4(1);\n" |
| 5927 | "}\n"; |
| 5928 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5929 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5930 | "\n" |
| 5931 | "void main(){\n" |
| 5932 | "}\n"; |
| 5933 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5934 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5935 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5936 | |
| 5937 | VkPipelineObj pipe(m_device); |
| 5938 | pipe.AddShader(&vs); |
| 5939 | pipe.AddShader(&fs); |
| 5940 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5941 | /* set up CB 0, not written */ |
| 5942 | pipe.AddColorAttachment(); |
| 5943 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5944 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5945 | VkDescriptorSetObj descriptorSet(m_device); |
| 5946 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5947 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5948 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5949 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5950 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5951 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5952 | } |
| 5953 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5954 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5955 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5956 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5957 | "FS writes to output location 1 with no matching attachment"); |
| 5958 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5959 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5960 | |
| 5961 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5962 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5963 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5964 | "out gl_PerVertex {\n" |
| 5965 | " vec4 gl_Position;\n" |
| 5966 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5967 | "void main(){\n" |
| 5968 | " gl_Position = vec4(1);\n" |
| 5969 | "}\n"; |
| 5970 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 5971 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5972 | "\n" |
| 5973 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5974 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5975 | "void main(){\n" |
| 5976 | " x = vec4(1);\n" |
| 5977 | " y = vec4(1);\n" |
| 5978 | "}\n"; |
| 5979 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5980 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5981 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5982 | |
| 5983 | VkPipelineObj pipe(m_device); |
| 5984 | pipe.AddShader(&vs); |
| 5985 | pipe.AddShader(&fs); |
| 5986 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5987 | /* set up CB 0, not written */ |
| 5988 | pipe.AddColorAttachment(); |
| 5989 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5990 | /* FS writes CB 1, but we don't configure it */ |
| 5991 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5992 | VkDescriptorSetObj descriptorSet(m_device); |
| 5993 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5994 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5995 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5996 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5997 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5998 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5999 | } |
| 6000 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6001 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6002 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6003 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6004 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6005 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6006 | |
| 6007 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6008 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6009 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6010 | "out gl_PerVertex {\n" |
| 6011 | " vec4 gl_Position;\n" |
| 6012 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6013 | "void main(){\n" |
| 6014 | " gl_Position = vec4(1);\n" |
| 6015 | "}\n"; |
| 6016 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6017 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6018 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6019 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6020 | "void main(){\n" |
| 6021 | " x = ivec4(1);\n" |
| 6022 | "}\n"; |
| 6023 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6024 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6025 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6026 | |
| 6027 | VkPipelineObj pipe(m_device); |
| 6028 | pipe.AddShader(&vs); |
| 6029 | pipe.AddShader(&fs); |
| 6030 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6031 | /* set up CB 0; type is UNORM by default */ |
| 6032 | pipe.AddColorAttachment(); |
| 6033 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6034 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6035 | VkDescriptorSetObj descriptorSet(m_device); |
| 6036 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6037 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6038 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6039 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6040 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6041 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6042 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 6043 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6044 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6045 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6046 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6047 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6048 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6049 | |
| 6050 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6051 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6052 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6053 | "out gl_PerVertex {\n" |
| 6054 | " vec4 gl_Position;\n" |
| 6055 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6056 | "void main(){\n" |
| 6057 | " gl_Position = vec4(1);\n" |
| 6058 | "}\n"; |
| 6059 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6060 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6061 | "\n" |
| 6062 | "layout(location=0) out vec4 x;\n" |
| 6063 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 6064 | "void main(){\n" |
| 6065 | " x = vec4(bar.y);\n" |
| 6066 | "}\n"; |
| 6067 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6068 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6069 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6070 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6071 | VkPipelineObj pipe(m_device); |
| 6072 | pipe.AddShader(&vs); |
| 6073 | pipe.AddShader(&fs); |
| 6074 | |
| 6075 | /* set up CB 0; type is UNORM by default */ |
| 6076 | pipe.AddColorAttachment(); |
| 6077 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6078 | |
| 6079 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6080 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6081 | |
| 6082 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6083 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6084 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 6085 | } |
| 6086 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 6087 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 6088 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6089 | "not declared in layout"); |
| 6090 | |
| 6091 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6092 | |
| 6093 | char const *vsSource = |
| 6094 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 6095 | "\n" |
| 6096 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 6097 | "out gl_PerVertex {\n" |
| 6098 | " vec4 gl_Position;\n" |
| 6099 | "};\n" |
| 6100 | "void main(){\n" |
| 6101 | " gl_Position = vec4(consts.x);\n" |
| 6102 | "}\n"; |
| 6103 | char const *fsSource = |
| 6104 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 6105 | "\n" |
| 6106 | "layout(location=0) out vec4 x;\n" |
| 6107 | "void main(){\n" |
| 6108 | " x = vec4(1);\n" |
| 6109 | "}\n"; |
| 6110 | |
| 6111 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6112 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6113 | |
| 6114 | VkPipelineObj pipe(m_device); |
| 6115 | pipe.AddShader(&vs); |
| 6116 | pipe.AddShader(&fs); |
| 6117 | |
| 6118 | /* set up CB 0; type is UNORM by default */ |
| 6119 | pipe.AddColorAttachment(); |
| 6120 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6121 | |
| 6122 | VkDescriptorSetObj descriptorSet(m_device); |
| 6123 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6124 | |
| 6125 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6126 | |
| 6127 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6128 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 6129 | } |
| 6130 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6131 | #endif // SHADER_CHECKER_TESTS |
| 6132 | |
| 6133 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 6134 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6135 | m_errorMonitor->SetDesiredFailureMsg( |
| 6136 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6137 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6138 | |
| 6139 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6140 | |
| 6141 | // Create an image |
| 6142 | VkImage image; |
| 6143 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6144 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6145 | const int32_t tex_width = 32; |
| 6146 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6147 | |
| 6148 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6149 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6150 | image_create_info.pNext = NULL; |
| 6151 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6152 | image_create_info.format = tex_format; |
| 6153 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6154 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6155 | image_create_info.extent.depth = 1; |
| 6156 | image_create_info.mipLevels = 1; |
| 6157 | image_create_info.arrayLayers = 1; |
| 6158 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6159 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6160 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6161 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6162 | |
| 6163 | // Introduce error by sending down a bogus width extent |
| 6164 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6165 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6166 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6167 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 6168 | } |
| 6169 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 6170 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 6171 | m_errorMonitor->SetDesiredFailureMsg( |
| 6172 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6173 | "CreateImage extents is 0 for at least one required dimension"); |
| 6174 | |
| 6175 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6176 | |
| 6177 | // Create an image |
| 6178 | VkImage image; |
| 6179 | |
| 6180 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6181 | const int32_t tex_width = 32; |
| 6182 | const int32_t tex_height = 32; |
| 6183 | |
| 6184 | VkImageCreateInfo image_create_info = {}; |
| 6185 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6186 | image_create_info.pNext = NULL; |
| 6187 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6188 | image_create_info.format = tex_format; |
| 6189 | image_create_info.extent.width = tex_width; |
| 6190 | image_create_info.extent.height = tex_height; |
| 6191 | image_create_info.extent.depth = 1; |
| 6192 | image_create_info.mipLevels = 1; |
| 6193 | image_create_info.arrayLayers = 1; |
| 6194 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6195 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6196 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6197 | image_create_info.flags = 0; |
| 6198 | |
| 6199 | // Introduce error by sending down a bogus width extent |
| 6200 | image_create_info.extent.width = 0; |
| 6201 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 6202 | |
| 6203 | m_errorMonitor->VerifyFound(); |
| 6204 | } |
| 6205 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6206 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 6207 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -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 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6211 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6212 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6213 | |
| 6214 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6215 | vk_testing::Buffer buffer; |
| 6216 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 6217 | |
| 6218 | BeginCommandBuffer(); |
| 6219 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6220 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6221 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6222 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6223 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6224 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6225 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6226 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6227 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6228 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6229 | EndCommandBuffer(); |
| 6230 | } |
| 6231 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6232 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6233 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6234 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6235 | |
| 6236 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6237 | |
| 6238 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6239 | vk_testing::Buffer buffer; |
| 6240 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 6241 | |
| 6242 | BeginCommandBuffer(); |
| 6243 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6244 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6245 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6246 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6247 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6248 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6249 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6250 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6251 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6252 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6253 | m_errorMonitor->VerifyFound(); |
| 6254 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6255 | EndCommandBuffer(); |
| 6256 | } |
| 6257 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6258 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 6259 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6260 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6261 | TEST_F(VkLayerTest, InvalidImageView) { |
| 6262 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6263 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6264 | m_errorMonitor->SetDesiredFailureMsg( |
| 6265 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6266 | "vkCreateImageView called with baseMipLevel 10 "); |
| 6267 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6268 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6269 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6270 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6271 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6272 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6273 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6274 | const int32_t tex_width = 32; |
| 6275 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6276 | |
| 6277 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6278 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6279 | image_create_info.pNext = NULL; |
| 6280 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6281 | image_create_info.format = tex_format; |
| 6282 | image_create_info.extent.width = tex_width; |
| 6283 | image_create_info.extent.height = tex_height; |
| 6284 | image_create_info.extent.depth = 1; |
| 6285 | image_create_info.mipLevels = 1; |
| 6286 | image_create_info.arrayLayers = 1; |
| 6287 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6288 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6289 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6290 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6291 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6292 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6293 | ASSERT_VK_SUCCESS(err); |
| 6294 | |
| 6295 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6296 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6297 | image_view_create_info.image = image; |
| 6298 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6299 | image_view_create_info.format = tex_format; |
| 6300 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6301 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 6302 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6303 | image_view_create_info.subresourceRange.aspectMask = |
| 6304 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6305 | |
| 6306 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6307 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6308 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6309 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6310 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6311 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6312 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6313 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 6314 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6315 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6316 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6317 | "vkCreateImageView: Color image " |
| 6318 | "formats must have ONLY the " |
| 6319 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6320 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6321 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6322 | |
| 6323 | // 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] | 6324 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6325 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6326 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6327 | const int32_t tex_width = 32; |
| 6328 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6329 | |
| 6330 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6331 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6332 | image_create_info.pNext = NULL; |
| 6333 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6334 | image_create_info.format = tex_format; |
| 6335 | image_create_info.extent.width = tex_width; |
| 6336 | image_create_info.extent.height = tex_height; |
| 6337 | image_create_info.extent.depth = 1; |
| 6338 | image_create_info.mipLevels = 1; |
| 6339 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6340 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6341 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 6342 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6343 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6344 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6345 | ASSERT_VK_SUCCESS(err); |
| 6346 | |
| 6347 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6348 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6349 | image_view_create_info.image = image; |
| 6350 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6351 | image_view_create_info.format = tex_format; |
| 6352 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 6353 | image_view_create_info.subresourceRange.levelCount = 1; |
| 6354 | // Cause an error by setting an invalid image aspect |
| 6355 | image_view_create_info.subresourceRange.aspectMask = |
| 6356 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6357 | |
| 6358 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6359 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 6360 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6361 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6362 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 6363 | } |
| 6364 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6365 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6366 | VkResult err; |
| 6367 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6368 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6369 | m_errorMonitor->SetDesiredFailureMsg( |
| 6370 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6371 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6372 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6373 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6374 | |
| 6375 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6376 | VkImage srcImage; |
| 6377 | VkImage dstImage; |
| 6378 | VkDeviceMemory srcMem; |
| 6379 | VkDeviceMemory destMem; |
| 6380 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6381 | |
| 6382 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6383 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6384 | image_create_info.pNext = NULL; |
| 6385 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6386 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6387 | image_create_info.extent.width = 32; |
| 6388 | image_create_info.extent.height = 32; |
| 6389 | image_create_info.extent.depth = 1; |
| 6390 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6391 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6392 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6393 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6394 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6395 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6396 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6397 | err = |
| 6398 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6399 | ASSERT_VK_SUCCESS(err); |
| 6400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6401 | err = |
| 6402 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6403 | ASSERT_VK_SUCCESS(err); |
| 6404 | |
| 6405 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6406 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6407 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6408 | memAlloc.pNext = NULL; |
| 6409 | memAlloc.allocationSize = 0; |
| 6410 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6411 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6412 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6413 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6414 | pass = |
| 6415 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6416 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6417 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6418 | ASSERT_VK_SUCCESS(err); |
| 6419 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6420 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6421 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6422 | pass = |
| 6423 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6424 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6425 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6426 | ASSERT_VK_SUCCESS(err); |
| 6427 | |
| 6428 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6429 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6430 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6431 | ASSERT_VK_SUCCESS(err); |
| 6432 | |
| 6433 | BeginCommandBuffer(); |
| 6434 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6435 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6436 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6437 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6438 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6439 | copyRegion.srcOffset.x = 0; |
| 6440 | copyRegion.srcOffset.y = 0; |
| 6441 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6442 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6443 | copyRegion.dstSubresource.mipLevel = 0; |
| 6444 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6445 | // Introduce failure by forcing the dst layerCount to differ from src |
| 6446 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6447 | copyRegion.dstOffset.x = 0; |
| 6448 | copyRegion.dstOffset.y = 0; |
| 6449 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6450 | copyRegion.extent.width = 1; |
| 6451 | copyRegion.extent.height = 1; |
| 6452 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6453 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6454 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6455 | EndCommandBuffer(); |
| 6456 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6457 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6458 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6459 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6460 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6461 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6462 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6463 | } |
| 6464 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6465 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6466 | VkResult err; |
| 6467 | bool pass; |
| 6468 | |
| 6469 | // Create color images with different format sizes and try to copy between them |
| 6470 | m_errorMonitor->SetDesiredFailureMsg( |
| 6471 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6472 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 6473 | |
| 6474 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6475 | |
| 6476 | // Create two images of different types and try to copy between them |
| 6477 | VkImage srcImage; |
| 6478 | VkImage dstImage; |
| 6479 | VkDeviceMemory srcMem; |
| 6480 | VkDeviceMemory destMem; |
| 6481 | VkMemoryRequirements memReqs; |
| 6482 | |
| 6483 | VkImageCreateInfo image_create_info = {}; |
| 6484 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6485 | image_create_info.pNext = NULL; |
| 6486 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6487 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6488 | image_create_info.extent.width = 32; |
| 6489 | image_create_info.extent.height = 32; |
| 6490 | image_create_info.extent.depth = 1; |
| 6491 | image_create_info.mipLevels = 1; |
| 6492 | image_create_info.arrayLayers = 1; |
| 6493 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6494 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6495 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6496 | image_create_info.flags = 0; |
| 6497 | |
| 6498 | err = |
| 6499 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 6500 | ASSERT_VK_SUCCESS(err); |
| 6501 | |
| 6502 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 6503 | // Introduce failure by creating second image with a different-sized format. |
| 6504 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 6505 | |
| 6506 | err = |
| 6507 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 6508 | ASSERT_VK_SUCCESS(err); |
| 6509 | |
| 6510 | // Allocate memory |
| 6511 | VkMemoryAllocateInfo memAlloc = {}; |
| 6512 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6513 | memAlloc.pNext = NULL; |
| 6514 | memAlloc.allocationSize = 0; |
| 6515 | memAlloc.memoryTypeIndex = 0; |
| 6516 | |
| 6517 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 6518 | memAlloc.allocationSize = memReqs.size; |
| 6519 | pass = |
| 6520 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 6521 | ASSERT_TRUE(pass); |
| 6522 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 6523 | ASSERT_VK_SUCCESS(err); |
| 6524 | |
| 6525 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 6526 | memAlloc.allocationSize = memReqs.size; |
| 6527 | pass = |
| 6528 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 6529 | ASSERT_TRUE(pass); |
| 6530 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 6531 | ASSERT_VK_SUCCESS(err); |
| 6532 | |
| 6533 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6534 | ASSERT_VK_SUCCESS(err); |
| 6535 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 6536 | ASSERT_VK_SUCCESS(err); |
| 6537 | |
| 6538 | BeginCommandBuffer(); |
| 6539 | VkImageCopy copyRegion; |
| 6540 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6541 | copyRegion.srcSubresource.mipLevel = 0; |
| 6542 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 6543 | copyRegion.srcSubresource.layerCount = 0; |
| 6544 | copyRegion.srcOffset.x = 0; |
| 6545 | copyRegion.srcOffset.y = 0; |
| 6546 | copyRegion.srcOffset.z = 0; |
| 6547 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 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; |
| 6554 | copyRegion.extent.width = 1; |
| 6555 | copyRegion.extent.height = 1; |
| 6556 | copyRegion.extent.depth = 1; |
| 6557 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6558 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6559 | EndCommandBuffer(); |
| 6560 | |
| 6561 | m_errorMonitor->VerifyFound(); |
| 6562 | |
| 6563 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 6564 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 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, CopyImageDepthStencilFormatMismatch) { |
| 6570 | VkResult err; |
| 6571 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6572 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6573 | // 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] | 6574 | m_errorMonitor->SetDesiredFailureMsg( |
| 6575 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6576 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6577 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6578 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6579 | |
| 6580 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6581 | VkImage srcImage; |
| 6582 | VkImage dstImage; |
| 6583 | VkDeviceMemory srcMem; |
| 6584 | VkDeviceMemory destMem; |
| 6585 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6586 | |
| 6587 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6588 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6589 | image_create_info.pNext = NULL; |
| 6590 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6591 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6592 | image_create_info.extent.width = 32; |
| 6593 | image_create_info.extent.height = 32; |
| 6594 | image_create_info.extent.depth = 1; |
| 6595 | image_create_info.mipLevels = 1; |
| 6596 | image_create_info.arrayLayers = 1; |
| 6597 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6598 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6599 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6600 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6601 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6602 | err = |
| 6603 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6604 | ASSERT_VK_SUCCESS(err); |
| 6605 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6606 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 6607 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6608 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6609 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 6610 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6611 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6612 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6613 | err = |
| 6614 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6615 | ASSERT_VK_SUCCESS(err); |
| 6616 | |
| 6617 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6618 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6619 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6620 | memAlloc.pNext = NULL; |
| 6621 | memAlloc.allocationSize = 0; |
| 6622 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6623 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6624 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6625 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6626 | pass = |
| 6627 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6628 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6629 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6630 | ASSERT_VK_SUCCESS(err); |
| 6631 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6632 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6633 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6634 | pass = |
| 6635 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6636 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6637 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6638 | ASSERT_VK_SUCCESS(err); |
| 6639 | |
| 6640 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6641 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6642 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6643 | ASSERT_VK_SUCCESS(err); |
| 6644 | |
| 6645 | BeginCommandBuffer(); |
| 6646 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6647 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6648 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6649 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6650 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6651 | copyRegion.srcOffset.x = 0; |
| 6652 | copyRegion.srcOffset.y = 0; |
| 6653 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6654 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6655 | copyRegion.dstSubresource.mipLevel = 0; |
| 6656 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6657 | copyRegion.dstSubresource.layerCount = 0; |
| 6658 | copyRegion.dstOffset.x = 0; |
| 6659 | copyRegion.dstOffset.y = 0; |
| 6660 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6661 | copyRegion.extent.width = 1; |
| 6662 | copyRegion.extent.height = 1; |
| 6663 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6664 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6665 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6666 | EndCommandBuffer(); |
| 6667 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6668 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6669 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6670 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6671 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6672 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6673 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6674 | } |
| 6675 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6676 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 6677 | VkResult err; |
| 6678 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6679 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6680 | m_errorMonitor->SetDesiredFailureMsg( |
| 6681 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6682 | "vkCmdResolveImage called with source sample count less than 2."); |
| 6683 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6684 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6685 | |
| 6686 | // 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] | 6687 | VkImage srcImage; |
| 6688 | VkImage dstImage; |
| 6689 | VkDeviceMemory srcMem; |
| 6690 | VkDeviceMemory destMem; |
| 6691 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6692 | |
| 6693 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6694 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6695 | image_create_info.pNext = NULL; |
| 6696 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6697 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6698 | image_create_info.extent.width = 32; |
| 6699 | image_create_info.extent.height = 1; |
| 6700 | image_create_info.extent.depth = 1; |
| 6701 | image_create_info.mipLevels = 1; |
| 6702 | image_create_info.arrayLayers = 1; |
| 6703 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6704 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6705 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6706 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6707 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6708 | err = |
| 6709 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6710 | ASSERT_VK_SUCCESS(err); |
| 6711 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6712 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6713 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6714 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6715 | err = |
| 6716 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6717 | ASSERT_VK_SUCCESS(err); |
| 6718 | |
| 6719 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6720 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6721 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6722 | memAlloc.pNext = NULL; |
| 6723 | memAlloc.allocationSize = 0; |
| 6724 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6725 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6726 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6727 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6728 | pass = |
| 6729 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6730 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6731 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6732 | ASSERT_VK_SUCCESS(err); |
| 6733 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6734 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6735 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6736 | pass = |
| 6737 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6738 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6739 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6740 | ASSERT_VK_SUCCESS(err); |
| 6741 | |
| 6742 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6743 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6744 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6745 | ASSERT_VK_SUCCESS(err); |
| 6746 | |
| 6747 | BeginCommandBuffer(); |
| 6748 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6749 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6750 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6751 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6752 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6753 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6754 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6755 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6756 | resolveRegion.srcOffset.x = 0; |
| 6757 | resolveRegion.srcOffset.y = 0; |
| 6758 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6759 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6760 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6761 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6762 | resolveRegion.dstSubresource.layerCount = 0; |
| 6763 | resolveRegion.dstOffset.x = 0; |
| 6764 | resolveRegion.dstOffset.y = 0; |
| 6765 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6766 | resolveRegion.extent.width = 1; |
| 6767 | resolveRegion.extent.height = 1; |
| 6768 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6769 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6770 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6771 | EndCommandBuffer(); |
| 6772 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6773 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6774 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6775 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6776 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6777 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6778 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6779 | } |
| 6780 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6781 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 6782 | VkResult err; |
| 6783 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6784 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6785 | m_errorMonitor->SetDesiredFailureMsg( |
| 6786 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6787 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 6788 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6789 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6790 | |
| 6791 | // 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] | 6792 | VkImage srcImage; |
| 6793 | VkImage dstImage; |
| 6794 | VkDeviceMemory srcMem; |
| 6795 | VkDeviceMemory destMem; |
| 6796 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6797 | |
| 6798 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6799 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6800 | image_create_info.pNext = NULL; |
| 6801 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6802 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6803 | image_create_info.extent.width = 32; |
| 6804 | image_create_info.extent.height = 1; |
| 6805 | image_create_info.extent.depth = 1; |
| 6806 | image_create_info.mipLevels = 1; |
| 6807 | image_create_info.arrayLayers = 1; |
| 6808 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6809 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6810 | // Note: Some implementations expect color attachment usage for any |
| 6811 | // multisample surface |
| 6812 | image_create_info.usage = |
| 6813 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6814 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6815 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6816 | err = |
| 6817 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6818 | ASSERT_VK_SUCCESS(err); |
| 6819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6820 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 6821 | // Note: Some implementations expect color attachment usage for any |
| 6822 | // multisample surface |
| 6823 | image_create_info.usage = |
| 6824 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6825 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6826 | err = |
| 6827 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6828 | ASSERT_VK_SUCCESS(err); |
| 6829 | |
| 6830 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6831 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6832 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6833 | memAlloc.pNext = NULL; |
| 6834 | memAlloc.allocationSize = 0; |
| 6835 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6836 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6837 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6838 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6839 | pass = |
| 6840 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6841 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6842 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6843 | ASSERT_VK_SUCCESS(err); |
| 6844 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6845 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6846 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6847 | pass = |
| 6848 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6849 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6850 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6851 | ASSERT_VK_SUCCESS(err); |
| 6852 | |
| 6853 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6854 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6855 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6856 | ASSERT_VK_SUCCESS(err); |
| 6857 | |
| 6858 | BeginCommandBuffer(); |
| 6859 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6860 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6861 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6862 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6863 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6864 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6865 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6866 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6867 | resolveRegion.srcOffset.x = 0; |
| 6868 | resolveRegion.srcOffset.y = 0; |
| 6869 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6870 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6871 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6872 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6873 | resolveRegion.dstSubresource.layerCount = 0; |
| 6874 | resolveRegion.dstOffset.x = 0; |
| 6875 | resolveRegion.dstOffset.y = 0; |
| 6876 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6877 | resolveRegion.extent.width = 1; |
| 6878 | resolveRegion.extent.height = 1; |
| 6879 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6880 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6881 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6882 | EndCommandBuffer(); |
| 6883 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6884 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6885 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6886 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6887 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6888 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6889 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6890 | } |
| 6891 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6892 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 6893 | VkResult err; |
| 6894 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6895 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6896 | m_errorMonitor->SetDesiredFailureMsg( |
| 6897 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6898 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 6899 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6900 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6901 | |
| 6902 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6903 | VkImage srcImage; |
| 6904 | VkImage dstImage; |
| 6905 | VkDeviceMemory srcMem; |
| 6906 | VkDeviceMemory destMem; |
| 6907 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6908 | |
| 6909 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6910 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6911 | image_create_info.pNext = NULL; |
| 6912 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6913 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6914 | image_create_info.extent.width = 32; |
| 6915 | image_create_info.extent.height = 1; |
| 6916 | image_create_info.extent.depth = 1; |
| 6917 | image_create_info.mipLevels = 1; |
| 6918 | image_create_info.arrayLayers = 1; |
| 6919 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 6920 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6921 | // Note: Some implementations expect color attachment usage for any |
| 6922 | // multisample surface |
| 6923 | image_create_info.usage = |
| 6924 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6925 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6926 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6927 | err = |
| 6928 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6929 | ASSERT_VK_SUCCESS(err); |
| 6930 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6931 | // Set format to something other than source image |
| 6932 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 6933 | // Note: Some implementations expect color attachment usage for any |
| 6934 | // multisample surface |
| 6935 | image_create_info.usage = |
| 6936 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 6937 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6938 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6939 | err = |
| 6940 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6941 | ASSERT_VK_SUCCESS(err); |
| 6942 | |
| 6943 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6944 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6945 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 6946 | memAlloc.pNext = NULL; |
| 6947 | memAlloc.allocationSize = 0; |
| 6948 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6949 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6950 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6951 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6952 | pass = |
| 6953 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6954 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6955 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6956 | ASSERT_VK_SUCCESS(err); |
| 6957 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6958 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6959 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6960 | pass = |
| 6961 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6962 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6963 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6964 | ASSERT_VK_SUCCESS(err); |
| 6965 | |
| 6966 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6967 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6968 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6969 | ASSERT_VK_SUCCESS(err); |
| 6970 | |
| 6971 | BeginCommandBuffer(); |
| 6972 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6973 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6974 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6975 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6976 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6977 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6978 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6979 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6980 | resolveRegion.srcOffset.x = 0; |
| 6981 | resolveRegion.srcOffset.y = 0; |
| 6982 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6983 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6984 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6985 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6986 | resolveRegion.dstSubresource.layerCount = 0; |
| 6987 | resolveRegion.dstOffset.x = 0; |
| 6988 | resolveRegion.dstOffset.y = 0; |
| 6989 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6990 | resolveRegion.extent.width = 1; |
| 6991 | resolveRegion.extent.height = 1; |
| 6992 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6993 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 6994 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6995 | EndCommandBuffer(); |
| 6996 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6997 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6998 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6999 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7000 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7001 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 7002 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7003 | } |
| 7004 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7005 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 7006 | VkResult err; |
| 7007 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7008 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7009 | m_errorMonitor->SetDesiredFailureMsg( |
| 7010 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7011 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 7012 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7013 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7014 | |
| 7015 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7016 | VkImage srcImage; |
| 7017 | VkImage dstImage; |
| 7018 | VkDeviceMemory srcMem; |
| 7019 | VkDeviceMemory destMem; |
| 7020 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7021 | |
| 7022 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7023 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7024 | image_create_info.pNext = NULL; |
| 7025 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7026 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7027 | image_create_info.extent.width = 32; |
| 7028 | image_create_info.extent.height = 1; |
| 7029 | image_create_info.extent.depth = 1; |
| 7030 | image_create_info.mipLevels = 1; |
| 7031 | image_create_info.arrayLayers = 1; |
| 7032 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 7033 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7034 | // Note: Some implementations expect color attachment usage for any |
| 7035 | // multisample surface |
| 7036 | image_create_info.usage = |
| 7037 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 7038 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7039 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7040 | err = |
| 7041 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7042 | ASSERT_VK_SUCCESS(err); |
| 7043 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7044 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 7045 | // Note: Some implementations expect color attachment usage for any |
| 7046 | // multisample surface |
| 7047 | image_create_info.usage = |
| 7048 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 7049 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7050 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7051 | err = |
| 7052 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7053 | ASSERT_VK_SUCCESS(err); |
| 7054 | |
| 7055 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7056 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7057 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 7058 | memAlloc.pNext = NULL; |
| 7059 | memAlloc.allocationSize = 0; |
| 7060 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7061 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 7062 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7063 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7064 | pass = |
| 7065 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 7066 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7067 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7068 | ASSERT_VK_SUCCESS(err); |
| 7069 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7070 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7071 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7072 | pass = |
| 7073 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 7074 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7075 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7076 | ASSERT_VK_SUCCESS(err); |
| 7077 | |
| 7078 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 7079 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7080 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7081 | ASSERT_VK_SUCCESS(err); |
| 7082 | |
| 7083 | BeginCommandBuffer(); |
| 7084 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7085 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 7086 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7087 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 7088 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7089 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 7090 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7091 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7092 | resolveRegion.srcOffset.x = 0; |
| 7093 | resolveRegion.srcOffset.y = 0; |
| 7094 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 7095 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7096 | resolveRegion.dstSubresource.mipLevel = 0; |
| 7097 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 7098 | resolveRegion.dstSubresource.layerCount = 0; |
| 7099 | resolveRegion.dstOffset.x = 0; |
| 7100 | resolveRegion.dstOffset.y = 0; |
| 7101 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7102 | resolveRegion.extent.width = 1; |
| 7103 | resolveRegion.extent.height = 1; |
| 7104 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7105 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 7106 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7107 | EndCommandBuffer(); |
| 7108 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7109 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7110 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7111 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7112 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7113 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 7114 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7115 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7116 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7117 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7118 | // 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] | 7119 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 7120 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7121 | // The image format check comes 2nd in validation so we trigger it first, |
| 7122 | // 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] | 7123 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7124 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7125 | m_errorMonitor->SetDesiredFailureMsg( |
| 7126 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7127 | "Combination depth/stencil image formats can have only the "); |
| 7128 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7129 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7130 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7131 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7132 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 7133 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7134 | |
| 7135 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7136 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7137 | ds_pool_ci.pNext = NULL; |
| 7138 | ds_pool_ci.maxSets = 1; |
| 7139 | ds_pool_ci.poolSizeCount = 1; |
| 7140 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7141 | |
| 7142 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7143 | err = |
| 7144 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7145 | ASSERT_VK_SUCCESS(err); |
| 7146 | |
| 7147 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7148 | dsl_binding.binding = 0; |
| 7149 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 7150 | dsl_binding.descriptorCount = 1; |
| 7151 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7152 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7153 | |
| 7154 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7155 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7156 | ds_layout_ci.pNext = NULL; |
| 7157 | ds_layout_ci.bindingCount = 1; |
| 7158 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7159 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7160 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7161 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7162 | ASSERT_VK_SUCCESS(err); |
| 7163 | |
| 7164 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7165 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7166 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7167 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7168 | alloc_info.descriptorPool = ds_pool; |
| 7169 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7170 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7171 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7172 | ASSERT_VK_SUCCESS(err); |
| 7173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7174 | VkImage image_bad; |
| 7175 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7176 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7177 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7178 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7179 | const int32_t tex_width = 32; |
| 7180 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7181 | |
| 7182 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7183 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7184 | image_create_info.pNext = NULL; |
| 7185 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7186 | image_create_info.format = tex_format_bad; |
| 7187 | image_create_info.extent.width = tex_width; |
| 7188 | image_create_info.extent.height = tex_height; |
| 7189 | image_create_info.extent.depth = 1; |
| 7190 | image_create_info.mipLevels = 1; |
| 7191 | image_create_info.arrayLayers = 1; |
| 7192 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7193 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7194 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 7195 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 7196 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7198 | err = |
| 7199 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7200 | ASSERT_VK_SUCCESS(err); |
| 7201 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7202 | image_create_info.usage = |
| 7203 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 7204 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 7205 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7206 | ASSERT_VK_SUCCESS(err); |
| 7207 | |
| 7208 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7209 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7210 | image_view_create_info.image = image_bad; |
| 7211 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7212 | image_view_create_info.format = tex_format_bad; |
| 7213 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 7214 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 7215 | image_view_create_info.subresourceRange.layerCount = 1; |
| 7216 | image_view_create_info.subresourceRange.levelCount = 1; |
| 7217 | image_view_create_info.subresourceRange.aspectMask = |
| 7218 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7219 | |
| 7220 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7221 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 7222 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7223 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7224 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7225 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7226 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 7227 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7228 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7229 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7230 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7231 | #endif // IMAGE_TESTS |
| 7232 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7233 | int main(int argc, char **argv) { |
| 7234 | int result; |
| 7235 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 7236 | #ifdef ANDROID |
| 7237 | int vulkanSupport = InitVulkan(); |
| 7238 | if (vulkanSupport == 0) |
| 7239 | return 1; |
| 7240 | #endif |
| 7241 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7242 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 7243 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7244 | |
| 7245 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 7246 | |
| 7247 | result = RUN_ALL_TESTS(); |
| 7248 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 7249 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7250 | return result; |
| 7251 | } |