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 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 120 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
| 121 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 122 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 123 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 124 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 125 | m_failureMsg.clear(); |
| 126 | m_otherMsgs.clear(); |
| 127 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 128 | m_msgFound = VK_FALSE; |
| 129 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 130 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 131 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 132 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 133 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 134 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 135 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 136 | if (m_bailout != NULL) { |
| 137 | *m_bailout = true; |
| 138 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 139 | string errorString(msgString); |
| 140 | if (msgFlags & m_msgFlags) { |
| 141 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 142 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 143 | m_otherMsgs.push_back(m_failureMsg); |
| 144 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 145 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 146 | m_msgFound = VK_TRUE; |
| 147 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 148 | } else { |
| 149 | m_otherMsgs.push_back(errorString); |
| 150 | } |
| 151 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 152 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 153 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 154 | } |
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 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
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 | string GetFailureMsg(void) { return m_failureMsg; } |
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 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 161 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 162 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 163 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 164 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 165 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 166 | cout << "Other error messages logged for this test were:" << endl; |
| 167 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 168 | cout << " " << *iter << endl; |
| 169 | } |
| 170 | } |
| 171 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 172 | /* helpers */ |
| 173 | |
| 174 | void ExpectSuccess() { |
| 175 | // match anything |
| 176 | SetDesiredFailureMsg(~0u, ""); |
| 177 | } |
| 178 | |
| 179 | void VerifyFound() { |
| 180 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 181 | // any other messages. |
| 182 | if (!DesiredMsgFound()) { |
| 183 | DumpFailureMsgs(); |
| 184 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | void VerifyNotFound() { |
| 189 | // ExpectSuccess() configured us to match anything. Any error is a |
| 190 | // failure. |
| 191 | if (DesiredMsgFound()) { |
| 192 | DumpFailureMsgs(); |
| 193 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 194 | } |
| 195 | } |
| 196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 197 | private: |
| 198 | VkFlags m_msgFlags; |
| 199 | string m_desiredMsg; |
| 200 | string m_failureMsg; |
| 201 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 202 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 203 | bool *m_bailout; |
| 204 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 205 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 206 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 207 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 208 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 209 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 210 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 211 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 212 | (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] | 213 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 214 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 215 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 216 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 217 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 218 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 219 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 220 | class VkLayerTest : public VkRenderFramework { |
| 221 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 222 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 223 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 224 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 225 | BsoFailSelect failMask); |
| 226 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 227 | VkPipelineObj &pipelineobj, |
| 228 | VkDescriptorSetObj &descriptorSet, |
| 229 | BsoFailSelect failMask); |
| 230 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 231 | VkDescriptorSetObj &descriptorSet, |
| 232 | BsoFailSelect failMask) { |
| 233 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 234 | failMask); |
| 235 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 236 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 237 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 238 | VkResult BeginCommandBuffer() { |
| 239 | return BeginCommandBuffer(*m_commandBuffer); |
| 240 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 241 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 242 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 243 | uint32_t firstVertex, uint32_t firstInstance) { |
| 244 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 245 | firstInstance); |
| 246 | } |
| 247 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 248 | uint32_t firstIndex, int32_t vertexOffset, |
| 249 | uint32_t firstInstance) { |
| 250 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 251 | vertexOffset, firstInstance); |
| 252 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 253 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 254 | void QueueCommandBuffer(const VkFence &fence) { |
| 255 | m_commandBuffer->QueueCommandBuffer(fence); |
| 256 | } |
| 257 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 258 | VkDeviceSize offset, uint32_t binding) { |
| 259 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 260 | } |
| 261 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 262 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 263 | } |
| 264 | |
| 265 | protected: |
| 266 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 267 | |
| 268 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 269 | std::vector<const char *> instance_layer_names; |
| 270 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 271 | std::vector<const char *> instance_extension_names; |
| 272 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 273 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 274 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 275 | /* |
| 276 | * Since CreateDbgMsgCallback is an instance level extension call |
| 277 | * any extension / layer that utilizes that feature also needs |
| 278 | * to be enabled at create instance time. |
| 279 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 280 | // Use Threading layer first to protect others from |
| 281 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 282 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 283 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 284 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 289 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 290 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 291 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 292 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 293 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 296 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 297 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 298 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 299 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 300 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 301 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 302 | this->app_info.pApplicationName = "layer_tests"; |
| 303 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 304 | this->app_info.pEngineName = "unittest"; |
| 305 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 306 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 307 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 308 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 309 | InitFramework(instance_layer_names, device_layer_names, |
| 310 | instance_extension_names, device_extension_names, |
| 311 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | virtual void TearDown() { |
| 315 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 316 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 317 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 318 | } |
| 319 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 320 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 321 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 322 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 323 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 324 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 325 | |
| 326 | /* |
| 327 | * For render test all drawing happens in a single render pass |
| 328 | * on a single command buffer. |
| 329 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 330 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 331 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | return result; |
| 335 | } |
| 336 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 337 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 338 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 339 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 340 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 341 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 342 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 343 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 344 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 345 | |
| 346 | return result; |
| 347 | } |
| 348 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 349 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 350 | const char *fragShaderText, |
| 351 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 352 | // Create identity matrix |
| 353 | int i; |
| 354 | struct vktriangle_vs_uniform data; |
| 355 | |
| 356 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 357 | glm::mat4 View = glm::mat4(1.0f); |
| 358 | glm::mat4 Model = glm::mat4(1.0f); |
| 359 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 360 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 361 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 362 | |
| 363 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 364 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 365 | static const Vertex tri_data[] = { |
| 366 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 367 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 368 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 369 | }; |
| 370 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 371 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 372 | data.position[i][0] = tri_data[i].posX; |
| 373 | data.position[i][1] = tri_data[i].posY; |
| 374 | data.position[i][2] = tri_data[i].posZ; |
| 375 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 376 | data.color[i][0] = tri_data[i].r; |
| 377 | data.color[i][1] = tri_data[i].g; |
| 378 | data.color[i][2] = tri_data[i].b; |
| 379 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 383 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 384 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 385 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 386 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 387 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 388 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 389 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 390 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 391 | |
| 392 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 393 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 394 | pipelineobj.AddShader(&vs); |
| 395 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 396 | if (failMask & BsoFailLineWidth) { |
| 397 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 398 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 399 | ia_state.sType = |
| 400 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 401 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 402 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 403 | } |
| 404 | if (failMask & BsoFailDepthBias) { |
| 405 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 406 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 407 | rs_state.sType = |
| 408 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 409 | rs_state.depthBiasEnable = VK_TRUE; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 410 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 411 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 412 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 413 | // Viewport and scissors must stay in synch or other errors will occur than |
| 414 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 415 | if (failMask & BsoFailViewport) { |
| 416 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 417 | m_viewports.clear(); |
| 418 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 419 | } |
| 420 | if (failMask & BsoFailScissor) { |
| 421 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 422 | m_scissors.clear(); |
| 423 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 424 | } |
| 425 | if (failMask & BsoFailBlend) { |
| 426 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 427 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 428 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 429 | att_state.blendEnable = VK_TRUE; |
| 430 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 431 | } |
| 432 | if (failMask & BsoFailDepthBounds) { |
| 433 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 434 | } |
| 435 | if (failMask & BsoFailStencilReadMask) { |
| 436 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 437 | } |
| 438 | if (failMask & BsoFailStencilWriteMask) { |
| 439 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 440 | } |
| 441 | if (failMask & BsoFailStencilReference) { |
| 442 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 443 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 444 | |
| 445 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 446 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 447 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 448 | |
| 449 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 450 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 451 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 452 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 453 | |
| 454 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 455 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 456 | |
| 457 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 458 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 459 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 460 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 461 | } |
| 462 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 463 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 464 | VkPipelineObj &pipelineobj, |
| 465 | VkDescriptorSetObj &descriptorSet, |
| 466 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 467 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 468 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 469 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 470 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 471 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 472 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 473 | } |
| 474 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 475 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 476 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 477 | // correctly |
| 478 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 479 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 480 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 481 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 482 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 483 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 484 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 485 | |
| 486 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 487 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 488 | ds_ci.pNext = NULL; |
| 489 | ds_ci.depthTestEnable = VK_FALSE; |
| 490 | ds_ci.depthWriteEnable = VK_TRUE; |
| 491 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 492 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 493 | if (failMask & BsoFailDepthBounds) { |
| 494 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
| 495 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 496 | ds_ci.stencilTestEnable = VK_TRUE; |
| 497 | ds_ci.front = stencil; |
| 498 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 499 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 500 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 501 | pipelineobj.SetViewport(m_viewports); |
| 502 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 503 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 504 | VkResult err = pipelineobj.CreateVKPipeline( |
| 505 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 506 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 507 | commandBuffer->BindPipeline(pipelineobj); |
| 508 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | // ******************************************************************************************************************** |
| 512 | // ******************************************************************************************************************** |
| 513 | // ******************************************************************************************************************** |
| 514 | // ******************************************************************************************************************** |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 515 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 516 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 517 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 518 | { |
| 519 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 520 | VkFenceCreateInfo fenceInfo = {}; |
| 521 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 522 | fenceInfo.pNext = NULL; |
| 523 | fenceInfo.flags = 0; |
| 524 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 525 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 526 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 527 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 528 | |
| 529 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 530 | vk_testing::Buffer buffer; |
| 531 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 532 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 533 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 534 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 535 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 536 | |
| 537 | testFence.init(*m_device, fenceInfo); |
| 538 | |
| 539 | // Bypass framework since it does the waits automatically |
| 540 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 541 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 542 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 543 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 544 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 545 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 546 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 547 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 548 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 549 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 550 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 551 | |
| 552 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 553 | ASSERT_VK_SUCCESS( err ); |
| 554 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 555 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 556 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 557 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 558 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 559 | } |
| 560 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 561 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 562 | { |
| 563 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 564 | VkFenceCreateInfo fenceInfo = {}; |
| 565 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 566 | fenceInfo.pNext = NULL; |
| 567 | fenceInfo.flags = 0; |
| 568 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 569 | 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] | 570 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 571 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 572 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 573 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 574 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 575 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 576 | 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] | 577 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 578 | |
| 579 | testFence.init(*m_device, fenceInfo); |
| 580 | |
| 581 | // Bypass framework since it does the waits automatically |
| 582 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 583 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 584 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 585 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 586 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 587 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 588 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 589 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 590 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 591 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 592 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 593 | |
| 594 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 595 | ASSERT_VK_SUCCESS( err ); |
| 596 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 597 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 598 | VkCommandBufferBeginInfo info = {}; |
| 599 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 600 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 601 | info.renderPass = VK_NULL_HANDLE; |
| 602 | info.subpass = 0; |
| 603 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 604 | info.occlusionQueryEnable = VK_FALSE; |
| 605 | info.queryFlags = 0; |
| 606 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 607 | |
| 608 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 609 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 610 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 611 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 612 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 613 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 614 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 615 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 616 | VkResult err; |
| 617 | bool pass; |
| 618 | |
| 619 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
| 620 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 621 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 622 | uint32_t swapchain_image_count = 0; |
| 623 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 624 | uint32_t image_index = 0; |
| 625 | // VkPresentInfoKHR present_info = {}; |
| 626 | |
| 627 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 628 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 629 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 630 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 631 | // Use the functions from the VK_KHR_android_surface extension without |
| 632 | // enabling that extension: |
| 633 | |
| 634 | // Create a surface: |
| 635 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
| 636 | #if 0 |
| 637 | #endif |
| 638 | m_errorMonitor->SetDesiredFailureMsg( |
| 639 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 640 | "extension was not enabled for this"); |
| 641 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 642 | &surface); |
| 643 | pass = (err != VK_SUCCESS); |
| 644 | ASSERT_TRUE(pass); |
| 645 | m_errorMonitor->VerifyFound(); |
| 646 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 647 | |
| 648 | |
| 649 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 650 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 651 | // that extension: |
| 652 | |
| 653 | // Create a surface: |
| 654 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
| 655 | #if 0 |
| 656 | #endif |
| 657 | m_errorMonitor->SetDesiredFailureMsg( |
| 658 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 659 | "extension was not enabled for this"); |
| 660 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 661 | pass = (err != VK_SUCCESS); |
| 662 | ASSERT_TRUE(pass); |
| 663 | m_errorMonitor->VerifyFound(); |
| 664 | |
| 665 | // Tell whether an mir_connection supports presentation: |
| 666 | MirConnection *mir_connection = NULL; |
| 667 | m_errorMonitor->SetDesiredFailureMsg( |
| 668 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 669 | "extension was not enabled for this"); |
| 670 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 671 | visual_id); |
| 672 | m_errorMonitor->VerifyFound(); |
| 673 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 674 | |
| 675 | |
| 676 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 677 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 678 | // enabling that extension: |
| 679 | |
| 680 | // Create a surface: |
| 681 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
| 682 | #if 0 |
| 683 | #endif |
| 684 | m_errorMonitor->SetDesiredFailureMsg( |
| 685 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 686 | "extension was not enabled for this"); |
| 687 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 688 | &surface); |
| 689 | pass = (err != VK_SUCCESS); |
| 690 | ASSERT_TRUE(pass); |
| 691 | m_errorMonitor->VerifyFound(); |
| 692 | |
| 693 | // Tell whether an wayland_display supports presentation: |
| 694 | struct wl_display wayland_display = {}; |
| 695 | m_errorMonitor->SetDesiredFailureMsg( |
| 696 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 697 | "extension was not enabled for this"); |
| 698 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 699 | &wayland_display); |
| 700 | m_errorMonitor->VerifyFound(); |
| 701 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 702 | |
| 703 | |
| 704 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
| 705 | // Use the functions from the VK_KHR_win32_surface extension without |
| 706 | // enabling that extension: |
| 707 | |
| 708 | // Create a surface: |
| 709 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
| 710 | #if 0 |
| 711 | #endif |
| 712 | m_errorMonitor->SetDesiredFailureMsg( |
| 713 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 714 | "extension was not enabled for this"); |
| 715 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 716 | &surface); |
| 717 | pass = (err != VK_SUCCESS); |
| 718 | ASSERT_TRUE(pass); |
| 719 | m_errorMonitor->VerifyFound(); |
| 720 | |
| 721 | // Tell whether win32 supports presentation: |
| 722 | struct wl_display win32_display = {}; |
| 723 | m_errorMonitor->SetDesiredFailureMsg( |
| 724 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 725 | "extension was not enabled for this"); |
| 726 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0, |
| 727 | &win32_display); |
| 728 | m_errorMonitor->VerifyFound(); |
| 729 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 730 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
| 731 | |
| 732 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 733 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 734 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 735 | // that extension: |
| 736 | |
| 737 | // Create a surface: |
| 738 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 739 | #if 0 |
| 740 | #endif |
| 741 | m_errorMonitor->SetDesiredFailureMsg( |
| 742 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 743 | "extension was not enabled for this"); |
| 744 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 745 | pass = (err != VK_SUCCESS); |
| 746 | ASSERT_TRUE(pass); |
| 747 | m_errorMonitor->VerifyFound(); |
| 748 | |
| 749 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 750 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 751 | xcb_visualid_t visual_id = 0; |
| 752 | m_errorMonitor->SetDesiredFailureMsg( |
| 753 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 754 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 755 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 756 | visual_id); |
| 757 | m_errorMonitor->VerifyFound(); |
| 758 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 759 | |
| 760 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 761 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 762 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 763 | // that extension: |
| 764 | |
| 765 | // Create a surface: |
| 766 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
| 767 | #if 0 |
| 768 | #endif |
| 769 | m_errorMonitor->SetDesiredFailureMsg( |
| 770 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 771 | "extension was not enabled for this"); |
| 772 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 773 | pass = (err != VK_SUCCESS); |
| 774 | ASSERT_TRUE(pass); |
| 775 | m_errorMonitor->VerifyFound(); |
| 776 | |
| 777 | // Tell whether an Xlib VisualID supports presentation: |
| 778 | Display *dpy = NULL; |
| 779 | VisualID visual = 0; |
| 780 | m_errorMonitor->SetDesiredFailureMsg( |
| 781 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 782 | "extension was not enabled for this"); |
| 783 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 784 | m_errorMonitor->VerifyFound(); |
| 785 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 786 | |
| 787 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 788 | // Use the functions from the VK_KHR_surface extension without enabling |
| 789 | // that extension: |
| 790 | |
| 791 | // Destroy a surface: |
| 792 | m_errorMonitor->SetDesiredFailureMsg( |
| 793 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 794 | "extension was not enabled for this"); |
| 795 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 796 | m_errorMonitor->VerifyFound(); |
| 797 | |
| 798 | // Check if surface supports presentation: |
| 799 | VkBool32 supported = false; |
| 800 | m_errorMonitor->SetDesiredFailureMsg( |
| 801 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 802 | "extension was not enabled for this"); |
| 803 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 804 | pass = (err != VK_SUCCESS); |
| 805 | ASSERT_TRUE(pass); |
| 806 | m_errorMonitor->VerifyFound(); |
| 807 | |
| 808 | // Check surface capabilities: |
| 809 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 810 | m_errorMonitor->SetDesiredFailureMsg( |
| 811 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 812 | "extension was not enabled for this"); |
| 813 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 814 | &capabilities); |
| 815 | pass = (err != VK_SUCCESS); |
| 816 | ASSERT_TRUE(pass); |
| 817 | m_errorMonitor->VerifyFound(); |
| 818 | |
| 819 | // Check surface formats: |
| 820 | uint32_t format_count = 0; |
| 821 | VkSurfaceFormatKHR *formats = NULL; |
| 822 | m_errorMonitor->SetDesiredFailureMsg( |
| 823 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 824 | "extension was not enabled for this"); |
| 825 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 826 | &format_count, formats); |
| 827 | pass = (err != VK_SUCCESS); |
| 828 | ASSERT_TRUE(pass); |
| 829 | m_errorMonitor->VerifyFound(); |
| 830 | |
| 831 | // Check surface present modes: |
| 832 | uint32_t present_mode_count = 0; |
| 833 | VkSurfaceFormatKHR *present_modes = NULL; |
| 834 | m_errorMonitor->SetDesiredFailureMsg( |
| 835 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 836 | "extension was not enabled for this"); |
| 837 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 838 | &present_mode_count, present_modes); |
| 839 | pass = (err != VK_SUCCESS); |
| 840 | ASSERT_TRUE(pass); |
| 841 | m_errorMonitor->VerifyFound(); |
| 842 | |
| 843 | |
| 844 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 845 | // that extension: |
| 846 | |
| 847 | // Create a swapchain: |
| 848 | m_errorMonitor->SetDesiredFailureMsg( |
| 849 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 850 | "extension was not enabled for this"); |
| 851 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 852 | swapchain_create_info.pNext = NULL; |
| 853 | #if 0 |
| 854 | swapchain_create_info.flags = 0; |
| 855 | swapchain_create_info.surface = 0; |
| 856 | swapchain_create_info.minImageCount = 0; |
| 857 | swapchain_create_info.imageFormat = 0; |
| 858 | swapchain_create_info.imageColorSpace = 0; |
| 859 | swapchain_create_info.imageExtent.width = 0; |
| 860 | swapchain_create_info.imageExtent.height = 0; |
| 861 | swapchain_create_info.imageArrayLayers = 0; |
| 862 | swapchain_create_info.imageUsage = 0; |
| 863 | swapchain_create_info.imageSharingMode = 0; |
| 864 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 865 | swapchain_create_info.preTransform = 0; |
| 866 | swapchain_create_info.compositeAlpha = 0; |
| 867 | swapchain_create_info.presentMode = 0; |
| 868 | swapchain_create_info.clipped = 0; |
| 869 | swapchain_create_info.oldSwapchain = NULL; |
| 870 | #endif |
| 871 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 872 | NULL, &swapchain); |
| 873 | pass = (err != VK_SUCCESS); |
| 874 | ASSERT_TRUE(pass); |
| 875 | m_errorMonitor->VerifyFound(); |
| 876 | |
| 877 | // Get the images from the swapchain: |
| 878 | m_errorMonitor->SetDesiredFailureMsg( |
| 879 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 880 | "extension was not enabled for this"); |
| 881 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 882 | &swapchain_image_count, NULL); |
| 883 | pass = (err != VK_SUCCESS); |
| 884 | ASSERT_TRUE(pass); |
| 885 | m_errorMonitor->VerifyFound(); |
| 886 | |
| 887 | // Try to acquire an image: |
| 888 | m_errorMonitor->SetDesiredFailureMsg( |
| 889 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 890 | "extension was not enabled for this"); |
| 891 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 892 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 893 | pass = (err != VK_SUCCESS); |
| 894 | ASSERT_TRUE(pass); |
| 895 | m_errorMonitor->VerifyFound(); |
| 896 | |
| 897 | // Try to present an image: |
| 898 | #if 0 // NOTE: Currently can't test this because a real swapchain is needed |
| 899 | // (as opposed to the fake one we created) in order for the layer to |
| 900 | // lookup the VkDevice used to enable the extension: |
| 901 | m_errorMonitor->SetDesiredFailureMsg( |
| 902 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 903 | "extension was not enabled for this"); |
| 904 | present_info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; |
| 905 | present_info.pNext = NULL; |
| 906 | #if 0 |
| 907 | #endif |
| 908 | err = vkQueuePresentKHR(m_device->m_queue, &present_info); |
| 909 | pass = (err != VK_SUCCESS); |
| 910 | ASSERT_TRUE(pass); |
| 911 | m_errorMonitor->VerifyFound(); |
| 912 | #endif |
| 913 | |
| 914 | // Destroy the swapchain: |
| 915 | m_errorMonitor->SetDesiredFailureMsg( |
| 916 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 917 | "extension was not enabled for this"); |
| 918 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 919 | m_errorMonitor->VerifyFound(); |
| 920 | } |
| 921 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 922 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 923 | VkResult err; |
| 924 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 925 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 926 | m_errorMonitor->SetDesiredFailureMsg( |
| 927 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 928 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 929 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 930 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 931 | |
| 932 | // 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] | 933 | VkImage image; |
| 934 | VkDeviceMemory mem; |
| 935 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 936 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 937 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 938 | const int32_t tex_width = 32; |
| 939 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 940 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 941 | VkImageCreateInfo image_create_info = {}; |
| 942 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 943 | image_create_info.pNext = NULL; |
| 944 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 945 | image_create_info.format = tex_format; |
| 946 | image_create_info.extent.width = tex_width; |
| 947 | image_create_info.extent.height = tex_height; |
| 948 | image_create_info.extent.depth = 1; |
| 949 | image_create_info.mipLevels = 1; |
| 950 | image_create_info.arrayLayers = 1; |
| 951 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 952 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 953 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 954 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 955 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 956 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 957 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 958 | mem_alloc.pNext = NULL; |
| 959 | mem_alloc.allocationSize = 0; |
| 960 | // Introduce failure, do NOT set memProps to |
| 961 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 962 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 963 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 964 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 965 | ASSERT_VK_SUCCESS(err); |
| 966 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 967 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 968 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 969 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 970 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 971 | pass = |
| 972 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 973 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 974 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 975 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 976 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 977 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 978 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 979 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 980 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 981 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 982 | ASSERT_VK_SUCCESS(err); |
| 983 | |
| 984 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 985 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 986 | ASSERT_VK_SUCCESS(err); |
| 987 | |
| 988 | // Map memory as if to initialize the image |
| 989 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 990 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 991 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 992 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 993 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 994 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 995 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 996 | } |
| 997 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 998 | TEST_F(VkLayerTest, RebindMemory) { |
| 999 | VkResult err; |
| 1000 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1001 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1002 | m_errorMonitor->SetDesiredFailureMsg( |
| 1003 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1004 | "which has already been bound to mem object"); |
| 1005 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1006 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1007 | |
| 1008 | // 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] | 1009 | VkImage image; |
| 1010 | VkDeviceMemory mem1; |
| 1011 | VkDeviceMemory mem2; |
| 1012 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1013 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1014 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1015 | const int32_t tex_width = 32; |
| 1016 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1017 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1018 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1019 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1020 | image_create_info.pNext = NULL; |
| 1021 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1022 | image_create_info.format = tex_format; |
| 1023 | image_create_info.extent.width = tex_width; |
| 1024 | image_create_info.extent.height = tex_height; |
| 1025 | image_create_info.extent.depth = 1; |
| 1026 | image_create_info.mipLevels = 1; |
| 1027 | image_create_info.arrayLayers = 1; |
| 1028 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1029 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1030 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1031 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1032 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1033 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1034 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1035 | mem_alloc.pNext = NULL; |
| 1036 | mem_alloc.allocationSize = 0; |
| 1037 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1038 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1039 | // Introduce failure, do NOT set memProps to |
| 1040 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1041 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1042 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1043 | ASSERT_VK_SUCCESS(err); |
| 1044 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1045 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1046 | |
| 1047 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1048 | pass = |
| 1049 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1050 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1051 | |
| 1052 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1053 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1054 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1055 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1056 | ASSERT_VK_SUCCESS(err); |
| 1057 | |
| 1058 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1059 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1060 | ASSERT_VK_SUCCESS(err); |
| 1061 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1062 | // Introduce validation failure, try to bind a different memory object to |
| 1063 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1064 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1065 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1066 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1067 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1068 | vkDestroyImage(m_device->device(), image, NULL); |
| 1069 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 1070 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1071 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1072 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1073 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1074 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1075 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1076 | m_errorMonitor->SetDesiredFailureMsg( |
| 1077 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 1078 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1079 | |
| 1080 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1081 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1082 | fenceInfo.pNext = NULL; |
| 1083 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1084 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1085 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1086 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1087 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1088 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1089 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1090 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 1091 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1092 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1093 | |
| 1094 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1095 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1096 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1097 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1098 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1099 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1100 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1101 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1102 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1103 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1104 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1105 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1106 | |
| 1107 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1108 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1109 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1110 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1111 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1112 | // This is a positive test. We used to expect error in this case but spec now |
| 1113 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1114 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1115 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1116 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1117 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1118 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1119 | fenceInfo.pNext = NULL; |
| 1120 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1121 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1122 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 1123 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1124 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 1125 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1126 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1127 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1128 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1129 | |
| 1130 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 1131 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1132 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 1133 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1134 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 1135 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1136 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1137 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1138 | |
| 1139 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1140 | VkImageObj image(m_device); |
| 1141 | // Initialize image with USAGE_INPUT_ATTACHMENT |
| 1142 | image.init(128, 128, VK_FORMAT_D32_SFLOAT_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 1143 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 1144 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1145 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1146 | VkImageView dsv; |
| 1147 | VkImageViewCreateInfo dsvci = {}; |
| 1148 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 1149 | dsvci.image = image.handle(); |
| 1150 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 1151 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 1152 | dsvci.subresourceRange.layerCount = 1; |
| 1153 | dsvci.subresourceRange.baseMipLevel = 0; |
| 1154 | dsvci.subresourceRange.levelCount = 1; |
| 1155 | dsvci.subresourceRange.aspectMask = |
| 1156 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1157 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1158 | // Create a view with depth / stencil aspect for image with different usage |
| 1159 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1160 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1161 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1162 | |
| 1163 | // Initialize buffer with TRANSFER_DST usage |
| 1164 | vk_testing::Buffer buffer; |
| 1165 | VkMemoryPropertyFlags reqs = 0; |
| 1166 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 1167 | VkBufferImageCopy region = {}; |
| 1168 | region.bufferRowLength = 128; |
| 1169 | region.bufferImageHeight = 128; |
| 1170 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1171 | region.imageSubresource.layerCount = 1; |
| 1172 | region.imageExtent.height = 16; |
| 1173 | region.imageExtent.width = 16; |
| 1174 | region.imageExtent.depth = 1; |
| 1175 | |
| 1176 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1177 | "Invalid usage flag for buffer "); |
| 1178 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 1179 | // TRANSFER_DST |
| 1180 | BeginCommandBuffer(); |
| 1181 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 1182 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 1183 | 1, ®ion); |
| 1184 | m_errorMonitor->VerifyFound(); |
| 1185 | |
| 1186 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1187 | "Invalid usage flag for image "); |
| 1188 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 1189 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 1190 | 1, ®ion); |
| 1191 | m_errorMonitor->VerifyFound(); |
| 1192 | |
| 1193 | vkDestroyImageView(m_device->device(), dsv, NULL); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1194 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1195 | #endif // MEM_TRACKER_TESTS |
| 1196 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 1197 | #if OBJ_TRACKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1198 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 1199 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1200 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1201 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1202 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1203 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1204 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1205 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1206 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1207 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1208 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1209 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1210 | |
| 1211 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1212 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1213 | ds_pool_ci.pNext = NULL; |
| 1214 | ds_pool_ci.maxSets = 1; |
| 1215 | ds_pool_ci.poolSizeCount = 1; |
| 1216 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1217 | |
| 1218 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1219 | err = |
| 1220 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1221 | ASSERT_VK_SUCCESS(err); |
| 1222 | |
| 1223 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1224 | dsl_binding.binding = 0; |
| 1225 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1226 | dsl_binding.descriptorCount = 1; |
| 1227 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1228 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1229 | |
| 1230 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1231 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1232 | ds_layout_ci.pNext = NULL; |
| 1233 | ds_layout_ci.bindingCount = 1; |
| 1234 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1235 | |
| 1236 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1237 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1238 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1239 | ASSERT_VK_SUCCESS(err); |
| 1240 | |
| 1241 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1242 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1243 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1244 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1245 | alloc_info.descriptorPool = ds_pool; |
| 1246 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1247 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1248 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1249 | ASSERT_VK_SUCCESS(err); |
| 1250 | |
| 1251 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1252 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1253 | pipeline_layout_ci.pNext = NULL; |
| 1254 | pipeline_layout_ci.setLayoutCount = 1; |
| 1255 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1256 | |
| 1257 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1258 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1259 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1260 | ASSERT_VK_SUCCESS(err); |
| 1261 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 1262 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1263 | |
| 1264 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1265 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1266 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1267 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1268 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1269 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1270 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1271 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1272 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1273 | } |
| 1274 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1275 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 1276 | VkResult err; |
| 1277 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1278 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1279 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1280 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1281 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1282 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1283 | |
| 1284 | // 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] | 1285 | VkImage image; |
| 1286 | VkDeviceMemory mem; |
| 1287 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1288 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1289 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1290 | const int32_t tex_width = 32; |
| 1291 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1292 | |
| 1293 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1294 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1295 | image_create_info.pNext = NULL; |
| 1296 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1297 | image_create_info.format = tex_format; |
| 1298 | image_create_info.extent.width = tex_width; |
| 1299 | image_create_info.extent.height = tex_height; |
| 1300 | image_create_info.extent.depth = 1; |
| 1301 | image_create_info.mipLevels = 1; |
| 1302 | image_create_info.arrayLayers = 1; |
| 1303 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1304 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1305 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1306 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1307 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1308 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1309 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1310 | mem_alloc.pNext = NULL; |
| 1311 | mem_alloc.allocationSize = 0; |
| 1312 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1313 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1314 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1315 | ASSERT_VK_SUCCESS(err); |
| 1316 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1317 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1318 | |
| 1319 | mem_alloc.allocationSize = mem_reqs.size; |
| 1320 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1321 | pass = |
| 1322 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1323 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1324 | |
| 1325 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1326 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1327 | ASSERT_VK_SUCCESS(err); |
| 1328 | |
| 1329 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1330 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1331 | |
| 1332 | // Try to bind free memory that has been freed |
| 1333 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1334 | // This may very well return an error. |
| 1335 | (void)err; |
| 1336 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1337 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1338 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1339 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1340 | } |
| 1341 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1342 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1343 | VkResult err; |
| 1344 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1345 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1346 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1347 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1348 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1349 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1350 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1351 | // Create an image object, allocate memory, destroy the object and then try |
| 1352 | // to bind it |
| 1353 | VkImage image; |
| 1354 | VkDeviceMemory mem; |
| 1355 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1356 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1357 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1358 | const int32_t tex_width = 32; |
| 1359 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1360 | |
| 1361 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1362 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1363 | image_create_info.pNext = NULL; |
| 1364 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1365 | image_create_info.format = tex_format; |
| 1366 | image_create_info.extent.width = tex_width; |
| 1367 | image_create_info.extent.height = tex_height; |
| 1368 | image_create_info.extent.depth = 1; |
| 1369 | image_create_info.mipLevels = 1; |
| 1370 | image_create_info.arrayLayers = 1; |
| 1371 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1372 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1373 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1374 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1375 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1376 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1377 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1378 | mem_alloc.pNext = NULL; |
| 1379 | mem_alloc.allocationSize = 0; |
| 1380 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1381 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1382 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1383 | ASSERT_VK_SUCCESS(err); |
| 1384 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1385 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1386 | |
| 1387 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1388 | pass = |
| 1389 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1390 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1391 | |
| 1392 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1393 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1394 | ASSERT_VK_SUCCESS(err); |
| 1395 | |
| 1396 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1397 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1398 | ASSERT_VK_SUCCESS(err); |
| 1399 | |
| 1400 | // Now Try to bind memory to this destroyed object |
| 1401 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1402 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1403 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1404 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1405 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1406 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1407 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1408 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1409 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1410 | #endif // OBJ_TRACKER_TESTS |
| 1411 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1412 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1413 | |
| 1414 | // This is a positive test. No errors should be generated. |
| 1415 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 1416 | |
| 1417 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1418 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 1419 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1420 | if ((m_device->queue_props.empty()) || |
| 1421 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1422 | return; |
| 1423 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1424 | m_errorMonitor->ExpectSuccess(); |
| 1425 | |
| 1426 | VkSemaphore semaphore; |
| 1427 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1428 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1429 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1430 | &semaphore); |
| 1431 | |
| 1432 | VkCommandPool command_pool; |
| 1433 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1434 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1435 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1436 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1437 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1438 | &command_pool); |
| 1439 | |
| 1440 | VkCommandBuffer command_buffer[2]; |
| 1441 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1442 | command_buffer_allocate_info.sType = |
| 1443 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1444 | command_buffer_allocate_info.commandPool = command_pool; |
| 1445 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1446 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1447 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1448 | command_buffer); |
| 1449 | |
| 1450 | VkQueue queue = VK_NULL_HANDLE; |
| 1451 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1452 | 1, &queue); |
| 1453 | |
| 1454 | { |
| 1455 | VkCommandBufferBeginInfo begin_info{}; |
| 1456 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1457 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1458 | |
| 1459 | vkCmdPipelineBarrier(command_buffer[0], |
| 1460 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1461 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1462 | 0, nullptr, 0, nullptr); |
| 1463 | |
| 1464 | VkViewport viewport{}; |
| 1465 | viewport.maxDepth = 1.0f; |
| 1466 | viewport.minDepth = 0.0f; |
| 1467 | viewport.width = 512; |
| 1468 | viewport.height = 512; |
| 1469 | viewport.x = 0; |
| 1470 | viewport.y = 0; |
| 1471 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1472 | vkEndCommandBuffer(command_buffer[0]); |
| 1473 | } |
| 1474 | { |
| 1475 | VkCommandBufferBeginInfo begin_info{}; |
| 1476 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1477 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1478 | |
| 1479 | VkViewport viewport{}; |
| 1480 | viewport.maxDepth = 1.0f; |
| 1481 | viewport.minDepth = 0.0f; |
| 1482 | viewport.width = 512; |
| 1483 | viewport.height = 512; |
| 1484 | viewport.x = 0; |
| 1485 | viewport.y = 0; |
| 1486 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1487 | vkEndCommandBuffer(command_buffer[1]); |
| 1488 | } |
| 1489 | { |
| 1490 | VkSubmitInfo submit_info{}; |
| 1491 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1492 | submit_info.commandBufferCount = 1; |
| 1493 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1494 | submit_info.signalSemaphoreCount = 1; |
| 1495 | submit_info.pSignalSemaphores = &semaphore; |
| 1496 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1497 | } |
| 1498 | { |
| 1499 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1500 | VkSubmitInfo submit_info{}; |
| 1501 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1502 | submit_info.commandBufferCount = 1; |
| 1503 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1504 | submit_info.waitSemaphoreCount = 1; |
| 1505 | submit_info.pWaitSemaphores = &semaphore; |
| 1506 | submit_info.pWaitDstStageMask = flags; |
| 1507 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1508 | } |
| 1509 | |
| 1510 | vkQueueWaitIdle(m_device->m_queue); |
| 1511 | |
| 1512 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1513 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1514 | &command_buffer[0]); |
| 1515 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1516 | |
| 1517 | m_errorMonitor->VerifyNotFound(); |
| 1518 | } |
| 1519 | |
| 1520 | // This is a positive test. No errors should be generated. |
| 1521 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 1522 | |
| 1523 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1524 | "submitted on separate queues, the second having a fence" |
| 1525 | "followed by a QueueWaitIdle."); |
| 1526 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1527 | if ((m_device->queue_props.empty()) || |
| 1528 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1529 | return; |
| 1530 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1531 | m_errorMonitor->ExpectSuccess(); |
| 1532 | |
| 1533 | VkFence fence; |
| 1534 | VkFenceCreateInfo fence_create_info{}; |
| 1535 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1536 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1537 | |
| 1538 | VkSemaphore semaphore; |
| 1539 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1540 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1541 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1542 | &semaphore); |
| 1543 | |
| 1544 | VkCommandPool command_pool; |
| 1545 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1546 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1547 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1548 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1549 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1550 | &command_pool); |
| 1551 | |
| 1552 | VkCommandBuffer command_buffer[2]; |
| 1553 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1554 | command_buffer_allocate_info.sType = |
| 1555 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1556 | command_buffer_allocate_info.commandPool = command_pool; |
| 1557 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1558 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1559 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1560 | command_buffer); |
| 1561 | |
| 1562 | VkQueue queue = VK_NULL_HANDLE; |
| 1563 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1564 | 1, &queue); |
| 1565 | |
| 1566 | { |
| 1567 | VkCommandBufferBeginInfo begin_info{}; |
| 1568 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1569 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1570 | |
| 1571 | vkCmdPipelineBarrier(command_buffer[0], |
| 1572 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1573 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1574 | 0, nullptr, 0, nullptr); |
| 1575 | |
| 1576 | VkViewport viewport{}; |
| 1577 | viewport.maxDepth = 1.0f; |
| 1578 | viewport.minDepth = 0.0f; |
| 1579 | viewport.width = 512; |
| 1580 | viewport.height = 512; |
| 1581 | viewport.x = 0; |
| 1582 | viewport.y = 0; |
| 1583 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1584 | vkEndCommandBuffer(command_buffer[0]); |
| 1585 | } |
| 1586 | { |
| 1587 | VkCommandBufferBeginInfo begin_info{}; |
| 1588 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1589 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1590 | |
| 1591 | VkViewport viewport{}; |
| 1592 | viewport.maxDepth = 1.0f; |
| 1593 | viewport.minDepth = 0.0f; |
| 1594 | viewport.width = 512; |
| 1595 | viewport.height = 512; |
| 1596 | viewport.x = 0; |
| 1597 | viewport.y = 0; |
| 1598 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1599 | vkEndCommandBuffer(command_buffer[1]); |
| 1600 | } |
| 1601 | { |
| 1602 | VkSubmitInfo submit_info{}; |
| 1603 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1604 | submit_info.commandBufferCount = 1; |
| 1605 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1606 | submit_info.signalSemaphoreCount = 1; |
| 1607 | submit_info.pSignalSemaphores = &semaphore; |
| 1608 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1609 | } |
| 1610 | { |
| 1611 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1612 | VkSubmitInfo submit_info{}; |
| 1613 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1614 | submit_info.commandBufferCount = 1; |
| 1615 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1616 | submit_info.waitSemaphoreCount = 1; |
| 1617 | submit_info.pWaitSemaphores = &semaphore; |
| 1618 | submit_info.pWaitDstStageMask = flags; |
| 1619 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 1620 | } |
| 1621 | |
| 1622 | vkQueueWaitIdle(m_device->m_queue); |
| 1623 | |
| 1624 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 1625 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1626 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1627 | &command_buffer[0]); |
| 1628 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1629 | |
| 1630 | m_errorMonitor->VerifyNotFound(); |
| 1631 | } |
| 1632 | |
| 1633 | // This is a positive test. No errors should be generated. |
| 1634 | TEST_F(VkLayerTest, |
| 1635 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 1636 | |
| 1637 | TEST_DESCRIPTION( |
| 1638 | "Two command buffers, each in a separate QueueSubmit call " |
| 1639 | "submitted on separate queues, the second having a fence" |
| 1640 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 1641 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1642 | if ((m_device->queue_props.empty()) || |
| 1643 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1644 | return; |
| 1645 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1646 | m_errorMonitor->ExpectSuccess(); |
| 1647 | |
| 1648 | VkFence fence; |
| 1649 | VkFenceCreateInfo fence_create_info{}; |
| 1650 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1651 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1652 | |
| 1653 | VkSemaphore semaphore; |
| 1654 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1655 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1656 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1657 | &semaphore); |
| 1658 | |
| 1659 | VkCommandPool command_pool; |
| 1660 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1661 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1662 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1663 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1664 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1665 | &command_pool); |
| 1666 | |
| 1667 | VkCommandBuffer command_buffer[2]; |
| 1668 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1669 | command_buffer_allocate_info.sType = |
| 1670 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1671 | command_buffer_allocate_info.commandPool = command_pool; |
| 1672 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1673 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1674 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1675 | command_buffer); |
| 1676 | |
| 1677 | VkQueue queue = VK_NULL_HANDLE; |
| 1678 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1679 | 1, &queue); |
| 1680 | |
| 1681 | { |
| 1682 | VkCommandBufferBeginInfo begin_info{}; |
| 1683 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1684 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1685 | |
| 1686 | vkCmdPipelineBarrier(command_buffer[0], |
| 1687 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1688 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1689 | 0, nullptr, 0, nullptr); |
| 1690 | |
| 1691 | VkViewport viewport{}; |
| 1692 | viewport.maxDepth = 1.0f; |
| 1693 | viewport.minDepth = 0.0f; |
| 1694 | viewport.width = 512; |
| 1695 | viewport.height = 512; |
| 1696 | viewport.x = 0; |
| 1697 | viewport.y = 0; |
| 1698 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1699 | vkEndCommandBuffer(command_buffer[0]); |
| 1700 | } |
| 1701 | { |
| 1702 | VkCommandBufferBeginInfo begin_info{}; |
| 1703 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1704 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1705 | |
| 1706 | VkViewport viewport{}; |
| 1707 | viewport.maxDepth = 1.0f; |
| 1708 | viewport.minDepth = 0.0f; |
| 1709 | viewport.width = 512; |
| 1710 | viewport.height = 512; |
| 1711 | viewport.x = 0; |
| 1712 | viewport.y = 0; |
| 1713 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1714 | vkEndCommandBuffer(command_buffer[1]); |
| 1715 | } |
| 1716 | { |
| 1717 | VkSubmitInfo submit_info{}; |
| 1718 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1719 | submit_info.commandBufferCount = 1; |
| 1720 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1721 | submit_info.signalSemaphoreCount = 1; |
| 1722 | submit_info.pSignalSemaphores = &semaphore; |
| 1723 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1724 | } |
| 1725 | { |
| 1726 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1727 | VkSubmitInfo submit_info{}; |
| 1728 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1729 | submit_info.commandBufferCount = 1; |
| 1730 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1731 | submit_info.waitSemaphoreCount = 1; |
| 1732 | submit_info.pWaitSemaphores = &semaphore; |
| 1733 | submit_info.pWaitDstStageMask = flags; |
| 1734 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 1735 | } |
| 1736 | |
| 1737 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 1738 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 1739 | |
| 1740 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 1741 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1742 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1743 | &command_buffer[0]); |
| 1744 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1745 | |
| 1746 | m_errorMonitor->VerifyNotFound(); |
| 1747 | } |
| 1748 | |
| 1749 | // This is a positive test. No errors should be generated. |
| 1750 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 1751 | |
| 1752 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1753 | "submitted on separate queues, the second having a fence, " |
| 1754 | "followed by a WaitForFences call."); |
| 1755 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1756 | if ((m_device->queue_props.empty()) || |
| 1757 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1758 | return; |
| 1759 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1760 | m_errorMonitor->ExpectSuccess(); |
| 1761 | |
| 1762 | VkFence fence; |
| 1763 | VkFenceCreateInfo fence_create_info{}; |
| 1764 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1765 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1766 | |
| 1767 | VkSemaphore semaphore; |
| 1768 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1769 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1770 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1771 | &semaphore); |
| 1772 | |
| 1773 | VkCommandPool command_pool; |
| 1774 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1775 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1776 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1777 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1778 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1779 | &command_pool); |
| 1780 | |
| 1781 | VkCommandBuffer command_buffer[2]; |
| 1782 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1783 | command_buffer_allocate_info.sType = |
| 1784 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1785 | command_buffer_allocate_info.commandPool = command_pool; |
| 1786 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1787 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1788 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1789 | command_buffer); |
| 1790 | |
| 1791 | VkQueue queue = VK_NULL_HANDLE; |
| 1792 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1793 | 1, &queue); |
| 1794 | |
| 1795 | |
| 1796 | { |
| 1797 | VkCommandBufferBeginInfo begin_info{}; |
| 1798 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1799 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1800 | |
| 1801 | vkCmdPipelineBarrier(command_buffer[0], |
| 1802 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1803 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1804 | 0, nullptr, 0, nullptr); |
| 1805 | |
| 1806 | VkViewport viewport{}; |
| 1807 | viewport.maxDepth = 1.0f; |
| 1808 | viewport.minDepth = 0.0f; |
| 1809 | viewport.width = 512; |
| 1810 | viewport.height = 512; |
| 1811 | viewport.x = 0; |
| 1812 | viewport.y = 0; |
| 1813 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1814 | vkEndCommandBuffer(command_buffer[0]); |
| 1815 | } |
| 1816 | { |
| 1817 | VkCommandBufferBeginInfo begin_info{}; |
| 1818 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1819 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1820 | |
| 1821 | VkViewport viewport{}; |
| 1822 | viewport.maxDepth = 1.0f; |
| 1823 | viewport.minDepth = 0.0f; |
| 1824 | viewport.width = 512; |
| 1825 | viewport.height = 512; |
| 1826 | viewport.x = 0; |
| 1827 | viewport.y = 0; |
| 1828 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1829 | vkEndCommandBuffer(command_buffer[1]); |
| 1830 | } |
| 1831 | { |
| 1832 | VkSubmitInfo submit_info{}; |
| 1833 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1834 | submit_info.commandBufferCount = 1; |
| 1835 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1836 | submit_info.signalSemaphoreCount = 1; |
| 1837 | submit_info.pSignalSemaphores = &semaphore; |
| 1838 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1839 | } |
| 1840 | { |
| 1841 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1842 | VkSubmitInfo submit_info{}; |
| 1843 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1844 | submit_info.commandBufferCount = 1; |
| 1845 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1846 | submit_info.waitSemaphoreCount = 1; |
| 1847 | submit_info.pWaitSemaphores = &semaphore; |
| 1848 | submit_info.pWaitDstStageMask = flags; |
| 1849 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 1850 | } |
| 1851 | |
| 1852 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 1853 | |
| 1854 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 1855 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1856 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1857 | &command_buffer[0]); |
| 1858 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1859 | |
| 1860 | m_errorMonitor->VerifyNotFound(); |
| 1861 | } |
| 1862 | |
| 1863 | // This is a positive test. No errors should be generated. |
| 1864 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 1865 | |
| 1866 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1867 | "on the same queue, sharing a signal/wait semaphore, the " |
| 1868 | "second having a fence, " |
| 1869 | "followed by a WaitForFences call."); |
| 1870 | |
| 1871 | m_errorMonitor->ExpectSuccess(); |
| 1872 | |
| 1873 | VkFence fence; |
| 1874 | VkFenceCreateInfo fence_create_info{}; |
| 1875 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1876 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1877 | |
| 1878 | VkSemaphore semaphore; |
| 1879 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1880 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1881 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1882 | &semaphore); |
| 1883 | |
| 1884 | VkCommandPool command_pool; |
| 1885 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1886 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1887 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1888 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1889 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1890 | &command_pool); |
| 1891 | |
| 1892 | VkCommandBuffer command_buffer[2]; |
| 1893 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1894 | command_buffer_allocate_info.sType = |
| 1895 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1896 | command_buffer_allocate_info.commandPool = command_pool; |
| 1897 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1898 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1899 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1900 | command_buffer); |
| 1901 | |
| 1902 | { |
| 1903 | VkCommandBufferBeginInfo begin_info{}; |
| 1904 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1905 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1906 | |
| 1907 | vkCmdPipelineBarrier(command_buffer[0], |
| 1908 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1909 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1910 | 0, nullptr, 0, nullptr); |
| 1911 | |
| 1912 | VkViewport viewport{}; |
| 1913 | viewport.maxDepth = 1.0f; |
| 1914 | viewport.minDepth = 0.0f; |
| 1915 | viewport.width = 512; |
| 1916 | viewport.height = 512; |
| 1917 | viewport.x = 0; |
| 1918 | viewport.y = 0; |
| 1919 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1920 | vkEndCommandBuffer(command_buffer[0]); |
| 1921 | } |
| 1922 | { |
| 1923 | VkCommandBufferBeginInfo begin_info{}; |
| 1924 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1925 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1926 | |
| 1927 | VkViewport viewport{}; |
| 1928 | viewport.maxDepth = 1.0f; |
| 1929 | viewport.minDepth = 0.0f; |
| 1930 | viewport.width = 512; |
| 1931 | viewport.height = 512; |
| 1932 | viewport.x = 0; |
| 1933 | viewport.y = 0; |
| 1934 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1935 | vkEndCommandBuffer(command_buffer[1]); |
| 1936 | } |
| 1937 | { |
| 1938 | VkSubmitInfo submit_info{}; |
| 1939 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1940 | submit_info.commandBufferCount = 1; |
| 1941 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1942 | submit_info.signalSemaphoreCount = 1; |
| 1943 | submit_info.pSignalSemaphores = &semaphore; |
| 1944 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1945 | } |
| 1946 | { |
| 1947 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1948 | VkSubmitInfo submit_info{}; |
| 1949 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1950 | submit_info.commandBufferCount = 1; |
| 1951 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1952 | submit_info.waitSemaphoreCount = 1; |
| 1953 | submit_info.pWaitSemaphores = &semaphore; |
| 1954 | submit_info.pWaitDstStageMask = flags; |
| 1955 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 1956 | } |
| 1957 | |
| 1958 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 1959 | |
| 1960 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 1961 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1962 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1963 | &command_buffer[0]); |
| 1964 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1965 | |
| 1966 | m_errorMonitor->VerifyNotFound(); |
| 1967 | } |
| 1968 | |
| 1969 | // This is a positive test. No errors should be generated. |
| 1970 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 1971 | |
| 1972 | TEST_DESCRIPTION( |
| 1973 | "Two command buffers, each in a separate QueueSubmit call " |
| 1974 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 1975 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 1976 | |
| 1977 | m_errorMonitor->ExpectSuccess(); |
| 1978 | |
| 1979 | VkFence fence; |
| 1980 | VkFenceCreateInfo fence_create_info{}; |
| 1981 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1982 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1983 | |
| 1984 | VkCommandPool command_pool; |
| 1985 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1986 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1987 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1988 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1989 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1990 | &command_pool); |
| 1991 | |
| 1992 | VkCommandBuffer command_buffer[2]; |
| 1993 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1994 | command_buffer_allocate_info.sType = |
| 1995 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1996 | command_buffer_allocate_info.commandPool = command_pool; |
| 1997 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1998 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1999 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2000 | command_buffer); |
| 2001 | |
| 2002 | { |
| 2003 | VkCommandBufferBeginInfo begin_info{}; |
| 2004 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2005 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2006 | |
| 2007 | vkCmdPipelineBarrier(command_buffer[0], |
| 2008 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2009 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2010 | 0, nullptr, 0, nullptr); |
| 2011 | |
| 2012 | VkViewport viewport{}; |
| 2013 | viewport.maxDepth = 1.0f; |
| 2014 | viewport.minDepth = 0.0f; |
| 2015 | viewport.width = 512; |
| 2016 | viewport.height = 512; |
| 2017 | viewport.x = 0; |
| 2018 | viewport.y = 0; |
| 2019 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2020 | vkEndCommandBuffer(command_buffer[0]); |
| 2021 | } |
| 2022 | { |
| 2023 | VkCommandBufferBeginInfo begin_info{}; |
| 2024 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2025 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2026 | |
| 2027 | VkViewport viewport{}; |
| 2028 | viewport.maxDepth = 1.0f; |
| 2029 | viewport.minDepth = 0.0f; |
| 2030 | viewport.width = 512; |
| 2031 | viewport.height = 512; |
| 2032 | viewport.x = 0; |
| 2033 | viewport.y = 0; |
| 2034 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2035 | vkEndCommandBuffer(command_buffer[1]); |
| 2036 | } |
| 2037 | { |
| 2038 | VkSubmitInfo submit_info{}; |
| 2039 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2040 | submit_info.commandBufferCount = 1; |
| 2041 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2042 | submit_info.signalSemaphoreCount = 0; |
| 2043 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2044 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2045 | } |
| 2046 | { |
| 2047 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2048 | VkSubmitInfo submit_info{}; |
| 2049 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2050 | submit_info.commandBufferCount = 1; |
| 2051 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2052 | submit_info.waitSemaphoreCount = 0; |
| 2053 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2054 | submit_info.pWaitDstStageMask = flags; |
| 2055 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2056 | } |
| 2057 | |
| 2058 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 2059 | |
| 2060 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2061 | |
| 2062 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2063 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2064 | &command_buffer[0]); |
| 2065 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2066 | |
| 2067 | m_errorMonitor->VerifyNotFound(); |
| 2068 | } |
| 2069 | |
| 2070 | // This is a positive test. No errors should be generated. |
| 2071 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 2072 | |
| 2073 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2074 | "on the same queue, the second having a fence, followed " |
| 2075 | "by a WaitForFences call."); |
| 2076 | |
| 2077 | m_errorMonitor->ExpectSuccess(); |
| 2078 | |
| 2079 | VkFence fence; |
| 2080 | VkFenceCreateInfo fence_create_info{}; |
| 2081 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2082 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2083 | |
| 2084 | VkCommandPool command_pool; |
| 2085 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2086 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2087 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2088 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2089 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2090 | &command_pool); |
| 2091 | |
| 2092 | VkCommandBuffer command_buffer[2]; |
| 2093 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2094 | command_buffer_allocate_info.sType = |
| 2095 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2096 | command_buffer_allocate_info.commandPool = command_pool; |
| 2097 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2098 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2099 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2100 | command_buffer); |
| 2101 | |
| 2102 | { |
| 2103 | VkCommandBufferBeginInfo begin_info{}; |
| 2104 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2105 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2106 | |
| 2107 | vkCmdPipelineBarrier(command_buffer[0], |
| 2108 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2109 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2110 | 0, nullptr, 0, nullptr); |
| 2111 | |
| 2112 | VkViewport viewport{}; |
| 2113 | viewport.maxDepth = 1.0f; |
| 2114 | viewport.minDepth = 0.0f; |
| 2115 | viewport.width = 512; |
| 2116 | viewport.height = 512; |
| 2117 | viewport.x = 0; |
| 2118 | viewport.y = 0; |
| 2119 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2120 | vkEndCommandBuffer(command_buffer[0]); |
| 2121 | } |
| 2122 | { |
| 2123 | VkCommandBufferBeginInfo begin_info{}; |
| 2124 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2125 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2126 | |
| 2127 | VkViewport viewport{}; |
| 2128 | viewport.maxDepth = 1.0f; |
| 2129 | viewport.minDepth = 0.0f; |
| 2130 | viewport.width = 512; |
| 2131 | viewport.height = 512; |
| 2132 | viewport.x = 0; |
| 2133 | viewport.y = 0; |
| 2134 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2135 | vkEndCommandBuffer(command_buffer[1]); |
| 2136 | } |
| 2137 | { |
| 2138 | VkSubmitInfo submit_info{}; |
| 2139 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2140 | submit_info.commandBufferCount = 1; |
| 2141 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2142 | submit_info.signalSemaphoreCount = 0; |
| 2143 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2144 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2145 | } |
| 2146 | { |
| 2147 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2148 | VkSubmitInfo submit_info{}; |
| 2149 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2150 | submit_info.commandBufferCount = 1; |
| 2151 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2152 | submit_info.waitSemaphoreCount = 0; |
| 2153 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2154 | submit_info.pWaitDstStageMask = flags; |
| 2155 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2156 | } |
| 2157 | |
| 2158 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2159 | |
| 2160 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2161 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2162 | &command_buffer[0]); |
| 2163 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2164 | |
| 2165 | m_errorMonitor->VerifyNotFound(); |
| 2166 | } |
| 2167 | |
| 2168 | // This is a positive test. No errors should be generated. |
| 2169 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 2170 | |
| 2171 | TEST_DESCRIPTION( |
| 2172 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 2173 | "QueueSubmit call followed by a WaitForFences call."); |
| 2174 | |
| 2175 | m_errorMonitor->ExpectSuccess(); |
| 2176 | |
| 2177 | VkFence fence; |
| 2178 | VkFenceCreateInfo fence_create_info{}; |
| 2179 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2180 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2181 | |
| 2182 | VkSemaphore semaphore; |
| 2183 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2184 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2185 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2186 | &semaphore); |
| 2187 | |
| 2188 | VkCommandPool command_pool; |
| 2189 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2190 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2191 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2192 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2193 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2194 | &command_pool); |
| 2195 | |
| 2196 | VkCommandBuffer command_buffer[2]; |
| 2197 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2198 | command_buffer_allocate_info.sType = |
| 2199 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2200 | command_buffer_allocate_info.commandPool = command_pool; |
| 2201 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2202 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2203 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2204 | command_buffer); |
| 2205 | |
| 2206 | { |
| 2207 | VkCommandBufferBeginInfo begin_info{}; |
| 2208 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2209 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2210 | |
| 2211 | vkCmdPipelineBarrier(command_buffer[0], |
| 2212 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2213 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2214 | 0, nullptr, 0, nullptr); |
| 2215 | |
| 2216 | VkViewport viewport{}; |
| 2217 | viewport.maxDepth = 1.0f; |
| 2218 | viewport.minDepth = 0.0f; |
| 2219 | viewport.width = 512; |
| 2220 | viewport.height = 512; |
| 2221 | viewport.x = 0; |
| 2222 | viewport.y = 0; |
| 2223 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2224 | vkEndCommandBuffer(command_buffer[0]); |
| 2225 | } |
| 2226 | { |
| 2227 | VkCommandBufferBeginInfo begin_info{}; |
| 2228 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2229 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2230 | |
| 2231 | VkViewport viewport{}; |
| 2232 | viewport.maxDepth = 1.0f; |
| 2233 | viewport.minDepth = 0.0f; |
| 2234 | viewport.width = 512; |
| 2235 | viewport.height = 512; |
| 2236 | viewport.x = 0; |
| 2237 | viewport.y = 0; |
| 2238 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2239 | vkEndCommandBuffer(command_buffer[1]); |
| 2240 | } |
| 2241 | { |
| 2242 | VkSubmitInfo submit_info[2]; |
| 2243 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2244 | |
| 2245 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2246 | submit_info[0].pNext = NULL; |
| 2247 | submit_info[0].commandBufferCount = 1; |
| 2248 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 2249 | submit_info[0].signalSemaphoreCount = 1; |
| 2250 | submit_info[0].pSignalSemaphores = &semaphore; |
| 2251 | submit_info[0].waitSemaphoreCount = 0; |
| 2252 | submit_info[0].pWaitSemaphores = NULL; |
| 2253 | submit_info[0].pWaitDstStageMask = 0; |
| 2254 | |
| 2255 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2256 | submit_info[1].pNext = NULL; |
| 2257 | submit_info[1].commandBufferCount = 1; |
| 2258 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 2259 | submit_info[1].waitSemaphoreCount = 1; |
| 2260 | submit_info[1].pWaitSemaphores = &semaphore; |
| 2261 | submit_info[1].pWaitDstStageMask = flags; |
| 2262 | submit_info[1].signalSemaphoreCount = 0; |
| 2263 | submit_info[1].pSignalSemaphores = NULL; |
| 2264 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 2265 | } |
| 2266 | |
| 2267 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2268 | |
| 2269 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2270 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2271 | &command_buffer[0]); |
| 2272 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2273 | |
| 2274 | m_errorMonitor->VerifyNotFound(); |
| 2275 | } |
| 2276 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2277 | TEST_F(VkLayerTest, DynamicStatesNotBound) { |
| 2278 | TEST_DESCRIPTION( |
| 2279 | "Run a series of simple draw calls to validate all the different " |
| 2280 | "failure cases that can occur when dynamic state is required but not " |
| 2281 | "correctly bound." |
| 2282 | "Here are the different dynamic state cases verified by this test:\n" |
| 2283 | "-Line Width\n-Depth Bias\n-Viewport State\n-Scissor State\n-Blend " |
| 2284 | "State\n-Depth Bounds\n-Stencil Read Mask\n-Stencil Write " |
| 2285 | "Mask\n-Stencil Reference"); |
| 2286 | |
| 2287 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2288 | m_errorMonitor->SetDesiredFailureMsg( |
| 2289 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2290 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2291 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2292 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2293 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2294 | // Dynamic depth bias |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2295 | m_errorMonitor->SetDesiredFailureMsg( |
| 2296 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2297 | "Dynamic depth bias state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2298 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2299 | BsoFailDepthBias); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2300 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2301 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2302 | m_errorMonitor->SetDesiredFailureMsg( |
| 2303 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2304 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2305 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2306 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2307 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2308 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2309 | m_errorMonitor->SetDesiredFailureMsg( |
| 2310 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2311 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2312 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2313 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2314 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2315 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2316 | m_errorMonitor->SetDesiredFailureMsg( |
| 2317 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2318 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2319 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2320 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2321 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2322 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2323 | m_errorMonitor->SetDesiredFailureMsg( |
| 2324 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2325 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2326 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2327 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2328 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2329 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2330 | m_errorMonitor->SetDesiredFailureMsg( |
| 2331 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2332 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2333 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2334 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2335 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2336 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2337 | m_errorMonitor->SetDesiredFailureMsg( |
| 2338 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2339 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2340 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2341 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2342 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 2343 | } |
| 2344 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2345 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2346 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2347 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2348 | m_errorMonitor->SetDesiredFailureMsg( |
| 2349 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2350 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 2351 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2352 | |
| 2353 | VkFenceCreateInfo fenceInfo = {}; |
| 2354 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2355 | fenceInfo.pNext = NULL; |
| 2356 | fenceInfo.flags = 0; |
| 2357 | |
| 2358 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2359 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2360 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2361 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2362 | // We luck out b/c by default the framework creates CB w/ the |
| 2363 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2364 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2365 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2366 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2367 | EndCommandBuffer(); |
| 2368 | |
| 2369 | testFence.init(*m_device, fenceInfo); |
| 2370 | |
| 2371 | // Bypass framework since it does the waits automatically |
| 2372 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2373 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2374 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2375 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2376 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2377 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2378 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2379 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2380 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2381 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2382 | submit_info.pSignalSemaphores = NULL; |
| 2383 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2384 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 2385 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2386 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2387 | // Cause validation error by re-submitting cmd buffer that should only be |
| 2388 | // submitted once |
| 2389 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2390 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2391 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2392 | } |
| 2393 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2394 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2395 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2396 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2397 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2398 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2399 | "Unable to allocate 1 descriptors of " |
| 2400 | "type " |
| 2401 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2402 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2403 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2404 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2405 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2406 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 2407 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2408 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2409 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2410 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2411 | |
| 2412 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2413 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2414 | ds_pool_ci.pNext = NULL; |
| 2415 | ds_pool_ci.flags = 0; |
| 2416 | ds_pool_ci.maxSets = 1; |
| 2417 | ds_pool_ci.poolSizeCount = 1; |
| 2418 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2419 | |
| 2420 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2421 | err = |
| 2422 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2423 | ASSERT_VK_SUCCESS(err); |
| 2424 | |
| 2425 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2426 | dsl_binding.binding = 0; |
| 2427 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2428 | dsl_binding.descriptorCount = 1; |
| 2429 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2430 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2431 | |
| 2432 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2433 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2434 | ds_layout_ci.pNext = NULL; |
| 2435 | ds_layout_ci.bindingCount = 1; |
| 2436 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2437 | |
| 2438 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2439 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2440 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2441 | ASSERT_VK_SUCCESS(err); |
| 2442 | |
| 2443 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2444 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2445 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2446 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2447 | alloc_info.descriptorPool = ds_pool; |
| 2448 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2449 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2450 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2451 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2452 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2453 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2454 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2455 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2456 | } |
| 2457 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2458 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 2459 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2460 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2461 | m_errorMonitor->SetDesiredFailureMsg( |
| 2462 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2463 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 2464 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2465 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2466 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2467 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2468 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2469 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2470 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2471 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2472 | |
| 2473 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2474 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2475 | ds_pool_ci.pNext = NULL; |
| 2476 | ds_pool_ci.maxSets = 1; |
| 2477 | ds_pool_ci.poolSizeCount = 1; |
| 2478 | ds_pool_ci.flags = 0; |
| 2479 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 2480 | // app can only call vkResetDescriptorPool on this pool.; |
| 2481 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2482 | |
| 2483 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2484 | err = |
| 2485 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2486 | ASSERT_VK_SUCCESS(err); |
| 2487 | |
| 2488 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2489 | dsl_binding.binding = 0; |
| 2490 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2491 | dsl_binding.descriptorCount = 1; |
| 2492 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2493 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2494 | |
| 2495 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2496 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2497 | ds_layout_ci.pNext = NULL; |
| 2498 | ds_layout_ci.bindingCount = 1; |
| 2499 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2500 | |
| 2501 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2502 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2503 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2504 | ASSERT_VK_SUCCESS(err); |
| 2505 | |
| 2506 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2507 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2508 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2509 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2510 | alloc_info.descriptorPool = ds_pool; |
| 2511 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2512 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2513 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2514 | ASSERT_VK_SUCCESS(err); |
| 2515 | |
| 2516 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2517 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2518 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2519 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2520 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2521 | } |
| 2522 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2523 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2524 | // Attempt to clear Descriptor Pool with bad object. |
| 2525 | // ObjectTracker should catch this. |
| 2526 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2527 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
| 2528 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 2529 | vkResetDescriptorPool(device(), badPool, 0); |
| 2530 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2531 | } |
| 2532 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2533 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2534 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 2535 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2536 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2537 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
| 2538 | VkDescriptorSet badSet = (VkDescriptorSet)0xbaad6001; |
| 2539 | VkResult err; |
| 2540 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2541 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 2542 | |
| 2543 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2544 | |
| 2545 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 2546 | layout_bindings[0].binding = 0; |
| 2547 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2548 | layout_bindings[0].descriptorCount = 1; |
| 2549 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 2550 | layout_bindings[0].pImmutableSamplers = NULL; |
| 2551 | |
| 2552 | VkDescriptorSetLayout descriptor_set_layout; |
| 2553 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 2554 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2555 | dslci.pNext = NULL; |
| 2556 | dslci.bindingCount = 1; |
| 2557 | dslci.pBindings = layout_bindings; |
| 2558 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 2559 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2560 | |
| 2561 | VkPipelineLayout pipeline_layout; |
| 2562 | VkPipelineLayoutCreateInfo plci = {}; |
| 2563 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2564 | plci.pNext = NULL; |
| 2565 | plci.setLayoutCount = 1; |
| 2566 | plci.pSetLayouts = &descriptor_set_layout; |
| 2567 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 2568 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2569 | |
| 2570 | BeginCommandBuffer(); |
| 2571 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 2572 | pipeline_layout, 0, 1, &badSet, 0, NULL); |
| 2573 | m_errorMonitor->VerifyFound(); |
| 2574 | EndCommandBuffer(); |
| 2575 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 2576 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2577 | } |
| 2578 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2579 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2580 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 2581 | // ObjectTracker should catch this. |
| 2582 | VkDescriptorSetLayout bad_layout = (VkDescriptorSetLayout)0xbaad6001; |
| 2583 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2584 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 2585 | |
| 2586 | VkPipelineLayout pipeline_layout; |
| 2587 | VkPipelineLayoutCreateInfo plci = {}; |
| 2588 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2589 | plci.pNext = NULL; |
| 2590 | plci.setLayoutCount = 1; |
| 2591 | plci.pSetLayouts = &bad_layout; |
| 2592 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 2593 | |
| 2594 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2595 | } |
| 2596 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2597 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2598 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 2599 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2600 | // Create a valid cmd buffer |
| 2601 | // call vkCmdBindPipeline w/ false Pipeline |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2602 | VkPipeline bad_pipeline = (VkPipeline)0xbaad6001; |
| 2603 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2604 | "Invalid VkPipeline Object 0xbaad6001"); |
| 2605 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2606 | BeginCommandBuffer(); |
| 2607 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2608 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 2609 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 2610 | |
| 2611 | // Now issue a draw call with no pipeline bound |
| 2612 | m_errorMonitor->SetDesiredFailureMsg( |
| 2613 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2614 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 2615 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2616 | BeginCommandBuffer(); |
| 2617 | Draw(1, 0, 0, 0); |
| 2618 | m_errorMonitor->VerifyFound(); |
| 2619 | // Finally same check once more but with Dispatch/Compute |
| 2620 | m_errorMonitor->SetDesiredFailureMsg( |
| 2621 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2622 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 2623 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2624 | BeginCommandBuffer(); |
| 2625 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 2626 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2627 | } |
| 2628 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2629 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 2630 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 2631 | // CommandBuffer |
| 2632 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2633 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 2634 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2635 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2636 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2637 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2638 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2639 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2640 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2641 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2642 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2643 | |
| 2644 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2645 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2646 | ds_pool_ci.pNext = NULL; |
| 2647 | ds_pool_ci.maxSets = 1; |
| 2648 | ds_pool_ci.poolSizeCount = 1; |
| 2649 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2650 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 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 | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2654 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2655 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 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; |
| 2661 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2662 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2663 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2664 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2665 | ds_layout_ci.pNext = NULL; |
| 2666 | ds_layout_ci.bindingCount = 1; |
| 2667 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2668 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2669 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2670 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2671 | ASSERT_VK_SUCCESS(err); |
| 2672 | |
| 2673 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2674 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2675 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2676 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2677 | alloc_info.descriptorPool = ds_pool; |
| 2678 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2679 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2680 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2681 | ASSERT_VK_SUCCESS(err); |
| 2682 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2683 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2684 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2685 | pipeline_layout_ci.pNext = NULL; |
| 2686 | pipeline_layout_ci.setLayoutCount = 1; |
| 2687 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2688 | |
| 2689 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2690 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2691 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2692 | ASSERT_VK_SUCCESS(err); |
| 2693 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2694 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 2695 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2696 | // 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] | 2697 | // on more devices |
| 2698 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 2699 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2700 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 2701 | VkPipelineObj pipe(m_device); |
| 2702 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 2703 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 2704 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 2705 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2706 | |
| 2707 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2708 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2709 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2710 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2711 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2712 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2713 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2714 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2715 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2716 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2717 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2718 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2719 | } |
| 2720 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2721 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2722 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2723 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2724 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2725 | m_errorMonitor->SetDesiredFailureMsg( |
| 2726 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2727 | "Attempt to update descriptor with invalid bufferView "); |
| 2728 | |
| 2729 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2730 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2731 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 2732 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2733 | |
| 2734 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2735 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2736 | ds_pool_ci.pNext = NULL; |
| 2737 | ds_pool_ci.maxSets = 1; |
| 2738 | ds_pool_ci.poolSizeCount = 1; |
| 2739 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2740 | |
| 2741 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2742 | err = |
| 2743 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2744 | ASSERT_VK_SUCCESS(err); |
| 2745 | |
| 2746 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2747 | dsl_binding.binding = 0; |
| 2748 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 2749 | dsl_binding.descriptorCount = 1; |
| 2750 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2751 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2752 | |
| 2753 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2754 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2755 | ds_layout_ci.pNext = NULL; |
| 2756 | ds_layout_ci.bindingCount = 1; |
| 2757 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2758 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2759 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2760 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2761 | ASSERT_VK_SUCCESS(err); |
| 2762 | |
| 2763 | VkDescriptorSet descriptorSet; |
| 2764 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2765 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2766 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2767 | alloc_info.descriptorPool = ds_pool; |
| 2768 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2769 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2770 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2771 | ASSERT_VK_SUCCESS(err); |
| 2772 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2773 | VkBufferView view = |
| 2774 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2775 | VkWriteDescriptorSet descriptor_write; |
| 2776 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2777 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2778 | descriptor_write.dstSet = descriptorSet; |
| 2779 | descriptor_write.dstBinding = 0; |
| 2780 | descriptor_write.descriptorCount = 1; |
| 2781 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 2782 | descriptor_write.pTexelBufferView = &view; |
| 2783 | |
| 2784 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2785 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2786 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 2787 | |
| 2788 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2789 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2790 | } |
| 2791 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2792 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 2793 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 2794 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2795 | // 1. No dynamicOffset supplied |
| 2796 | // 2. Too many dynamicOffsets supplied |
| 2797 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2798 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2799 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2800 | " requires 1 dynamicOffsets, but only " |
| 2801 | "0 dynamicOffsets are left in " |
| 2802 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2803 | |
| 2804 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2805 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2806 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2807 | |
| 2808 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2809 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 2810 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2811 | |
| 2812 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2813 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2814 | ds_pool_ci.pNext = NULL; |
| 2815 | ds_pool_ci.maxSets = 1; |
| 2816 | ds_pool_ci.poolSizeCount = 1; |
| 2817 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2818 | |
| 2819 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2820 | err = |
| 2821 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2822 | ASSERT_VK_SUCCESS(err); |
| 2823 | |
| 2824 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2825 | dsl_binding.binding = 0; |
| 2826 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 2827 | dsl_binding.descriptorCount = 1; |
| 2828 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2829 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2830 | |
| 2831 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2832 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2833 | ds_layout_ci.pNext = NULL; |
| 2834 | ds_layout_ci.bindingCount = 1; |
| 2835 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2836 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2837 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2838 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2839 | ASSERT_VK_SUCCESS(err); |
| 2840 | |
| 2841 | VkDescriptorSet descriptorSet; |
| 2842 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2843 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2844 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2845 | alloc_info.descriptorPool = ds_pool; |
| 2846 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2847 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2848 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2849 | ASSERT_VK_SUCCESS(err); |
| 2850 | |
| 2851 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2852 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2853 | pipeline_layout_ci.pNext = NULL; |
| 2854 | pipeline_layout_ci.setLayoutCount = 1; |
| 2855 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2856 | |
| 2857 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2858 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2859 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2860 | ASSERT_VK_SUCCESS(err); |
| 2861 | |
| 2862 | // Create a buffer to update the descriptor with |
| 2863 | uint32_t qfi = 0; |
| 2864 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2865 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2866 | buffCI.size = 1024; |
| 2867 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 2868 | buffCI.queueFamilyIndexCount = 1; |
| 2869 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2870 | |
| 2871 | VkBuffer dyub; |
| 2872 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 2873 | ASSERT_VK_SUCCESS(err); |
| 2874 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 2875 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2876 | buffInfo.buffer = dyub; |
| 2877 | buffInfo.offset = 0; |
| 2878 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2879 | |
| 2880 | VkWriteDescriptorSet descriptor_write; |
| 2881 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2882 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2883 | descriptor_write.dstSet = descriptorSet; |
| 2884 | descriptor_write.dstBinding = 0; |
| 2885 | descriptor_write.descriptorCount = 1; |
| 2886 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 2887 | descriptor_write.pBufferInfo = &buffInfo; |
| 2888 | |
| 2889 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2890 | |
| 2891 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2892 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2893 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2894 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2895 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2896 | uint32_t pDynOff[2] = {512, 756}; |
| 2897 | // 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] | 2898 | m_errorMonitor->SetDesiredFailureMsg( |
| 2899 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2900 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2901 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2902 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2903 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 2904 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2905 | // Finally cause error due to dynamicOffset being too big |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2906 | m_errorMonitor->SetDesiredFailureMsg( |
| 2907 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2908 | " from its update, this oversteps its buffer ("); |
| 2909 | // Create PSO to be used for draw-time errors below |
| 2910 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 2911 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2912 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 2913 | "out gl_PerVertex { \n" |
| 2914 | " vec4 gl_Position;\n" |
| 2915 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2916 | "void main(){\n" |
| 2917 | " gl_Position = vec4(1);\n" |
| 2918 | "}\n"; |
| 2919 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 2920 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2921 | "\n" |
| 2922 | "layout(location=0) out vec4 x;\n" |
| 2923 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 2924 | "void main(){\n" |
| 2925 | " x = vec4(bar.y);\n" |
| 2926 | "}\n"; |
| 2927 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2928 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 2929 | VkPipelineObj pipe(m_device); |
| 2930 | pipe.AddShader(&vs); |
| 2931 | pipe.AddShader(&fs); |
| 2932 | pipe.AddColorAttachment(); |
| 2933 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 2934 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2935 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2936 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2937 | // This update should succeed, but offset size of 512 will overstep buffer |
| 2938 | // /w range 1024 & size 1024 |
| 2939 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 2940 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 2941 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 2942 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2943 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 2944 | |
| 2945 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2946 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2947 | } |
| 2948 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 2949 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 2950 | // Hit push constant error cases: |
| 2951 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 2952 | // 2. Incorrectly set push constant size to 0 |
| 2953 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 2954 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 2955 | VkResult err; |
| 2956 | m_errorMonitor->SetDesiredFailureMsg( |
| 2957 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2958 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 2959 | |
| 2960 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2961 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2962 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2963 | |
| 2964 | VkPushConstantRange pc_range = {}; |
| 2965 | pc_range.size = 0xFFFFFFFFu; |
| 2966 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 2967 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2968 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2969 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 2970 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 2971 | |
| 2972 | VkPipelineLayout pipeline_layout; |
| 2973 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2974 | &pipeline_layout); |
| 2975 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2976 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 2977 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 2978 | pc_range.size = 0; |
| 2979 | m_errorMonitor->SetDesiredFailureMsg( |
| 2980 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2981 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 2982 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2983 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2984 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 2985 | pc_range.size = 1; |
| 2986 | m_errorMonitor->SetDesiredFailureMsg( |
| 2987 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2988 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 2989 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2990 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2991 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 2992 | // Cause error due to bad size in vkCmdPushConstants() call |
| 2993 | m_errorMonitor->SetDesiredFailureMsg( |
| 2994 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2995 | "vkCmdPushConstants() call has push constants with offset "); |
| 2996 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 2997 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 2998 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2999 | &pipeline_layout); |
| 3000 | ASSERT_VK_SUCCESS(err); |
| 3001 | BeginCommandBuffer(); |
| 3002 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 3003 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3004 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3005 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3006 | } |
| 3007 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3008 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3009 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3010 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3011 | |
| 3012 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3013 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3014 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3015 | |
| 3016 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 3017 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3018 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3019 | ds_type_count[0].descriptorCount = 10; |
| 3020 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3021 | ds_type_count[1].descriptorCount = 2; |
| 3022 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3023 | ds_type_count[2].descriptorCount = 2; |
| 3024 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3025 | ds_type_count[3].descriptorCount = 5; |
| 3026 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 3027 | // type |
| 3028 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 3029 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 3030 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3031 | |
| 3032 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3033 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3034 | ds_pool_ci.pNext = NULL; |
| 3035 | ds_pool_ci.maxSets = 5; |
| 3036 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 3037 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3038 | |
| 3039 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3040 | err = |
| 3041 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3042 | ASSERT_VK_SUCCESS(err); |
| 3043 | |
| 3044 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 3045 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3046 | dsl_binding[0].binding = 0; |
| 3047 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3048 | dsl_binding[0].descriptorCount = 5; |
| 3049 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3050 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3051 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3052 | // Create layout identical to set0 layout but w/ different stageFlags |
| 3053 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3054 | dsl_fs_stage_only.binding = 0; |
| 3055 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3056 | dsl_fs_stage_only.descriptorCount = 5; |
| 3057 | dsl_fs_stage_only.stageFlags = |
| 3058 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 3059 | // bind time |
| 3060 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3061 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3062 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3063 | ds_layout_ci.pNext = NULL; |
| 3064 | ds_layout_ci.bindingCount = 1; |
| 3065 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3066 | static const uint32_t NUM_LAYOUTS = 4; |
| 3067 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3068 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3069 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 3070 | // layout for error case |
| 3071 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3072 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3073 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3074 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3075 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3076 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3077 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3078 | dsl_binding[0].binding = 0; |
| 3079 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3080 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3081 | dsl_binding[1].binding = 1; |
| 3082 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3083 | dsl_binding[1].descriptorCount = 2; |
| 3084 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3085 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3086 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3087 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3088 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3089 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3090 | ASSERT_VK_SUCCESS(err); |
| 3091 | dsl_binding[0].binding = 0; |
| 3092 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3093 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3094 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3095 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3096 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3097 | ASSERT_VK_SUCCESS(err); |
| 3098 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3099 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3100 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3101 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3102 | ASSERT_VK_SUCCESS(err); |
| 3103 | |
| 3104 | static const uint32_t NUM_SETS = 4; |
| 3105 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 3106 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3107 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3108 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3109 | alloc_info.descriptorPool = ds_pool; |
| 3110 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3111 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3112 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3113 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3114 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3115 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3116 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3117 | err = |
| 3118 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3119 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3120 | |
| 3121 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3122 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3123 | pipeline_layout_ci.pNext = NULL; |
| 3124 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 3125 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3126 | |
| 3127 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3128 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3129 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3130 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3131 | // Create pipelineLayout with only one setLayout |
| 3132 | pipeline_layout_ci.setLayoutCount = 1; |
| 3133 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3134 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3135 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3136 | ASSERT_VK_SUCCESS(err); |
| 3137 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 3138 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 3139 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3140 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3141 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3142 | ASSERT_VK_SUCCESS(err); |
| 3143 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 3144 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 3145 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3146 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3147 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3148 | ASSERT_VK_SUCCESS(err); |
| 3149 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 3150 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 3151 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3152 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3153 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3154 | ASSERT_VK_SUCCESS(err); |
| 3155 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 3156 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 3157 | pl_bad_s0[0] = ds_layout_fs_only; |
| 3158 | pl_bad_s0[1] = ds_layout[1]; |
| 3159 | pipeline_layout_ci.setLayoutCount = 2; |
| 3160 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 3161 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3162 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3163 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3164 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3165 | |
| 3166 | // Create a buffer to update the descriptor with |
| 3167 | uint32_t qfi = 0; |
| 3168 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3169 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3170 | buffCI.size = 1024; |
| 3171 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3172 | buffCI.queueFamilyIndexCount = 1; |
| 3173 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3174 | |
| 3175 | VkBuffer dyub; |
| 3176 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3177 | ASSERT_VK_SUCCESS(err); |
| 3178 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3179 | static const uint32_t NUM_BUFFS = 5; |
| 3180 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3181 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3182 | buffInfo[i].buffer = dyub; |
| 3183 | buffInfo[i].offset = 0; |
| 3184 | buffInfo[i].range = 1024; |
| 3185 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3186 | VkImage image; |
| 3187 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3188 | const int32_t tex_width = 32; |
| 3189 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3190 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3191 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3192 | image_create_info.pNext = NULL; |
| 3193 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3194 | image_create_info.format = tex_format; |
| 3195 | image_create_info.extent.width = tex_width; |
| 3196 | image_create_info.extent.height = tex_height; |
| 3197 | image_create_info.extent.depth = 1; |
| 3198 | image_create_info.mipLevels = 1; |
| 3199 | image_create_info.arrayLayers = 1; |
| 3200 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3201 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3202 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3203 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3204 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 3205 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3206 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3207 | VkMemoryRequirements memReqs; |
| 3208 | VkDeviceMemory imageMem; |
| 3209 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3210 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3211 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3212 | memAlloc.pNext = NULL; |
| 3213 | memAlloc.allocationSize = 0; |
| 3214 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3215 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 3216 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3217 | pass = |
| 3218 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3219 | ASSERT_TRUE(pass); |
| 3220 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 3221 | ASSERT_VK_SUCCESS(err); |
| 3222 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 3223 | ASSERT_VK_SUCCESS(err); |
| 3224 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3225 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3226 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3227 | image_view_create_info.image = image; |
| 3228 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3229 | image_view_create_info.format = tex_format; |
| 3230 | image_view_create_info.subresourceRange.layerCount = 1; |
| 3231 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 3232 | image_view_create_info.subresourceRange.levelCount = 1; |
| 3233 | image_view_create_info.subresourceRange.aspectMask = |
| 3234 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3235 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3236 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3237 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 3238 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3239 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3240 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3241 | imageInfo[0].imageView = view; |
| 3242 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3243 | imageInfo[1].imageView = view; |
| 3244 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3245 | imageInfo[2].imageView = view; |
| 3246 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3247 | imageInfo[3].imageView = view; |
| 3248 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3249 | |
| 3250 | static const uint32_t NUM_SET_UPDATES = 3; |
| 3251 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 3252 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3253 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 3254 | descriptor_write[0].dstBinding = 0; |
| 3255 | descriptor_write[0].descriptorCount = 5; |
| 3256 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3257 | descriptor_write[0].pBufferInfo = buffInfo; |
| 3258 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3259 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 3260 | descriptor_write[1].dstBinding = 0; |
| 3261 | descriptor_write[1].descriptorCount = 2; |
| 3262 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3263 | descriptor_write[1].pImageInfo = imageInfo; |
| 3264 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3265 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 3266 | descriptor_write[2].dstBinding = 1; |
| 3267 | descriptor_write[2].descriptorCount = 2; |
| 3268 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3269 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3270 | |
| 3271 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3272 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3273 | // Create PSO to be used for draw-time errors below |
| 3274 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3275 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3276 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3277 | "out gl_PerVertex {\n" |
| 3278 | " vec4 gl_Position;\n" |
| 3279 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3280 | "void main(){\n" |
| 3281 | " gl_Position = vec4(1);\n" |
| 3282 | "}\n"; |
| 3283 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3284 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3285 | "\n" |
| 3286 | "layout(location=0) out vec4 x;\n" |
| 3287 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3288 | "void main(){\n" |
| 3289 | " x = vec4(bar.y);\n" |
| 3290 | "}\n"; |
| 3291 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3292 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3293 | VkPipelineObj pipe(m_device); |
| 3294 | pipe.AddShader(&vs); |
| 3295 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3296 | pipe.AddColorAttachment(); |
| 3297 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3298 | |
| 3299 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3300 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3301 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3302 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3303 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 3304 | // of PSO |
| 3305 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 3306 | // cmd_pipeline.c |
| 3307 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 3308 | // cmd_bind_graphics_pipeline() |
| 3309 | // TODO : Want to cause various binding incompatibility issues here to test |
| 3310 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3311 | // First cause various verify_layout_compatibility() fails |
| 3312 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3313 | // verify_set_layout_compatibility fail cases: |
| 3314 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3315 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3316 | " due to: invalid VkPipelineLayout "); |
| 3317 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3318 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3319 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 3320 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3321 | m_errorMonitor->VerifyFound(); |
| 3322 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3323 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3324 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3325 | " attempting to bind set to index 1"); |
| 3326 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3327 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 3328 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3329 | m_errorMonitor->VerifyFound(); |
| 3330 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3331 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3332 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 3333 | // descriptors |
| 3334 | m_errorMonitor->SetDesiredFailureMsg( |
| 3335 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3336 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3337 | vkCmdBindDescriptorSets( |
| 3338 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3339 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3340 | m_errorMonitor->VerifyFound(); |
| 3341 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3342 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 3343 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3344 | m_errorMonitor->SetDesiredFailureMsg( |
| 3345 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3346 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3347 | vkCmdBindDescriptorSets( |
| 3348 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3349 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3350 | m_errorMonitor->VerifyFound(); |
| 3351 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3352 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 3353 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3354 | m_errorMonitor->SetDesiredFailureMsg( |
| 3355 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3356 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3357 | vkCmdBindDescriptorSets( |
| 3358 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3359 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3360 | m_errorMonitor->VerifyFound(); |
| 3361 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3362 | // Cause INFO messages due to disturbing previously bound Sets |
| 3363 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3364 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3365 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3366 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3367 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3368 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3369 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3370 | " previously bound as set #0 was disturbed "); |
| 3371 | vkCmdBindDescriptorSets( |
| 3372 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3373 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3374 | m_errorMonitor->VerifyFound(); |
| 3375 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3376 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3377 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3378 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3379 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3380 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3381 | " newly bound as set #0 so set #1 and " |
| 3382 | "any subsequent sets were disturbed "); |
| 3383 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3384 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3385 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3386 | m_errorMonitor->VerifyFound(); |
| 3387 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3388 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3389 | // 1. Error due to not binding required set (we actually use same code as |
| 3390 | // above to disturb set0) |
| 3391 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3392 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3393 | 2, &descriptorSet[0], 0, NULL); |
| 3394 | vkCmdBindDescriptorSets( |
| 3395 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3396 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 3397 | m_errorMonitor->SetDesiredFailureMsg( |
| 3398 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3399 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3400 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3401 | m_errorMonitor->VerifyFound(); |
| 3402 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3403 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3404 | // 2. Error due to bound set not being compatible with PSO's |
| 3405 | // VkPipelineLayout (diff stageFlags in this case) |
| 3406 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3407 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3408 | 2, &descriptorSet[0], 0, NULL); |
| 3409 | m_errorMonitor->SetDesiredFailureMsg( |
| 3410 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3411 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3412 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3413 | m_errorMonitor->VerifyFound(); |
| 3414 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3415 | // Remaining clean-up |
| 3416 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3417 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3418 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 3419 | } |
| 3420 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
| 3421 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, descriptorSet); |
| 3422 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3423 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3424 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3425 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3426 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3427 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3428 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3429 | m_errorMonitor->SetDesiredFailureMsg( |
| 3430 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3431 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3432 | |
| 3433 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3434 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3435 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3436 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3437 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3438 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3439 | } |
| 3440 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3441 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 3442 | VkResult err; |
| 3443 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3444 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3445 | m_errorMonitor->SetDesiredFailureMsg( |
| 3446 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 3447 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3448 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3449 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3450 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3451 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3452 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3453 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3454 | cmd.commandPool = m_commandPool; |
| 3455 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3456 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3457 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3458 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3459 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3460 | |
| 3461 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3462 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3463 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3464 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3465 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3466 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 3467 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3468 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3469 | |
| 3470 | // The error should be caught by validation of the BeginCommandBuffer call |
| 3471 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 3472 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3473 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3474 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3475 | } |
| 3476 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3477 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3478 | // Cause error due to Begin while recording CB |
| 3479 | // Then cause 2 errors for attempting to reset CB w/o having |
| 3480 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 3481 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3482 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3483 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3484 | |
| 3485 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3486 | |
| 3487 | // Calls AllocateCommandBuffers |
| 3488 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 3489 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3490 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 3491 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3492 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3493 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3494 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3495 | cmd_buf_info.pNext = NULL; |
| 3496 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3497 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3498 | |
| 3499 | // Begin CB to transition to recording state |
| 3500 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 3501 | // Can't re-begin. This should trigger error |
| 3502 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3503 | m_errorMonitor->VerifyFound(); |
| 3504 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3505 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3506 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3507 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 3508 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 3509 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3510 | m_errorMonitor->VerifyFound(); |
| 3511 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3512 | m_errorMonitor->SetDesiredFailureMsg( |
| 3513 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3514 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3515 | // Transition CB to RECORDED state |
| 3516 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 3517 | // Now attempting to Begin will implicitly reset, which triggers error |
| 3518 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3519 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3520 | } |
| 3521 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3522 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3523 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3524 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3525 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3526 | m_errorMonitor->SetDesiredFailureMsg( |
| 3527 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3528 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 3529 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3530 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3531 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3532 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3533 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3534 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3535 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3536 | |
| 3537 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3538 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3539 | ds_pool_ci.pNext = NULL; |
| 3540 | ds_pool_ci.maxSets = 1; |
| 3541 | ds_pool_ci.poolSizeCount = 1; |
| 3542 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3543 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3544 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3545 | err = |
| 3546 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3547 | ASSERT_VK_SUCCESS(err); |
| 3548 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3549 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3550 | dsl_binding.binding = 0; |
| 3551 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3552 | dsl_binding.descriptorCount = 1; |
| 3553 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3554 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3555 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3556 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3557 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3558 | ds_layout_ci.pNext = NULL; |
| 3559 | ds_layout_ci.bindingCount = 1; |
| 3560 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3561 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3562 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3563 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3564 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3565 | ASSERT_VK_SUCCESS(err); |
| 3566 | |
| 3567 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3568 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3569 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3570 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3571 | alloc_info.descriptorPool = ds_pool; |
| 3572 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3573 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3574 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3575 | ASSERT_VK_SUCCESS(err); |
| 3576 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3577 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3578 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3579 | pipeline_layout_ci.setLayoutCount = 1; |
| 3580 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3581 | |
| 3582 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3583 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3584 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3585 | ASSERT_VK_SUCCESS(err); |
| 3586 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3587 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3588 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3589 | |
| 3590 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3591 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3592 | vp_state_ci.scissorCount = 1; |
| 3593 | vp_state_ci.pScissors = ≻ |
| 3594 | vp_state_ci.viewportCount = 1; |
| 3595 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3596 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3597 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 3598 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3599 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 3600 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 3601 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 3602 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 3603 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 3604 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 3605 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3606 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3607 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3608 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3609 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3610 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3611 | gp_ci.layout = pipeline_layout; |
| 3612 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3613 | |
| 3614 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3615 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3616 | pc_ci.initialDataSize = 0; |
| 3617 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3618 | |
| 3619 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3620 | VkPipelineCache pipelineCache; |
| 3621 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3622 | err = |
| 3623 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 3624 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3625 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3626 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3627 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3628 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3629 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3630 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3631 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3632 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3633 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3634 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3635 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 3636 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 3637 | { |
| 3638 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3639 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3640 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3641 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3642 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 3643 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3644 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3645 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3646 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3647 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3648 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3649 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3650 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3651 | |
| 3652 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3653 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3654 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3655 | ds_pool_ci.poolSizeCount = 1; |
| 3656 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3657 | |
| 3658 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3659 | err = vkCreateDescriptorPool(m_device->device(), |
| 3660 | 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] | 3661 | ASSERT_VK_SUCCESS(err); |
| 3662 | |
| 3663 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3664 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3665 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3666 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3667 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3668 | dsl_binding.pImmutableSamplers = NULL; |
| 3669 | |
| 3670 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3671 | ds_layout_ci.sType = |
| 3672 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3673 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3674 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3675 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3676 | |
| 3677 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3678 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3679 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3680 | ASSERT_VK_SUCCESS(err); |
| 3681 | |
| 3682 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3683 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 3684 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3685 | ASSERT_VK_SUCCESS(err); |
| 3686 | |
| 3687 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3688 | pipeline_layout_ci.sType = |
| 3689 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3690 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3691 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3692 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3693 | |
| 3694 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3695 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3696 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3697 | ASSERT_VK_SUCCESS(err); |
| 3698 | |
| 3699 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 3700 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 3701 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3702 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 3703 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3704 | // 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] | 3705 | VkShaderObj |
| 3706 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 3707 | this); |
| 3708 | VkShaderObj |
| 3709 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 3710 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3711 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3712 | shaderStages[0].sType = |
| 3713 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3714 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3715 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3716 | shaderStages[1].sType = |
| 3717 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3718 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3719 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3720 | shaderStages[2].sType = |
| 3721 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3722 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3723 | shaderStages[2].shader = te.handle(); |
| 3724 | |
| 3725 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3726 | iaCI.sType = |
| 3727 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3728 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3729 | |
| 3730 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 3731 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 3732 | tsCI.patchControlPoints = 0; // This will cause an error |
| 3733 | |
| 3734 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 3735 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3736 | gp_ci.pNext = NULL; |
| 3737 | gp_ci.stageCount = 3; |
| 3738 | gp_ci.pStages = shaderStages; |
| 3739 | gp_ci.pVertexInputState = NULL; |
| 3740 | gp_ci.pInputAssemblyState = &iaCI; |
| 3741 | gp_ci.pTessellationState = &tsCI; |
| 3742 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3743 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3744 | gp_ci.pMultisampleState = NULL; |
| 3745 | gp_ci.pDepthStencilState = NULL; |
| 3746 | gp_ci.pColorBlendState = NULL; |
| 3747 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3748 | gp_ci.layout = pipeline_layout; |
| 3749 | gp_ci.renderPass = renderPass(); |
| 3750 | |
| 3751 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 3752 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3753 | pc_ci.pNext = NULL; |
| 3754 | pc_ci.initialSize = 0; |
| 3755 | pc_ci.initialData = 0; |
| 3756 | pc_ci.maxSize = 0; |
| 3757 | |
| 3758 | VkPipeline pipeline; |
| 3759 | VkPipelineCache pipelineCache; |
| 3760 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3761 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 3762 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3763 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3764 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3765 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3766 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3767 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3768 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3769 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3770 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3771 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3772 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 3773 | } |
| 3774 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3775 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3776 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3777 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3778 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3779 | m_errorMonitor->SetDesiredFailureMsg( |
| 3780 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3781 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 3782 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3783 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3784 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3785 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3786 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3787 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3788 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3789 | |
| 3790 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3791 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3792 | ds_pool_ci.maxSets = 1; |
| 3793 | ds_pool_ci.poolSizeCount = 1; |
| 3794 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3795 | |
| 3796 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3797 | err = |
| 3798 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3799 | ASSERT_VK_SUCCESS(err); |
| 3800 | |
| 3801 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3802 | dsl_binding.binding = 0; |
| 3803 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3804 | dsl_binding.descriptorCount = 1; |
| 3805 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3806 | |
| 3807 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3808 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3809 | ds_layout_ci.bindingCount = 1; |
| 3810 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3811 | |
| 3812 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3813 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3814 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3815 | ASSERT_VK_SUCCESS(err); |
| 3816 | |
| 3817 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3818 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3819 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3820 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3821 | alloc_info.descriptorPool = ds_pool; |
| 3822 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3823 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3824 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3825 | ASSERT_VK_SUCCESS(err); |
| 3826 | |
| 3827 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3828 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3829 | pipeline_layout_ci.setLayoutCount = 1; |
| 3830 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3831 | |
| 3832 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3833 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3834 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3835 | ASSERT_VK_SUCCESS(err); |
| 3836 | |
| 3837 | VkViewport vp = {}; // Just need dummy vp to point to |
| 3838 | |
| 3839 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3840 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 3841 | vp_state_ci.scissorCount = 0; |
| 3842 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 3843 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3844 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3845 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 3846 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3847 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 3848 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 3849 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 3850 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 3851 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 3852 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 3853 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3854 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3855 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3856 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3857 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3858 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3859 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3860 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3861 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3862 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3863 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3864 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3865 | |
| 3866 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3867 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3868 | gp_ci.stageCount = 2; |
| 3869 | gp_ci.pStages = shaderStages; |
| 3870 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3871 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3872 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3873 | gp_ci.layout = pipeline_layout; |
| 3874 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3875 | |
| 3876 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3877 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3878 | |
| 3879 | VkPipeline pipeline; |
| 3880 | VkPipelineCache pipelineCache; |
| 3881 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3882 | err = |
| 3883 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3884 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3885 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 3886 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3887 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3888 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3889 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3890 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3891 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3892 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3893 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3894 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3895 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 3896 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3897 | // 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] | 3898 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3899 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3900 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3901 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3902 | m_errorMonitor->SetDesiredFailureMsg( |
| 3903 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3904 | "Gfx Pipeline pViewportState is null. Even if "); |
| 3905 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3906 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3907 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3908 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3909 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3910 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3911 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3912 | |
| 3913 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3914 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3915 | ds_pool_ci.maxSets = 1; |
| 3916 | ds_pool_ci.poolSizeCount = 1; |
| 3917 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -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 | e68360f | 2015-10-01 11:15:13 -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_UNIFORM_BUFFER; |
| 3927 | dsl_binding.descriptorCount = 1; |
| 3928 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3929 | |
| 3930 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3931 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3932 | ds_layout_ci.bindingCount = 1; |
| 3933 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3934 | |
| 3935 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3936 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3937 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3938 | ASSERT_VK_SUCCESS(err); |
| 3939 | |
| 3940 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3941 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3942 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3943 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3944 | alloc_info.descriptorPool = ds_pool; |
| 3945 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3946 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3947 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3948 | ASSERT_VK_SUCCESS(err); |
| 3949 | |
| 3950 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3951 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3952 | pipeline_layout_ci.setLayoutCount = 1; |
| 3953 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3954 | |
| 3955 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3956 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3957 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3958 | ASSERT_VK_SUCCESS(err); |
| 3959 | |
| 3960 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 3961 | // Set scissor as dynamic to avoid second error |
| 3962 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3963 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 3964 | dyn_state_ci.dynamicStateCount = 1; |
| 3965 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3966 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3967 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3968 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3969 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3970 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3971 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3972 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3973 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3974 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3975 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3976 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3977 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3978 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3979 | |
| 3980 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 3981 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 3982 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 3983 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 3984 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 3985 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 3986 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 3987 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 3988 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3989 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3990 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 3991 | gp_ci.stageCount = 2; |
| 3992 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 3993 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3994 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 3995 | // should cause validation error |
| 3996 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3997 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3998 | gp_ci.layout = pipeline_layout; |
| 3999 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4000 | |
| 4001 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4002 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4003 | |
| 4004 | VkPipeline pipeline; |
| 4005 | VkPipelineCache pipelineCache; |
| 4006 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4007 | err = |
| 4008 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4009 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4010 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4011 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4012 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4013 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4014 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4015 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4016 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4017 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4018 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4019 | } |
| 4020 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4021 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 4022 | // count |
| 4023 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 4024 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4025 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4026 | m_errorMonitor->SetDesiredFailureMsg( |
| 4027 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4028 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 4029 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4030 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4031 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4032 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4033 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4034 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4035 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4036 | |
| 4037 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4038 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4039 | ds_pool_ci.maxSets = 1; |
| 4040 | ds_pool_ci.poolSizeCount = 1; |
| 4041 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4042 | |
| 4043 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4044 | err = |
| 4045 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4046 | ASSERT_VK_SUCCESS(err); |
| 4047 | |
| 4048 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4049 | dsl_binding.binding = 0; |
| 4050 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4051 | dsl_binding.descriptorCount = 1; |
| 4052 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4053 | |
| 4054 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4055 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4056 | ds_layout_ci.bindingCount = 1; |
| 4057 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4058 | |
| 4059 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4060 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4061 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4062 | ASSERT_VK_SUCCESS(err); |
| 4063 | |
| 4064 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4065 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4066 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4067 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4068 | alloc_info.descriptorPool = ds_pool; |
| 4069 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4070 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4071 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4072 | ASSERT_VK_SUCCESS(err); |
| 4073 | |
| 4074 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4075 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4076 | pipeline_layout_ci.setLayoutCount = 1; |
| 4077 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4078 | |
| 4079 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4080 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4081 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4082 | ASSERT_VK_SUCCESS(err); |
| 4083 | |
| 4084 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4085 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4086 | vp_state_ci.viewportCount = 1; |
| 4087 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 4088 | vp_state_ci.scissorCount = 1; |
| 4089 | vp_state_ci.pScissors = |
| 4090 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4091 | |
| 4092 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4093 | // Set scissor as dynamic to avoid that error |
| 4094 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4095 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4096 | dyn_state_ci.dynamicStateCount = 1; |
| 4097 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4098 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4099 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4100 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4101 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4102 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4103 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4104 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4105 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4106 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4107 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4108 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4109 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4110 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4111 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4112 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4113 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4114 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4115 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4116 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4117 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4118 | |
| 4119 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4120 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4121 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4122 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4123 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4124 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4125 | rs_ci.pNext = nullptr; |
| 4126 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4127 | VkPipelineColorBlendAttachmentState att = {}; |
| 4128 | att.blendEnable = VK_FALSE; |
| 4129 | att.colorWriteMask = 0xf; |
| 4130 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4131 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4132 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4133 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4134 | cb_ci.attachmentCount = 1; |
| 4135 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4136 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4137 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4138 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4139 | gp_ci.stageCount = 2; |
| 4140 | gp_ci.pStages = shaderStages; |
| 4141 | gp_ci.pVertexInputState = &vi_ci; |
| 4142 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4143 | gp_ci.pViewportState = &vp_state_ci; |
| 4144 | gp_ci.pRasterizationState = &rs_ci; |
| 4145 | gp_ci.pColorBlendState = &cb_ci; |
| 4146 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4147 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4148 | gp_ci.layout = pipeline_layout; |
| 4149 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4150 | |
| 4151 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4152 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4153 | |
| 4154 | VkPipeline pipeline; |
| 4155 | VkPipelineCache pipelineCache; |
| 4156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4157 | err = |
| 4158 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4159 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4160 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4161 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4162 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4163 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4164 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4165 | // 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] | 4166 | // First need to successfully create the PSO from above by setting |
| 4167 | // pViewports |
| 4168 | m_errorMonitor->SetDesiredFailureMsg( |
| 4169 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4170 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 4171 | "scissorCount is 1. These counts must match."); |
| 4172 | |
| 4173 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4174 | vp_state_ci.pViewports = &vp; |
| 4175 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4176 | &gp_ci, NULL, &pipeline); |
| 4177 | ASSERT_VK_SUCCESS(err); |
| 4178 | BeginCommandBuffer(); |
| 4179 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4180 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4181 | VkRect2D scissors[2] = {}; // don't care about data |
| 4182 | // Count of 2 doesn't match PSO count of 1 |
| 4183 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 4184 | Draw(1, 0, 0, 0); |
| 4185 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4186 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4187 | |
| 4188 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4189 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4190 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4191 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4192 | } |
| 4193 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 4194 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 4195 | // viewportCount |
| 4196 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 4197 | VkResult err; |
| 4198 | |
| 4199 | m_errorMonitor->SetDesiredFailureMsg( |
| 4200 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4201 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 4202 | |
| 4203 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4204 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4205 | |
| 4206 | VkDescriptorPoolSize ds_type_count = {}; |
| 4207 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4208 | ds_type_count.descriptorCount = 1; |
| 4209 | |
| 4210 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4211 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4212 | ds_pool_ci.maxSets = 1; |
| 4213 | ds_pool_ci.poolSizeCount = 1; |
| 4214 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4215 | |
| 4216 | VkDescriptorPool ds_pool; |
| 4217 | err = |
| 4218 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4219 | ASSERT_VK_SUCCESS(err); |
| 4220 | |
| 4221 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4222 | dsl_binding.binding = 0; |
| 4223 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4224 | dsl_binding.descriptorCount = 1; |
| 4225 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4226 | |
| 4227 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4228 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4229 | ds_layout_ci.bindingCount = 1; |
| 4230 | ds_layout_ci.pBindings = &dsl_binding; |
| 4231 | |
| 4232 | VkDescriptorSetLayout ds_layout; |
| 4233 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4234 | &ds_layout); |
| 4235 | ASSERT_VK_SUCCESS(err); |
| 4236 | |
| 4237 | VkDescriptorSet descriptorSet; |
| 4238 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4239 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4240 | alloc_info.descriptorSetCount = 1; |
| 4241 | alloc_info.descriptorPool = ds_pool; |
| 4242 | alloc_info.pSetLayouts = &ds_layout; |
| 4243 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4244 | &descriptorSet); |
| 4245 | ASSERT_VK_SUCCESS(err); |
| 4246 | |
| 4247 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4248 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4249 | pipeline_layout_ci.setLayoutCount = 1; |
| 4250 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4251 | |
| 4252 | VkPipelineLayout pipeline_layout; |
| 4253 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4254 | &pipeline_layout); |
| 4255 | ASSERT_VK_SUCCESS(err); |
| 4256 | |
| 4257 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4258 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4259 | vp_state_ci.scissorCount = 1; |
| 4260 | vp_state_ci.pScissors = |
| 4261 | NULL; // Null scissor w/ count of 1 should cause error |
| 4262 | vp_state_ci.viewportCount = 1; |
| 4263 | vp_state_ci.pViewports = |
| 4264 | NULL; // vp is dynamic (below) so this won't cause error |
| 4265 | |
| 4266 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 4267 | // Set scissor as dynamic to avoid that error |
| 4268 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4269 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4270 | dyn_state_ci.dynamicStateCount = 1; |
| 4271 | dyn_state_ci.pDynamicStates = &vp_state; |
| 4272 | |
| 4273 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4274 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4275 | |
| 4276 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4277 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4278 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4279 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4280 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4281 | // but add it to be able to run on more devices |
| 4282 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4283 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4284 | |
| 4285 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4286 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4287 | vi_ci.pNext = nullptr; |
| 4288 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4289 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4290 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4291 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4292 | |
| 4293 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4294 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4295 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4296 | |
| 4297 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4298 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4299 | rs_ci.pNext = nullptr; |
| 4300 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4301 | VkPipelineColorBlendAttachmentState att = {}; |
| 4302 | att.blendEnable = VK_FALSE; |
| 4303 | att.colorWriteMask = 0xf; |
| 4304 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4305 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4306 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4307 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4308 | cb_ci.attachmentCount = 1; |
| 4309 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4310 | |
| 4311 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4312 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4313 | gp_ci.stageCount = 2; |
| 4314 | gp_ci.pStages = shaderStages; |
| 4315 | gp_ci.pVertexInputState = &vi_ci; |
| 4316 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4317 | gp_ci.pViewportState = &vp_state_ci; |
| 4318 | gp_ci.pRasterizationState = &rs_ci; |
| 4319 | gp_ci.pColorBlendState = &cb_ci; |
| 4320 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4321 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4322 | gp_ci.layout = pipeline_layout; |
| 4323 | gp_ci.renderPass = renderPass(); |
| 4324 | |
| 4325 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4326 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4327 | |
| 4328 | VkPipeline pipeline; |
| 4329 | VkPipelineCache pipelineCache; |
| 4330 | |
| 4331 | err = |
| 4332 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4333 | ASSERT_VK_SUCCESS(err); |
| 4334 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4335 | &gp_ci, NULL, &pipeline); |
| 4336 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4337 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4338 | |
| 4339 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 4340 | // First need to successfully create the PSO from above by setting |
| 4341 | // pViewports |
| 4342 | m_errorMonitor->SetDesiredFailureMsg( |
| 4343 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4344 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 4345 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4346 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4347 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 4348 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4349 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4350 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4351 | ASSERT_VK_SUCCESS(err); |
| 4352 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4353 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4354 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4355 | VkViewport viewports[2] = {}; // don't care about data |
| 4356 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 4357 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4358 | Draw(1, 0, 0, 0); |
| 4359 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4360 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4361 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4362 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4363 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4364 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4365 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4366 | } |
| 4367 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4368 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 4369 | VkResult err; |
| 4370 | |
| 4371 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4372 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4373 | |
| 4374 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4375 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4376 | |
| 4377 | VkDescriptorPoolSize ds_type_count = {}; |
| 4378 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4379 | ds_type_count.descriptorCount = 1; |
| 4380 | |
| 4381 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4382 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4383 | ds_pool_ci.maxSets = 1; |
| 4384 | ds_pool_ci.poolSizeCount = 1; |
| 4385 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4386 | |
| 4387 | VkDescriptorPool ds_pool; |
| 4388 | err = |
| 4389 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4390 | ASSERT_VK_SUCCESS(err); |
| 4391 | |
| 4392 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4393 | dsl_binding.binding = 0; |
| 4394 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4395 | dsl_binding.descriptorCount = 1; |
| 4396 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4397 | |
| 4398 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4399 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4400 | ds_layout_ci.bindingCount = 1; |
| 4401 | ds_layout_ci.pBindings = &dsl_binding; |
| 4402 | |
| 4403 | VkDescriptorSetLayout ds_layout; |
| 4404 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4405 | &ds_layout); |
| 4406 | ASSERT_VK_SUCCESS(err); |
| 4407 | |
| 4408 | VkDescriptorSet descriptorSet; |
| 4409 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4410 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4411 | alloc_info.descriptorSetCount = 1; |
| 4412 | alloc_info.descriptorPool = ds_pool; |
| 4413 | alloc_info.pSetLayouts = &ds_layout; |
| 4414 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4415 | &descriptorSet); |
| 4416 | ASSERT_VK_SUCCESS(err); |
| 4417 | |
| 4418 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4419 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4420 | pipeline_layout_ci.setLayoutCount = 1; |
| 4421 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4422 | |
| 4423 | VkPipelineLayout pipeline_layout; |
| 4424 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4425 | &pipeline_layout); |
| 4426 | ASSERT_VK_SUCCESS(err); |
| 4427 | |
| 4428 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4429 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4430 | vp_state_ci.scissorCount = 1; |
| 4431 | vp_state_ci.pScissors = NULL; |
| 4432 | vp_state_ci.viewportCount = 1; |
| 4433 | vp_state_ci.pViewports = NULL; |
| 4434 | |
| 4435 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 4436 | VK_DYNAMIC_STATE_SCISSOR, |
| 4437 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 4438 | // Set scissor as dynamic to avoid that error |
| 4439 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4440 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4441 | dyn_state_ci.dynamicStateCount = 2; |
| 4442 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 4443 | |
| 4444 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4445 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4446 | |
| 4447 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4448 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4449 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4450 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4451 | this); // TODO - We shouldn't need a fragment shader |
| 4452 | // but add it to be able to run on more devices |
| 4453 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4454 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4455 | |
| 4456 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4457 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4458 | vi_ci.pNext = nullptr; |
| 4459 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4460 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4461 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4462 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4463 | |
| 4464 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4465 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4466 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4467 | |
| 4468 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4469 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4470 | rs_ci.pNext = nullptr; |
| 4471 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4472 | // Check too low (line width of -1.0f). |
| 4473 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4474 | |
| 4475 | VkPipelineColorBlendAttachmentState att = {}; |
| 4476 | att.blendEnable = VK_FALSE; |
| 4477 | att.colorWriteMask = 0xf; |
| 4478 | |
| 4479 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4480 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4481 | cb_ci.pNext = nullptr; |
| 4482 | cb_ci.attachmentCount = 1; |
| 4483 | cb_ci.pAttachments = &att; |
| 4484 | |
| 4485 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4486 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4487 | gp_ci.stageCount = 2; |
| 4488 | gp_ci.pStages = shaderStages; |
| 4489 | gp_ci.pVertexInputState = &vi_ci; |
| 4490 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4491 | gp_ci.pViewportState = &vp_state_ci; |
| 4492 | gp_ci.pRasterizationState = &rs_ci; |
| 4493 | gp_ci.pColorBlendState = &cb_ci; |
| 4494 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4495 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4496 | gp_ci.layout = pipeline_layout; |
| 4497 | gp_ci.renderPass = renderPass(); |
| 4498 | |
| 4499 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4500 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4501 | |
| 4502 | VkPipeline pipeline; |
| 4503 | VkPipelineCache pipelineCache; |
| 4504 | |
| 4505 | err = |
| 4506 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4507 | ASSERT_VK_SUCCESS(err); |
| 4508 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4509 | &gp_ci, NULL, &pipeline); |
| 4510 | |
| 4511 | m_errorMonitor->VerifyFound(); |
| 4512 | |
| 4513 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4514 | "Attempt to set lineWidth to 65536"); |
| 4515 | |
| 4516 | // Check too high (line width of 65536.0f). |
| 4517 | rs_ci.lineWidth = 65536.0f; |
| 4518 | |
| 4519 | err = |
| 4520 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4521 | ASSERT_VK_SUCCESS(err); |
| 4522 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4523 | &gp_ci, NULL, &pipeline); |
| 4524 | |
| 4525 | m_errorMonitor->VerifyFound(); |
| 4526 | |
| 4527 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4528 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4529 | |
| 4530 | dyn_state_ci.dynamicStateCount = 3; |
| 4531 | |
| 4532 | rs_ci.lineWidth = 1.0f; |
| 4533 | |
| 4534 | err = |
| 4535 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4536 | ASSERT_VK_SUCCESS(err); |
| 4537 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4538 | &gp_ci, NULL, &pipeline); |
| 4539 | BeginCommandBuffer(); |
| 4540 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4541 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4542 | |
| 4543 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4544 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4545 | m_errorMonitor->VerifyFound(); |
| 4546 | |
| 4547 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4548 | "Attempt to set lineWidth to 65536"); |
| 4549 | |
| 4550 | // Check too high with dynamic setting. |
| 4551 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 4552 | m_errorMonitor->VerifyFound(); |
| 4553 | EndCommandBuffer(); |
| 4554 | |
| 4555 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4556 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4557 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4558 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4559 | } |
| 4560 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4561 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4562 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4563 | m_errorMonitor->SetDesiredFailureMsg( |
| 4564 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4565 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4566 | |
| 4567 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4568 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4569 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4570 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4571 | // Don't care about RenderPass handle b/c error should be flagged before |
| 4572 | // that |
| 4573 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 4574 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4575 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4576 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 4577 | } |
| 4578 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4579 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4580 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4581 | m_errorMonitor->SetDesiredFailureMsg( |
| 4582 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4583 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4584 | |
| 4585 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4586 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4587 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4588 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4589 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 4590 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4591 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4592 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 4593 | rp_begin.pNext = NULL; |
| 4594 | rp_begin.renderPass = renderPass(); |
| 4595 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4596 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4597 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 4598 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4599 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4600 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4601 | } |
| 4602 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4603 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4604 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4605 | m_errorMonitor->SetDesiredFailureMsg( |
| 4606 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4607 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4608 | |
| 4609 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4610 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4611 | |
| 4612 | // Renderpass is started here |
| 4613 | BeginCommandBuffer(); |
| 4614 | |
| 4615 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4616 | vk_testing::Buffer dstBuffer; |
| 4617 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4618 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4619 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4620 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4621 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4622 | } |
| 4623 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4624 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4625 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4626 | m_errorMonitor->SetDesiredFailureMsg( |
| 4627 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4628 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4629 | |
| 4630 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4631 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4632 | |
| 4633 | // Renderpass is started here |
| 4634 | BeginCommandBuffer(); |
| 4635 | |
| 4636 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4637 | vk_testing::Buffer dstBuffer; |
| 4638 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4639 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4640 | VkDeviceSize dstOffset = 0; |
| 4641 | VkDeviceSize dataSize = 1024; |
| 4642 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4643 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4644 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 4645 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4646 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4647 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4648 | } |
| 4649 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4650 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4651 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4652 | m_errorMonitor->SetDesiredFailureMsg( |
| 4653 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4654 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4655 | |
| 4656 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4657 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4658 | |
| 4659 | // Renderpass is started here |
| 4660 | BeginCommandBuffer(); |
| 4661 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 4662 | VkClearColorValue clear_color; |
| 4663 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4664 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4665 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4666 | const int32_t tex_width = 32; |
| 4667 | const int32_t tex_height = 32; |
| 4668 | VkImageCreateInfo image_create_info = {}; |
| 4669 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4670 | image_create_info.pNext = NULL; |
| 4671 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4672 | image_create_info.format = tex_format; |
| 4673 | image_create_info.extent.width = tex_width; |
| 4674 | image_create_info.extent.height = tex_height; |
| 4675 | image_create_info.extent.depth = 1; |
| 4676 | image_create_info.mipLevels = 1; |
| 4677 | image_create_info.arrayLayers = 1; |
| 4678 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4679 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4680 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4681 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4682 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4683 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 4684 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4685 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4686 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 4687 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4688 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4689 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 4690 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4691 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4692 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4693 | } |
| 4694 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4695 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4696 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4697 | m_errorMonitor->SetDesiredFailureMsg( |
| 4698 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4699 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4700 | |
| 4701 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4702 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4703 | |
| 4704 | // Renderpass is started here |
| 4705 | BeginCommandBuffer(); |
| 4706 | |
| 4707 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 4708 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4709 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 4710 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4711 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 4712 | image_create_info.extent.width = 64; |
| 4713 | image_create_info.extent.height = 64; |
| 4714 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 4715 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4716 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4717 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4718 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 4719 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4720 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4721 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 4722 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4723 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4724 | vkCmdClearDepthStencilImage( |
| 4725 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 4726 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 4727 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4728 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4729 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4730 | } |
| 4731 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4732 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4733 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4734 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4735 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4736 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4737 | "vkCmdClearAttachments: This call " |
| 4738 | "must be issued inside an active " |
| 4739 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4740 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4741 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4742 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4743 | |
| 4744 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4745 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4746 | ASSERT_VK_SUCCESS(err); |
| 4747 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4748 | VkClearAttachment color_attachment; |
| 4749 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4750 | color_attachment.clearValue.color.float32[0] = 0; |
| 4751 | color_attachment.clearValue.color.float32[1] = 0; |
| 4752 | color_attachment.clearValue.color.float32[2] = 0; |
| 4753 | color_attachment.clearValue.color.float32[3] = 0; |
| 4754 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4755 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 4756 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 4757 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4758 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4759 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 4760 | } |
| 4761 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 4762 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 4763 | // Try to add a buffer memory barrier with no buffer. |
| 4764 | m_errorMonitor->SetDesiredFailureMsg( |
| 4765 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4766 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 4767 | |
| 4768 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4769 | BeginCommandBuffer(); |
| 4770 | |
| 4771 | VkBufferMemoryBarrier buf_barrier = {}; |
| 4772 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 4773 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 4774 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 4775 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4776 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4777 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 4778 | buf_barrier.offset = 0; |
| 4779 | buf_barrier.size = VK_WHOLE_SIZE; |
| 4780 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4781 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 4782 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 4783 | |
| 4784 | m_errorMonitor->VerifyFound(); |
| 4785 | } |
| 4786 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 4787 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 4788 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 4789 | |
| 4790 | m_errorMonitor->SetDesiredFailureMsg( |
| 4791 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 4792 | |
| 4793 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4794 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4795 | |
| 4796 | VkMemoryBarrier mem_barrier = {}; |
| 4797 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 4798 | mem_barrier.pNext = NULL; |
| 4799 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 4800 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 4801 | BeginCommandBuffer(); |
| 4802 | // BeginCommandBuffer() starts a render pass |
| 4803 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4804 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4805 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 4806 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 4807 | m_errorMonitor->VerifyFound(); |
| 4808 | |
| 4809 | m_errorMonitor->SetDesiredFailureMsg( |
| 4810 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4811 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 4812 | VkImageObj image(m_device); |
| 4813 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 4814 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 4815 | ASSERT_TRUE(image.initialized()); |
| 4816 | VkImageMemoryBarrier img_barrier = {}; |
| 4817 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 4818 | img_barrier.pNext = NULL; |
| 4819 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 4820 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 4821 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4822 | // New layout can't be UNDEFINED |
| 4823 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 4824 | img_barrier.image = image.handle(); |
| 4825 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4826 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4827 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4828 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 4829 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 4830 | img_barrier.subresourceRange.layerCount = 1; |
| 4831 | img_barrier.subresourceRange.levelCount = 1; |
| 4832 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4833 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4834 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 4835 | nullptr, 1, &img_barrier); |
| 4836 | m_errorMonitor->VerifyFound(); |
| 4837 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4838 | |
| 4839 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4840 | "Subresource must have the sum of the " |
| 4841 | "baseArrayLayer"); |
| 4842 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 4843 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 4844 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4845 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4846 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 4847 | nullptr, 1, &img_barrier); |
| 4848 | m_errorMonitor->VerifyFound(); |
| 4849 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 4850 | |
| 4851 | m_errorMonitor->SetDesiredFailureMsg( |
| 4852 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4853 | "Subresource must have the sum of the baseMipLevel"); |
| 4854 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 4855 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 4856 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4857 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4858 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 4859 | nullptr, 1, &img_barrier); |
| 4860 | m_errorMonitor->VerifyFound(); |
| 4861 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 4862 | |
| 4863 | m_errorMonitor->SetDesiredFailureMsg( |
| 4864 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4865 | "Buffer Barriers cannot be used during a render pass"); |
| 4866 | vk_testing::Buffer buffer; |
| 4867 | buffer.init(*m_device, 256); |
| 4868 | VkBufferMemoryBarrier buf_barrier = {}; |
| 4869 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 4870 | buf_barrier.pNext = NULL; |
| 4871 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 4872 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 4873 | buf_barrier.buffer = buffer.handle(); |
| 4874 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4875 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 4876 | buf_barrier.offset = 0; |
| 4877 | buf_barrier.size = VK_WHOLE_SIZE; |
| 4878 | // Can't send buffer barrier during a render pass |
| 4879 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4880 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4881 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 4882 | &buf_barrier, 0, nullptr); |
| 4883 | m_errorMonitor->VerifyFound(); |
| 4884 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 4885 | |
| 4886 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4887 | "which is not less than total size"); |
| 4888 | buf_barrier.offset = 257; |
| 4889 | // Offset greater than total size |
| 4890 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4891 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4892 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 4893 | &buf_barrier, 0, nullptr); |
| 4894 | m_errorMonitor->VerifyFound(); |
| 4895 | buf_barrier.offset = 0; |
| 4896 | |
| 4897 | m_errorMonitor->SetDesiredFailureMsg( |
| 4898 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 4899 | buf_barrier.size = 257; |
| 4900 | // Size greater than total size |
| 4901 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4902 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4903 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 4904 | &buf_barrier, 0, nullptr); |
| 4905 | m_errorMonitor->VerifyFound(); |
| 4906 | buf_barrier.size = VK_WHOLE_SIZE; |
| 4907 | |
| 4908 | m_errorMonitor->SetDesiredFailureMsg( |
| 4909 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4910 | "Image is a depth and stencil format and thus must " |
| 4911 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 4912 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 4913 | VkDepthStencilObj ds_image(m_device); |
| 4914 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 4915 | ASSERT_TRUE(ds_image.initialized()); |
| 4916 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 4917 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 4918 | img_barrier.image = ds_image.handle(); |
| 4919 | // Leave aspectMask at COLOR on purpose |
| 4920 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 4921 | VK_PIPELINE_STAGE_HOST_BIT, |
| 4922 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 4923 | nullptr, 1, &img_barrier); |
| 4924 | m_errorMonitor->VerifyFound(); |
| 4925 | } |
| 4926 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4927 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 4928 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4929 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 4930 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4931 | m_errorMonitor->SetDesiredFailureMsg( |
| 4932 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4933 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 4934 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 4935 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4936 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 4937 | uint32_t qfi = 0; |
| 4938 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4939 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4940 | buffCI.size = 1024; |
| 4941 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 4942 | buffCI.queueFamilyIndexCount = 1; |
| 4943 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 4944 | |
| 4945 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4946 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 4947 | ASSERT_VK_SUCCESS(err); |
| 4948 | |
| 4949 | BeginCommandBuffer(); |
| 4950 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4951 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4952 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 4953 | // 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] | 4954 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 4955 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 4956 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4957 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4958 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4959 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 4960 | } |
| 4961 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 4962 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 4963 | // Create an out-of-range queueFamilyIndex |
| 4964 | m_errorMonitor->SetDesiredFailureMsg( |
| 4965 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 4966 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 4967 | |
| 4968 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4969 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4970 | VkBufferCreateInfo buffCI = {}; |
| 4971 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4972 | buffCI.size = 1024; |
| 4973 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 4974 | buffCI.queueFamilyIndexCount = 1; |
| 4975 | // Introduce failure by specifying invalid queue_family_index |
| 4976 | uint32_t qfi = 777; |
| 4977 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 4978 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 4979 | |
| 4980 | VkBuffer ib; |
| 4981 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 4982 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4983 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 4984 | } |
| 4985 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4986 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 4987 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 4988 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4989 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4990 | m_errorMonitor->SetDesiredFailureMsg( |
| 4991 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4992 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 4993 | |
| 4994 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4995 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 4996 | |
| 4997 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4998 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4999 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 5000 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5001 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5002 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5003 | } |
| 5004 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5005 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5006 | // 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] | 5007 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5008 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5009 | m_errorMonitor->SetDesiredFailureMsg( |
| 5010 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Write descriptor update has descriptor " |
| 5011 | "type VK_DESCRIPTOR_TYPE_SAMPLER that " |
| 5012 | "does not match "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5013 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5014 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5015 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5016 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5017 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5018 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5019 | |
| 5020 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5021 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5022 | ds_pool_ci.pNext = NULL; |
| 5023 | ds_pool_ci.maxSets = 1; |
| 5024 | ds_pool_ci.poolSizeCount = 1; |
| 5025 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5026 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5027 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5028 | err = |
| 5029 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5030 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5031 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5032 | dsl_binding.binding = 0; |
| 5033 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5034 | dsl_binding.descriptorCount = 1; |
| 5035 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5036 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5037 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5038 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5039 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5040 | ds_layout_ci.pNext = NULL; |
| 5041 | ds_layout_ci.bindingCount = 1; |
| 5042 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5043 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5044 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5045 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5046 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5047 | ASSERT_VK_SUCCESS(err); |
| 5048 | |
| 5049 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5050 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5051 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5052 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5053 | alloc_info.descriptorPool = ds_pool; |
| 5054 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5055 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5056 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5057 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5058 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5059 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5060 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5061 | sampler_ci.pNext = NULL; |
| 5062 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5063 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5064 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5065 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5066 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5067 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5068 | sampler_ci.mipLodBias = 1.0; |
| 5069 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5070 | sampler_ci.maxAnisotropy = 1; |
| 5071 | sampler_ci.compareEnable = VK_FALSE; |
| 5072 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5073 | sampler_ci.minLod = 1.0; |
| 5074 | sampler_ci.maxLod = 1.0; |
| 5075 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5076 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 5077 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5078 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5079 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5080 | ASSERT_VK_SUCCESS(err); |
| 5081 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5082 | VkDescriptorImageInfo info = {}; |
| 5083 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5084 | |
| 5085 | VkWriteDescriptorSet descriptor_write; |
| 5086 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5087 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5088 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5089 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5090 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5091 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5092 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5093 | |
| 5094 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5095 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5096 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5097 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5098 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5099 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5100 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5101 | } |
| 5102 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5103 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5104 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5105 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5106 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5107 | m_errorMonitor->SetDesiredFailureMsg( |
| 5108 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Descriptor update type of " |
| 5109 | "VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET " |
| 5110 | "is out of bounds for matching binding"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5111 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5112 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5113 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5114 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5115 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5116 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5117 | |
| 5118 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5119 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5120 | ds_pool_ci.pNext = NULL; |
| 5121 | ds_pool_ci.maxSets = 1; |
| 5122 | ds_pool_ci.poolSizeCount = 1; |
| 5123 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5124 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5125 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5126 | err = |
| 5127 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5128 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5129 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5130 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5131 | dsl_binding.binding = 0; |
| 5132 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5133 | dsl_binding.descriptorCount = 1; |
| 5134 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5135 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5136 | |
| 5137 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5138 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5139 | ds_layout_ci.pNext = NULL; |
| 5140 | ds_layout_ci.bindingCount = 1; |
| 5141 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5142 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5143 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5144 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5145 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5146 | ASSERT_VK_SUCCESS(err); |
| 5147 | |
| 5148 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5149 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5150 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5151 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5152 | alloc_info.descriptorPool = ds_pool; |
| 5153 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5154 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5155 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5156 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5157 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5158 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5159 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5160 | sampler_ci.pNext = NULL; |
| 5161 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5162 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5163 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5164 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5165 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5166 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5167 | sampler_ci.mipLodBias = 1.0; |
| 5168 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5169 | sampler_ci.maxAnisotropy = 1; |
| 5170 | sampler_ci.compareEnable = VK_FALSE; |
| 5171 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5172 | sampler_ci.minLod = 1.0; |
| 5173 | sampler_ci.maxLod = 1.0; |
| 5174 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5175 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5176 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5177 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5178 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5179 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5180 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5181 | VkDescriptorImageInfo info = {}; |
| 5182 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5183 | |
| 5184 | VkWriteDescriptorSet descriptor_write; |
| 5185 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5186 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5187 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5188 | descriptor_write.dstArrayElement = |
| 5189 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5190 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5191 | // 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] | 5192 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5193 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5194 | |
| 5195 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5196 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5197 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5198 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5199 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5200 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5201 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5202 | } |
| 5203 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5204 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 5205 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 5206 | // index 2 |
| 5207 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5208 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5209 | m_errorMonitor->SetDesiredFailureMsg( |
| 5210 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5211 | " does not have binding to match update binding "); |
| 5212 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5213 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5214 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5215 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5216 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5217 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5218 | |
| 5219 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5220 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5221 | ds_pool_ci.pNext = NULL; |
| 5222 | ds_pool_ci.maxSets = 1; |
| 5223 | ds_pool_ci.poolSizeCount = 1; |
| 5224 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5225 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5226 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5227 | err = |
| 5228 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5229 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5230 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5231 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5232 | dsl_binding.binding = 0; |
| 5233 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5234 | dsl_binding.descriptorCount = 1; |
| 5235 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5236 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5237 | |
| 5238 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5239 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5240 | ds_layout_ci.pNext = NULL; |
| 5241 | ds_layout_ci.bindingCount = 1; |
| 5242 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5243 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5244 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5245 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5246 | ASSERT_VK_SUCCESS(err); |
| 5247 | |
| 5248 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5249 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5250 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5251 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5252 | alloc_info.descriptorPool = ds_pool; |
| 5253 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5254 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5255 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5256 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5257 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5258 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5259 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5260 | sampler_ci.pNext = NULL; |
| 5261 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5262 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5263 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5264 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5265 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5266 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5267 | sampler_ci.mipLodBias = 1.0; |
| 5268 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5269 | sampler_ci.maxAnisotropy = 1; |
| 5270 | sampler_ci.compareEnable = VK_FALSE; |
| 5271 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5272 | sampler_ci.minLod = 1.0; |
| 5273 | sampler_ci.maxLod = 1.0; |
| 5274 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5275 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5276 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5277 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5278 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5279 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5280 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5281 | VkDescriptorImageInfo info = {}; |
| 5282 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5283 | |
| 5284 | VkWriteDescriptorSet descriptor_write; |
| 5285 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5286 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5287 | descriptor_write.dstSet = descriptorSet; |
| 5288 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5289 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5290 | // 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] | 5291 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5292 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5293 | |
| 5294 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5295 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5296 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5297 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5298 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5299 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5300 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5301 | } |
| 5302 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5303 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 5304 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 5305 | // types |
| 5306 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5307 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5308 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5309 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5310 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5311 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5312 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5313 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5314 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5315 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5316 | |
| 5317 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5318 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5319 | ds_pool_ci.pNext = NULL; |
| 5320 | ds_pool_ci.maxSets = 1; |
| 5321 | ds_pool_ci.poolSizeCount = 1; |
| 5322 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5323 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5324 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5325 | err = |
| 5326 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5327 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5328 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5329 | dsl_binding.binding = 0; |
| 5330 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5331 | dsl_binding.descriptorCount = 1; |
| 5332 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5333 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5334 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5335 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5336 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5337 | ds_layout_ci.pNext = NULL; |
| 5338 | ds_layout_ci.bindingCount = 1; |
| 5339 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5340 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5341 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5342 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5343 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5344 | ASSERT_VK_SUCCESS(err); |
| 5345 | |
| 5346 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5347 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5348 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5349 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5350 | alloc_info.descriptorPool = ds_pool; |
| 5351 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5352 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5353 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5354 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5355 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5356 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5357 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5358 | sampler_ci.pNext = NULL; |
| 5359 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5360 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5361 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5362 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5363 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5364 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5365 | sampler_ci.mipLodBias = 1.0; |
| 5366 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5367 | sampler_ci.maxAnisotropy = 1; |
| 5368 | sampler_ci.compareEnable = VK_FALSE; |
| 5369 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5370 | sampler_ci.minLod = 1.0; |
| 5371 | sampler_ci.maxLod = 1.0; |
| 5372 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5373 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5374 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5375 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5376 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5377 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5378 | VkDescriptorImageInfo info = {}; |
| 5379 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5380 | |
| 5381 | VkWriteDescriptorSet descriptor_write; |
| 5382 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5383 | descriptor_write.sType = |
| 5384 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5385 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5386 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5387 | // 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] | 5388 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5389 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5390 | |
| 5391 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5392 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5393 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5394 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5395 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5396 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5397 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5398 | } |
| 5399 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5400 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5401 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5402 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5403 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5404 | m_errorMonitor->SetDesiredFailureMsg( |
| 5405 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5406 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 5407 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5408 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5409 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 5410 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5411 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5412 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5413 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5414 | |
| 5415 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5416 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5417 | ds_pool_ci.pNext = NULL; |
| 5418 | ds_pool_ci.maxSets = 1; |
| 5419 | ds_pool_ci.poolSizeCount = 1; |
| 5420 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5421 | |
| 5422 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5423 | err = |
| 5424 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5425 | ASSERT_VK_SUCCESS(err); |
| 5426 | |
| 5427 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5428 | dsl_binding.binding = 0; |
| 5429 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5430 | dsl_binding.descriptorCount = 1; |
| 5431 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5432 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5433 | |
| 5434 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5435 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5436 | ds_layout_ci.pNext = NULL; |
| 5437 | ds_layout_ci.bindingCount = 1; |
| 5438 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5439 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5440 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5441 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5442 | ASSERT_VK_SUCCESS(err); |
| 5443 | |
| 5444 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5445 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5446 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5447 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5448 | alloc_info.descriptorPool = ds_pool; |
| 5449 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5450 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5451 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5452 | ASSERT_VK_SUCCESS(err); |
| 5453 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5454 | VkSampler sampler = |
| 5455 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5456 | |
| 5457 | VkDescriptorImageInfo descriptor_info; |
| 5458 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5459 | descriptor_info.sampler = sampler; |
| 5460 | |
| 5461 | VkWriteDescriptorSet descriptor_write; |
| 5462 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5463 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5464 | descriptor_write.dstSet = descriptorSet; |
| 5465 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5466 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5467 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5468 | descriptor_write.pImageInfo = &descriptor_info; |
| 5469 | |
| 5470 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5471 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5472 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5473 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5474 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5475 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5476 | } |
| 5477 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5478 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 5479 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 5480 | // imageView |
| 5481 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5482 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5483 | m_errorMonitor->SetDesiredFailureMsg( |
| 5484 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5485 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 5486 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5487 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5488 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5489 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5490 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5491 | |
| 5492 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5493 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5494 | ds_pool_ci.pNext = NULL; |
| 5495 | ds_pool_ci.maxSets = 1; |
| 5496 | ds_pool_ci.poolSizeCount = 1; |
| 5497 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5498 | |
| 5499 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5500 | err = |
| 5501 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5502 | ASSERT_VK_SUCCESS(err); |
| 5503 | |
| 5504 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5505 | dsl_binding.binding = 0; |
| 5506 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5507 | dsl_binding.descriptorCount = 1; |
| 5508 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5509 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5510 | |
| 5511 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5512 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5513 | ds_layout_ci.pNext = NULL; |
| 5514 | ds_layout_ci.bindingCount = 1; |
| 5515 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5516 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5517 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5518 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5519 | ASSERT_VK_SUCCESS(err); |
| 5520 | |
| 5521 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5522 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5523 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5524 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5525 | alloc_info.descriptorPool = ds_pool; |
| 5526 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5527 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5528 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5529 | ASSERT_VK_SUCCESS(err); |
| 5530 | |
| 5531 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5532 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5533 | sampler_ci.pNext = NULL; |
| 5534 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5535 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5536 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5537 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5538 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5539 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5540 | sampler_ci.mipLodBias = 1.0; |
| 5541 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5542 | sampler_ci.maxAnisotropy = 1; |
| 5543 | sampler_ci.compareEnable = VK_FALSE; |
| 5544 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5545 | sampler_ci.minLod = 1.0; |
| 5546 | sampler_ci.maxLod = 1.0; |
| 5547 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5548 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5549 | |
| 5550 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5551 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5552 | ASSERT_VK_SUCCESS(err); |
| 5553 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5554 | VkImageView view = |
| 5555 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5556 | |
| 5557 | VkDescriptorImageInfo descriptor_info; |
| 5558 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5559 | descriptor_info.sampler = sampler; |
| 5560 | descriptor_info.imageView = view; |
| 5561 | |
| 5562 | VkWriteDescriptorSet descriptor_write; |
| 5563 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5564 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5565 | descriptor_write.dstSet = descriptorSet; |
| 5566 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5567 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5568 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5569 | descriptor_write.pImageInfo = &descriptor_info; |
| 5570 | |
| 5571 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5572 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5573 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5574 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5575 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5576 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5577 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5578 | } |
| 5579 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5580 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 5581 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 5582 | // into the other |
| 5583 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5584 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5585 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5586 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5587 | "Copy descriptor update index 0, has src update descriptor " |
| 5588 | "type VK_DESCRIPTOR_TYPE_SAMPLER that does not match overlapping " |
| 5589 | "dest "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5590 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5591 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5592 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5593 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5594 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5595 | ds_type_count[0].descriptorCount = 1; |
| 5596 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5597 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5598 | |
| 5599 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5600 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5601 | ds_pool_ci.pNext = NULL; |
| 5602 | ds_pool_ci.maxSets = 1; |
| 5603 | ds_pool_ci.poolSizeCount = 2; |
| 5604 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5605 | |
| 5606 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5607 | err = |
| 5608 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5609 | ASSERT_VK_SUCCESS(err); |
| 5610 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5611 | dsl_binding[0].binding = 0; |
| 5612 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5613 | dsl_binding[0].descriptorCount = 1; |
| 5614 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5615 | dsl_binding[0].pImmutableSamplers = NULL; |
| 5616 | dsl_binding[1].binding = 1; |
| 5617 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5618 | dsl_binding[1].descriptorCount = 1; |
| 5619 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5620 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5621 | |
| 5622 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5623 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5624 | ds_layout_ci.pNext = NULL; |
| 5625 | ds_layout_ci.bindingCount = 2; |
| 5626 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5627 | |
| 5628 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5629 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5630 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5631 | ASSERT_VK_SUCCESS(err); |
| 5632 | |
| 5633 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5634 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5635 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5636 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5637 | alloc_info.descriptorPool = ds_pool; |
| 5638 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5639 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5640 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5641 | ASSERT_VK_SUCCESS(err); |
| 5642 | |
| 5643 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5644 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5645 | sampler_ci.pNext = NULL; |
| 5646 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5647 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5648 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5649 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5650 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5651 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5652 | sampler_ci.mipLodBias = 1.0; |
| 5653 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5654 | sampler_ci.maxAnisotropy = 1; |
| 5655 | sampler_ci.compareEnable = VK_FALSE; |
| 5656 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5657 | sampler_ci.minLod = 1.0; |
| 5658 | sampler_ci.maxLod = 1.0; |
| 5659 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5660 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5661 | |
| 5662 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5663 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5664 | ASSERT_VK_SUCCESS(err); |
| 5665 | |
| 5666 | VkDescriptorImageInfo info = {}; |
| 5667 | info.sampler = sampler; |
| 5668 | |
| 5669 | VkWriteDescriptorSet descriptor_write; |
| 5670 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 5671 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5672 | descriptor_write.dstSet = descriptorSet; |
| 5673 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5674 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5675 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5676 | descriptor_write.pImageInfo = &info; |
| 5677 | // This write update should succeed |
| 5678 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5679 | // Now perform a copy update that fails due to type mismatch |
| 5680 | VkCopyDescriptorSet copy_ds_update; |
| 5681 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 5682 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 5683 | copy_ds_update.srcSet = descriptorSet; |
| 5684 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5685 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5686 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5687 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5688 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 5689 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5690 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5691 | // 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] | 5692 | m_errorMonitor->SetDesiredFailureMsg( |
| 5693 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5694 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5695 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 5696 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 5697 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5698 | copy_ds_update.srcBinding = |
| 5699 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5700 | copy_ds_update.dstSet = descriptorSet; |
| 5701 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5702 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5703 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 5704 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5705 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5706 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5707 | // 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] | 5708 | m_errorMonitor->SetDesiredFailureMsg( |
| 5709 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5710 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 5711 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5712 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 5713 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 5714 | copy_ds_update.srcSet = descriptorSet; |
| 5715 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5716 | copy_ds_update.dstSet = descriptorSet; |
| 5717 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5718 | copy_ds_update.descriptorCount = |
| 5719 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5720 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 5721 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5722 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5723 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5724 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5725 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5726 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 5727 | } |
| 5728 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5729 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 5730 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 5731 | // sampleCount |
| 5732 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5733 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5734 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5735 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5736 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5737 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5738 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5739 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5740 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5741 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5742 | |
| 5743 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5744 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5745 | ds_pool_ci.pNext = NULL; |
| 5746 | ds_pool_ci.maxSets = 1; |
| 5747 | ds_pool_ci.poolSizeCount = 1; |
| 5748 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5749 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5750 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5751 | err = |
| 5752 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5753 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5754 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5755 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5756 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5757 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5758 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5759 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5760 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5761 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5762 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5763 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5764 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5765 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5766 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5767 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5768 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5769 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5770 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5771 | ASSERT_VK_SUCCESS(err); |
| 5772 | |
| 5773 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5774 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5775 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5776 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5777 | alloc_info.descriptorPool = ds_pool; |
| 5778 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5779 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5780 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5781 | ASSERT_VK_SUCCESS(err); |
| 5782 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5783 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5784 | pipe_ms_state_ci.sType = |
| 5785 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 5786 | pipe_ms_state_ci.pNext = NULL; |
| 5787 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 5788 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 5789 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 5790 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5791 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5792 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5793 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5794 | pipeline_layout_ci.pNext = NULL; |
| 5795 | pipeline_layout_ci.setLayoutCount = 1; |
| 5796 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5797 | |
| 5798 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5799 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5800 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5801 | ASSERT_VK_SUCCESS(err); |
| 5802 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5803 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5804 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5805 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5806 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5807 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5808 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 5809 | VkPipelineObj pipe(m_device); |
| 5810 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 5811 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5812 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 5813 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 5814 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5815 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5816 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5817 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5818 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5819 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5820 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5821 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5822 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5823 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5824 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5825 | } |
Tobin Ehlis | 0f10db5 | 2016-04-04 10:00:21 -0600 | [diff] [blame] | 5826 | #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] | 5827 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 5828 | // Create Pipeline where the number of blend attachments doesn't match the |
| 5829 | // number of color attachments. In this case, we don't add any color |
| 5830 | // blend attachments even though we have a color attachment. |
| 5831 | VkResult err; |
| 5832 | |
| 5833 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5834 | "Mismatch between blend state attachment"); |
| 5835 | |
| 5836 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5837 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5838 | VkDescriptorPoolSize ds_type_count = {}; |
| 5839 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5840 | ds_type_count.descriptorCount = 1; |
| 5841 | |
| 5842 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5843 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5844 | ds_pool_ci.pNext = NULL; |
| 5845 | ds_pool_ci.maxSets = 1; |
| 5846 | ds_pool_ci.poolSizeCount = 1; |
| 5847 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 5848 | |
| 5849 | VkDescriptorPool ds_pool; |
| 5850 | err = |
| 5851 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 5852 | ASSERT_VK_SUCCESS(err); |
| 5853 | |
| 5854 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5855 | dsl_binding.binding = 0; |
| 5856 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5857 | dsl_binding.descriptorCount = 1; |
| 5858 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5859 | dsl_binding.pImmutableSamplers = NULL; |
| 5860 | |
| 5861 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5862 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5863 | ds_layout_ci.pNext = NULL; |
| 5864 | ds_layout_ci.bindingCount = 1; |
| 5865 | ds_layout_ci.pBindings = &dsl_binding; |
| 5866 | |
| 5867 | VkDescriptorSetLayout ds_layout; |
| 5868 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5869 | &ds_layout); |
| 5870 | ASSERT_VK_SUCCESS(err); |
| 5871 | |
| 5872 | VkDescriptorSet descriptorSet; |
| 5873 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 5874 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 5875 | alloc_info.descriptorSetCount = 1; |
| 5876 | alloc_info.descriptorPool = ds_pool; |
| 5877 | alloc_info.pSetLayouts = &ds_layout; |
| 5878 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5879 | &descriptorSet); |
| 5880 | ASSERT_VK_SUCCESS(err); |
| 5881 | |
| 5882 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 5883 | pipe_ms_state_ci.sType = |
| 5884 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 5885 | pipe_ms_state_ci.pNext = NULL; |
| 5886 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 5887 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 5888 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 5889 | pipe_ms_state_ci.pSampleMask = NULL; |
| 5890 | |
| 5891 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5892 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5893 | pipeline_layout_ci.pNext = NULL; |
| 5894 | pipeline_layout_ci.setLayoutCount = 1; |
| 5895 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5896 | |
| 5897 | VkPipelineLayout pipeline_layout; |
| 5898 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5899 | &pipeline_layout); |
| 5900 | ASSERT_VK_SUCCESS(err); |
| 5901 | |
| 5902 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5903 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5904 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5905 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5906 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5907 | // but add it to be able to run on more devices |
| 5908 | VkPipelineObj pipe(m_device); |
| 5909 | pipe.AddShader(&vs); |
| 5910 | pipe.AddShader(&fs); |
| 5911 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 5912 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 5913 | |
| 5914 | BeginCommandBuffer(); |
| 5915 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5916 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5917 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5918 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5919 | |
| 5920 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5921 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5922 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5923 | } |
Tony Barbour | 4e81a20 | 2016-04-04 11:09:40 -0600 | [diff] [blame] | 5924 | #endif //ADD_BACK_IN_WHEN_CHECK_IS_BACK |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5925 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 5926 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 5927 | // to issuing a Draw |
| 5928 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 5929 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5930 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 5931 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5932 | "vkCmdClearAttachments() issued on CB object "); |
| 5933 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 5934 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5935 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5936 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5937 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5938 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5939 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5940 | |
| 5941 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5942 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5943 | ds_pool_ci.pNext = NULL; |
| 5944 | ds_pool_ci.maxSets = 1; |
| 5945 | ds_pool_ci.poolSizeCount = 1; |
| 5946 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5947 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 5948 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5949 | err = |
| 5950 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 5951 | ASSERT_VK_SUCCESS(err); |
| 5952 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5953 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5954 | dsl_binding.binding = 0; |
| 5955 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5956 | dsl_binding.descriptorCount = 1; |
| 5957 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5958 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 5959 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5960 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5961 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5962 | ds_layout_ci.pNext = NULL; |
| 5963 | ds_layout_ci.bindingCount = 1; |
| 5964 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5965 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 5966 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5967 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5968 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 5969 | ASSERT_VK_SUCCESS(err); |
| 5970 | |
| 5971 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5972 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5973 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5974 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5975 | alloc_info.descriptorPool = ds_pool; |
| 5976 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5977 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5978 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 5979 | ASSERT_VK_SUCCESS(err); |
| 5980 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5981 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5982 | pipe_ms_state_ci.sType = |
| 5983 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 5984 | pipe_ms_state_ci.pNext = NULL; |
| 5985 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 5986 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 5987 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 5988 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 5989 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5990 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5991 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5992 | pipeline_layout_ci.pNext = NULL; |
| 5993 | pipeline_layout_ci.setLayoutCount = 1; |
| 5994 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 5995 | |
| 5996 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5997 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5998 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 5999 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6000 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6001 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6002 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6003 | // 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] | 6004 | // on more devices |
| 6005 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6006 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6007 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6008 | VkPipelineObj pipe(m_device); |
| 6009 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6010 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6011 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6012 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6013 | |
| 6014 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6015 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6016 | // Main thing we care about for this test is that the VkImage obj we're |
| 6017 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6018 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6019 | VkClearAttachment color_attachment; |
| 6020 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6021 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 6022 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 6023 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 6024 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 6025 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6026 | VkClearRect clear_rect = { |
| 6027 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6028 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6029 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6030 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6031 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6032 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6033 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6034 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6035 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6036 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6037 | } |
| 6038 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6039 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 6040 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6041 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6042 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6043 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 6044 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6045 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6046 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6047 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6048 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6049 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6050 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6051 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6052 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6053 | |
| 6054 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6055 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6056 | ds_pool_ci.pNext = NULL; |
| 6057 | ds_pool_ci.maxSets = 1; |
| 6058 | ds_pool_ci.poolSizeCount = 1; |
| 6059 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6060 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6061 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6062 | err = |
| 6063 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6064 | ASSERT_VK_SUCCESS(err); |
| 6065 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6066 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6067 | dsl_binding.binding = 0; |
| 6068 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6069 | dsl_binding.descriptorCount = 1; |
| 6070 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6071 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6072 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6073 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6074 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6075 | ds_layout_ci.pNext = NULL; |
| 6076 | ds_layout_ci.bindingCount = 1; |
| 6077 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6078 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6079 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6080 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6081 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6082 | ASSERT_VK_SUCCESS(err); |
| 6083 | |
| 6084 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6085 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6086 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6087 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6088 | alloc_info.descriptorPool = ds_pool; |
| 6089 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6090 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6091 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6092 | ASSERT_VK_SUCCESS(err); |
| 6093 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6094 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6095 | pipe_ms_state_ci.sType = |
| 6096 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6097 | pipe_ms_state_ci.pNext = NULL; |
| 6098 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6099 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6100 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6101 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6102 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6103 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6104 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6105 | pipeline_layout_ci.pNext = NULL; |
| 6106 | pipeline_layout_ci.setLayoutCount = 1; |
| 6107 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6108 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6109 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6110 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6111 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6112 | ASSERT_VK_SUCCESS(err); |
| 6113 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6114 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6115 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6116 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6117 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6118 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6119 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6120 | VkPipelineObj pipe(m_device); |
| 6121 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6122 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6123 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6124 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6125 | pipe.SetViewport(m_viewports); |
| 6126 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6127 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6128 | |
| 6129 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6130 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6131 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6132 | // Don't care about actual data, just need to get to draw to flag error |
| 6133 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6134 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 6135 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6136 | 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] | 6137 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6138 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6139 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6140 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6141 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6142 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6143 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6144 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6145 | #endif // DRAW_STATE_TESTS |
| 6146 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 6147 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6148 | #if GTEST_IS_THREADSAFE |
| 6149 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6150 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6151 | VkEvent event; |
| 6152 | bool bailout; |
| 6153 | }; |
| 6154 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6155 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 6156 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6158 | for (int i = 0; i < 10000; i++) { |
| 6159 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 6160 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6161 | if (data->bailout) { |
| 6162 | break; |
| 6163 | } |
| 6164 | } |
| 6165 | return NULL; |
| 6166 | } |
| 6167 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6168 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6169 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6170 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6171 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6172 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6173 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6174 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6175 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6176 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6177 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6178 | // Calls AllocateCommandBuffers |
| 6179 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6180 | |
| 6181 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6182 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6183 | |
| 6184 | VkEventCreateInfo event_info; |
| 6185 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6186 | VkResult err; |
| 6187 | |
| 6188 | memset(&event_info, 0, sizeof(event_info)); |
| 6189 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 6190 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6191 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6192 | ASSERT_VK_SUCCESS(err); |
| 6193 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6194 | err = vkResetEvent(device(), event); |
| 6195 | ASSERT_VK_SUCCESS(err); |
| 6196 | |
| 6197 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6198 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6199 | data.event = event; |
| 6200 | data.bailout = false; |
| 6201 | m_errorMonitor->SetBailout(&data.bailout); |
| 6202 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6203 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6204 | // Add many entries to command buffer from this thread at the same time. |
| 6205 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6206 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6207 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6208 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6209 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 6210 | m_errorMonitor->SetBailout(NULL); |
| 6211 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6212 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6213 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6214 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6215 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6216 | #endif // GTEST_IS_THREADSAFE |
| 6217 | #endif // THREADING_TESTS |
| 6218 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6219 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6220 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6221 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6222 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6223 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6224 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6225 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6226 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6227 | VkShaderModule module; |
| 6228 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6229 | struct icd_spv_header spv; |
| 6230 | |
| 6231 | spv.magic = ICD_SPV_MAGIC; |
| 6232 | spv.version = ICD_SPV_VERSION; |
| 6233 | spv.gen_magic = 0; |
| 6234 | |
| 6235 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6236 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6237 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6238 | moduleCreateInfo.codeSize = 4; |
| 6239 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6240 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6241 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6242 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6243 | } |
| 6244 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6245 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6246 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6247 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6248 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6249 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6250 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6251 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6252 | VkShaderModule module; |
| 6253 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6254 | struct icd_spv_header spv; |
| 6255 | |
| 6256 | spv.magic = ~ICD_SPV_MAGIC; |
| 6257 | spv.version = ICD_SPV_VERSION; |
| 6258 | spv.gen_magic = 0; |
| 6259 | |
| 6260 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6261 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6262 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6263 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6264 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6265 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6266 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6267 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6268 | } |
| 6269 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6270 | #if 0 |
| 6271 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6272 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6273 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6274 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6275 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6276 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6277 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6278 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6279 | VkShaderModule module; |
| 6280 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6281 | struct icd_spv_header spv; |
| 6282 | |
| 6283 | spv.magic = ICD_SPV_MAGIC; |
| 6284 | spv.version = ~ICD_SPV_VERSION; |
| 6285 | spv.gen_magic = 0; |
| 6286 | |
| 6287 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6288 | moduleCreateInfo.pNext = NULL; |
| 6289 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6290 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6291 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6292 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6293 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6294 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6295 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6296 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6297 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6298 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6299 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6300 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6301 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6302 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6303 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6304 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6305 | |
| 6306 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6307 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6308 | "\n" |
| 6309 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6310 | "out gl_PerVertex {\n" |
| 6311 | " vec4 gl_Position;\n" |
| 6312 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6313 | "void main(){\n" |
| 6314 | " gl_Position = vec4(1);\n" |
| 6315 | " x = 0;\n" |
| 6316 | "}\n"; |
| 6317 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6318 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6319 | "\n" |
| 6320 | "layout(location=0) out vec4 color;\n" |
| 6321 | "void main(){\n" |
| 6322 | " color = vec4(1);\n" |
| 6323 | "}\n"; |
| 6324 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6325 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6326 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6327 | |
| 6328 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6329 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6330 | pipe.AddShader(&vs); |
| 6331 | pipe.AddShader(&fs); |
| 6332 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6333 | VkDescriptorSetObj descriptorSet(m_device); |
| 6334 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6335 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6336 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6337 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6338 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6339 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6340 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6341 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6342 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6343 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6344 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6345 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6346 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6347 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6348 | |
| 6349 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6350 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6351 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6352 | "out gl_PerVertex {\n" |
| 6353 | " vec4 gl_Position;\n" |
| 6354 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6355 | "void main(){\n" |
| 6356 | " gl_Position = vec4(1);\n" |
| 6357 | "}\n"; |
| 6358 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6359 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6360 | "\n" |
| 6361 | "layout(location=0) in float x;\n" |
| 6362 | "layout(location=0) out vec4 color;\n" |
| 6363 | "void main(){\n" |
| 6364 | " color = vec4(x);\n" |
| 6365 | "}\n"; |
| 6366 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6367 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6368 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6369 | |
| 6370 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6371 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6372 | pipe.AddShader(&vs); |
| 6373 | pipe.AddShader(&fs); |
| 6374 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6375 | VkDescriptorSetObj descriptorSet(m_device); |
| 6376 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6377 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6378 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6379 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6380 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6381 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6382 | } |
| 6383 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6384 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6385 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6386 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6387 | |
| 6388 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6389 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6390 | |
| 6391 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6392 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6393 | "\n" |
| 6394 | "out gl_PerVertex {\n" |
| 6395 | " vec4 gl_Position;\n" |
| 6396 | "};\n" |
| 6397 | "void main(){\n" |
| 6398 | " gl_Position = vec4(1);\n" |
| 6399 | "}\n"; |
| 6400 | char const *fsSource = |
| 6401 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6402 | "\n" |
| 6403 | "in block { layout(location=0) float x; } ins;\n" |
| 6404 | "layout(location=0) out vec4 color;\n" |
| 6405 | "void main(){\n" |
| 6406 | " color = vec4(ins.x);\n" |
| 6407 | "}\n"; |
| 6408 | |
| 6409 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6410 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6411 | |
| 6412 | VkPipelineObj pipe(m_device); |
| 6413 | pipe.AddColorAttachment(); |
| 6414 | pipe.AddShader(&vs); |
| 6415 | pipe.AddShader(&fs); |
| 6416 | |
| 6417 | VkDescriptorSetObj descriptorSet(m_device); |
| 6418 | descriptorSet.AppendDummy(); |
| 6419 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6420 | |
| 6421 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6422 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6423 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6424 | } |
| 6425 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6426 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6427 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6428 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6429 | "output arr[2] of float32' vs 'ptr to " |
| 6430 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6431 | |
| 6432 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6433 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6434 | |
| 6435 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6436 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6437 | "\n" |
| 6438 | "layout(location=0) out float x[2];\n" |
| 6439 | "out gl_PerVertex {\n" |
| 6440 | " vec4 gl_Position;\n" |
| 6441 | "};\n" |
| 6442 | "void main(){\n" |
| 6443 | " x[0] = 0; x[1] = 0;\n" |
| 6444 | " gl_Position = vec4(1);\n" |
| 6445 | "}\n"; |
| 6446 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6447 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6448 | "\n" |
| 6449 | "layout(location=0) in float x[3];\n" |
| 6450 | "layout(location=0) out vec4 color;\n" |
| 6451 | "void main(){\n" |
| 6452 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 6453 | "}\n"; |
| 6454 | |
| 6455 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6456 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6457 | |
| 6458 | VkPipelineObj pipe(m_device); |
| 6459 | pipe.AddColorAttachment(); |
| 6460 | pipe.AddShader(&vs); |
| 6461 | pipe.AddShader(&fs); |
| 6462 | |
| 6463 | VkDescriptorSetObj descriptorSet(m_device); |
| 6464 | descriptorSet.AppendDummy(); |
| 6465 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6466 | |
| 6467 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6468 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6469 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 6470 | } |
| 6471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6472 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6473 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6474 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6475 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6476 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6477 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6478 | |
| 6479 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6480 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6481 | "\n" |
| 6482 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6483 | "out gl_PerVertex {\n" |
| 6484 | " vec4 gl_Position;\n" |
| 6485 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6486 | "void main(){\n" |
| 6487 | " x = 0;\n" |
| 6488 | " gl_Position = vec4(1);\n" |
| 6489 | "}\n"; |
| 6490 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6491 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6492 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6493 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6494 | "layout(location=0) out vec4 color;\n" |
| 6495 | "void main(){\n" |
| 6496 | " color = vec4(x);\n" |
| 6497 | "}\n"; |
| 6498 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6499 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6500 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6501 | |
| 6502 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6503 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6504 | pipe.AddShader(&vs); |
| 6505 | pipe.AddShader(&fs); |
| 6506 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6507 | VkDescriptorSetObj descriptorSet(m_device); |
| 6508 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6509 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6510 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6511 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6512 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6513 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 6514 | } |
| 6515 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6516 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6517 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6518 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6519 | |
| 6520 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6521 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6522 | |
| 6523 | char const *vsSource = |
| 6524 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6525 | "\n" |
| 6526 | "out block { layout(location=0) int x; } outs;\n" |
| 6527 | "out gl_PerVertex {\n" |
| 6528 | " vec4 gl_Position;\n" |
| 6529 | "};\n" |
| 6530 | "void main(){\n" |
| 6531 | " outs.x = 0;\n" |
| 6532 | " gl_Position = vec4(1);\n" |
| 6533 | "}\n"; |
| 6534 | char const *fsSource = |
| 6535 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6536 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6537 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6538 | "layout(location=0) out vec4 color;\n" |
| 6539 | "void main(){\n" |
| 6540 | " color = vec4(ins.x);\n" |
| 6541 | "}\n"; |
| 6542 | |
| 6543 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6544 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6545 | |
| 6546 | VkPipelineObj pipe(m_device); |
| 6547 | pipe.AddColorAttachment(); |
| 6548 | pipe.AddShader(&vs); |
| 6549 | pipe.AddShader(&fs); |
| 6550 | |
| 6551 | VkDescriptorSetObj descriptorSet(m_device); |
| 6552 | descriptorSet.AppendDummy(); |
| 6553 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6554 | |
| 6555 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6556 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6557 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6558 | } |
| 6559 | |
| 6560 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 6561 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6562 | "location 0.0 which is not written by vertex shader"); |
| 6563 | |
| 6564 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6565 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6566 | |
| 6567 | char const *vsSource = |
| 6568 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6569 | "\n" |
| 6570 | "out block { layout(location=1) float x; } outs;\n" |
| 6571 | "out gl_PerVertex {\n" |
| 6572 | " vec4 gl_Position;\n" |
| 6573 | "};\n" |
| 6574 | "void main(){\n" |
| 6575 | " outs.x = 0;\n" |
| 6576 | " gl_Position = vec4(1);\n" |
| 6577 | "}\n"; |
| 6578 | char const *fsSource = |
| 6579 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6580 | "\n" |
| 6581 | "in block { layout(location=0) float x; } ins;\n" |
| 6582 | "layout(location=0) out vec4 color;\n" |
| 6583 | "void main(){\n" |
| 6584 | " color = vec4(ins.x);\n" |
| 6585 | "}\n"; |
| 6586 | |
| 6587 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6588 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6589 | |
| 6590 | VkPipelineObj pipe(m_device); |
| 6591 | pipe.AddColorAttachment(); |
| 6592 | pipe.AddShader(&vs); |
| 6593 | pipe.AddShader(&fs); |
| 6594 | |
| 6595 | VkDescriptorSetObj descriptorSet(m_device); |
| 6596 | descriptorSet.AppendDummy(); |
| 6597 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6598 | |
| 6599 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6600 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6601 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6602 | } |
| 6603 | |
| 6604 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 6605 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6606 | "location 0.1 which is not written by vertex shader"); |
| 6607 | |
| 6608 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6609 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6610 | |
| 6611 | char const *vsSource = |
| 6612 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6613 | "\n" |
| 6614 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 6615 | "out gl_PerVertex {\n" |
| 6616 | " vec4 gl_Position;\n" |
| 6617 | "};\n" |
| 6618 | "void main(){\n" |
| 6619 | " outs.x = 0;\n" |
| 6620 | " gl_Position = vec4(1);\n" |
| 6621 | "}\n"; |
| 6622 | char const *fsSource = |
| 6623 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 6624 | "\n" |
| 6625 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 6626 | "layout(location=0) out vec4 color;\n" |
| 6627 | "void main(){\n" |
| 6628 | " color = vec4(ins.x);\n" |
| 6629 | "}\n"; |
| 6630 | |
| 6631 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6632 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6633 | |
| 6634 | VkPipelineObj pipe(m_device); |
| 6635 | pipe.AddColorAttachment(); |
| 6636 | pipe.AddShader(&vs); |
| 6637 | pipe.AddShader(&fs); |
| 6638 | |
| 6639 | VkDescriptorSetObj descriptorSet(m_device); |
| 6640 | descriptorSet.AppendDummy(); |
| 6641 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6642 | |
| 6643 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6644 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6645 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 6646 | } |
| 6647 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6648 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6649 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6650 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6651 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6652 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6653 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6654 | |
| 6655 | VkVertexInputBindingDescription input_binding; |
| 6656 | memset(&input_binding, 0, sizeof(input_binding)); |
| 6657 | |
| 6658 | VkVertexInputAttributeDescription input_attrib; |
| 6659 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 6660 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 6661 | |
| 6662 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6663 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6664 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6665 | "out gl_PerVertex {\n" |
| 6666 | " vec4 gl_Position;\n" |
| 6667 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6668 | "void main(){\n" |
| 6669 | " gl_Position = vec4(1);\n" |
| 6670 | "}\n"; |
| 6671 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6672 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6673 | "\n" |
| 6674 | "layout(location=0) out vec4 color;\n" |
| 6675 | "void main(){\n" |
| 6676 | " color = vec4(1);\n" |
| 6677 | "}\n"; |
| 6678 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6679 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6680 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6681 | |
| 6682 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6683 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6684 | pipe.AddShader(&vs); |
| 6685 | pipe.AddShader(&fs); |
| 6686 | |
| 6687 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 6688 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 6689 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6690 | VkDescriptorSetObj descriptorSet(m_device); |
| 6691 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6692 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6693 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6694 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6695 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6696 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 6697 | } |
| 6698 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6699 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6700 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6701 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 6702 | |
| 6703 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6704 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6705 | |
| 6706 | VkVertexInputBindingDescription input_binding; |
| 6707 | memset(&input_binding, 0, sizeof(input_binding)); |
| 6708 | |
| 6709 | VkVertexInputAttributeDescription input_attrib; |
| 6710 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 6711 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 6712 | |
| 6713 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6714 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 6715 | "\n" |
| 6716 | "layout(location=1) in float x;\n" |
| 6717 | "out gl_PerVertex {\n" |
| 6718 | " vec4 gl_Position;\n" |
| 6719 | "};\n" |
| 6720 | "void main(){\n" |
| 6721 | " gl_Position = vec4(x);\n" |
| 6722 | "}\n"; |
| 6723 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6724 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 6725 | "\n" |
| 6726 | "layout(location=0) out vec4 color;\n" |
| 6727 | "void main(){\n" |
| 6728 | " color = vec4(1);\n" |
| 6729 | "}\n"; |
| 6730 | |
| 6731 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6732 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6733 | |
| 6734 | VkPipelineObj pipe(m_device); |
| 6735 | pipe.AddColorAttachment(); |
| 6736 | pipe.AddShader(&vs); |
| 6737 | pipe.AddShader(&fs); |
| 6738 | |
| 6739 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 6740 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 6741 | |
| 6742 | VkDescriptorSetObj descriptorSet(m_device); |
| 6743 | descriptorSet.AppendDummy(); |
| 6744 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6745 | |
| 6746 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6747 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6748 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 6749 | } |
| 6750 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6751 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 6752 | m_errorMonitor->SetDesiredFailureMsg( |
| 6753 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6754 | "VS consumes input at location 0 but not provided"); |
| 6755 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6756 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6757 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6758 | |
| 6759 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6760 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6761 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6762 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6763 | "out gl_PerVertex {\n" |
| 6764 | " vec4 gl_Position;\n" |
| 6765 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6766 | "void main(){\n" |
| 6767 | " gl_Position = x;\n" |
| 6768 | "}\n"; |
| 6769 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6770 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6771 | "\n" |
| 6772 | "layout(location=0) out vec4 color;\n" |
| 6773 | "void main(){\n" |
| 6774 | " color = vec4(1);\n" |
| 6775 | "}\n"; |
| 6776 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6777 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6778 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6779 | |
| 6780 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6781 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6782 | pipe.AddShader(&vs); |
| 6783 | pipe.AddShader(&fs); |
| 6784 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6785 | VkDescriptorSetObj descriptorSet(m_device); |
| 6786 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6787 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6788 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6789 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6790 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6791 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 6792 | } |
| 6793 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6794 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 6795 | m_errorMonitor->SetDesiredFailureMsg( |
| 6796 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6797 | "location 0 does not match VS input type"); |
| 6798 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6799 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6800 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6801 | |
| 6802 | VkVertexInputBindingDescription input_binding; |
| 6803 | memset(&input_binding, 0, sizeof(input_binding)); |
| 6804 | |
| 6805 | VkVertexInputAttributeDescription input_attrib; |
| 6806 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 6807 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 6808 | |
| 6809 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6810 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6811 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6812 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6813 | "out gl_PerVertex {\n" |
| 6814 | " vec4 gl_Position;\n" |
| 6815 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6816 | "void main(){\n" |
| 6817 | " gl_Position = vec4(x);\n" |
| 6818 | "}\n"; |
| 6819 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6820 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6821 | "\n" |
| 6822 | "layout(location=0) out vec4 color;\n" |
| 6823 | "void main(){\n" |
| 6824 | " color = vec4(1);\n" |
| 6825 | "}\n"; |
| 6826 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6827 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6828 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6829 | |
| 6830 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6831 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6832 | pipe.AddShader(&vs); |
| 6833 | pipe.AddShader(&fs); |
| 6834 | |
| 6835 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 6836 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 6837 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6838 | VkDescriptorSetObj descriptorSet(m_device); |
| 6839 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6840 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6841 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6842 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6843 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6844 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 6845 | } |
| 6846 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 6847 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 6848 | m_errorMonitor->SetDesiredFailureMsg( |
| 6849 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6850 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 6851 | |
| 6852 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6853 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6854 | |
| 6855 | char const *vsSource = |
| 6856 | "#version 450\n" |
| 6857 | "\n" |
| 6858 | "out gl_PerVertex {\n" |
| 6859 | " vec4 gl_Position;\n" |
| 6860 | "};\n" |
| 6861 | "void main(){\n" |
| 6862 | " gl_Position = vec4(1);\n" |
| 6863 | "}\n"; |
| 6864 | char const *fsSource = |
| 6865 | "#version 450\n" |
| 6866 | "\n" |
| 6867 | "layout(location=0) out vec4 color;\n" |
| 6868 | "void main(){\n" |
| 6869 | " color = vec4(1);\n" |
| 6870 | "}\n"; |
| 6871 | |
| 6872 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6873 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6874 | |
| 6875 | VkPipelineObj pipe(m_device); |
| 6876 | pipe.AddColorAttachment(); |
| 6877 | pipe.AddShader(&vs); |
| 6878 | pipe.AddShader(&vs); |
| 6879 | pipe.AddShader(&fs); |
| 6880 | |
| 6881 | VkDescriptorSetObj descriptorSet(m_device); |
| 6882 | descriptorSet.AppendDummy(); |
| 6883 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6884 | |
| 6885 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6886 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6887 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 6888 | } |
| 6889 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6890 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6891 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 6892 | |
| 6893 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6894 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6895 | |
| 6896 | VkVertexInputBindingDescription input_binding; |
| 6897 | memset(&input_binding, 0, sizeof(input_binding)); |
| 6898 | |
| 6899 | VkVertexInputAttributeDescription input_attribs[2]; |
| 6900 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 6901 | |
| 6902 | for (int i = 0; i < 2; i++) { |
| 6903 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 6904 | input_attribs[i].location = i; |
| 6905 | } |
| 6906 | |
| 6907 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6908 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 6909 | "\n" |
| 6910 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6911 | "out gl_PerVertex {\n" |
| 6912 | " vec4 gl_Position;\n" |
| 6913 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 6914 | "void main(){\n" |
| 6915 | " gl_Position = x[0] + x[1];\n" |
| 6916 | "}\n"; |
| 6917 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6918 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 6919 | "\n" |
| 6920 | "layout(location=0) out vec4 color;\n" |
| 6921 | "void main(){\n" |
| 6922 | " color = vec4(1);\n" |
| 6923 | "}\n"; |
| 6924 | |
| 6925 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6926 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6927 | |
| 6928 | VkPipelineObj pipe(m_device); |
| 6929 | pipe.AddColorAttachment(); |
| 6930 | pipe.AddShader(&vs); |
| 6931 | pipe.AddShader(&fs); |
| 6932 | |
| 6933 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 6934 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 6935 | |
| 6936 | VkDescriptorSetObj descriptorSet(m_device); |
| 6937 | descriptorSet.AppendDummy(); |
| 6938 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6939 | |
| 6940 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6941 | |
| 6942 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6943 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 6944 | } |
| 6945 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 6946 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 6947 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6948 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 6949 | |
| 6950 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6951 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6952 | |
| 6953 | VkVertexInputBindingDescription input_binding; |
| 6954 | memset(&input_binding, 0, sizeof(input_binding)); |
| 6955 | |
| 6956 | VkVertexInputAttributeDescription input_attribs[2]; |
| 6957 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 6958 | |
| 6959 | for (int i = 0; i < 2; i++) { |
| 6960 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 6961 | input_attribs[i].location = i; |
| 6962 | } |
| 6963 | |
| 6964 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6965 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 6966 | "\n" |
| 6967 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6968 | "out gl_PerVertex {\n" |
| 6969 | " vec4 gl_Position;\n" |
| 6970 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 6971 | "void main(){\n" |
| 6972 | " gl_Position = x[0] + x[1];\n" |
| 6973 | "}\n"; |
| 6974 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6975 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 6976 | "\n" |
| 6977 | "layout(location=0) out vec4 color;\n" |
| 6978 | "void main(){\n" |
| 6979 | " color = vec4(1);\n" |
| 6980 | "}\n"; |
| 6981 | |
| 6982 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6983 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 6984 | |
| 6985 | VkPipelineObj pipe(m_device); |
| 6986 | pipe.AddColorAttachment(); |
| 6987 | pipe.AddShader(&vs); |
| 6988 | pipe.AddShader(&fs); |
| 6989 | |
| 6990 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 6991 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 6992 | |
| 6993 | VkDescriptorSetObj descriptorSet(m_device); |
| 6994 | descriptorSet.AppendDummy(); |
| 6995 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 6996 | |
| 6997 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 6998 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6999 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7000 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7001 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7002 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 7003 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7004 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7005 | |
| 7006 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7007 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7008 | |
| 7009 | char const *vsSource = |
| 7010 | "#version 450\n" |
| 7011 | "out gl_PerVertex {\n" |
| 7012 | " vec4 gl_Position;\n" |
| 7013 | "};\n" |
| 7014 | "void main(){\n" |
| 7015 | " gl_Position = vec4(0);\n" |
| 7016 | "}\n"; |
| 7017 | char const *fsSource = |
| 7018 | "#version 450\n" |
| 7019 | "\n" |
| 7020 | "layout(location=0) out vec4 color;\n" |
| 7021 | "void main(){\n" |
| 7022 | " color = vec4(1);\n" |
| 7023 | "}\n"; |
| 7024 | |
| 7025 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7026 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7027 | |
| 7028 | VkPipelineObj pipe(m_device); |
| 7029 | pipe.AddColorAttachment(); |
| 7030 | pipe.AddShader(&vs); |
| 7031 | pipe.AddShader(&fs); |
| 7032 | |
| 7033 | VkDescriptorSetObj descriptorSet(m_device); |
| 7034 | descriptorSet.AppendDummy(); |
| 7035 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7036 | |
| 7037 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7038 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7039 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7040 | } |
| 7041 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7042 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 7043 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7044 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7045 | |
| 7046 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 7047 | |
| 7048 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7049 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7050 | |
| 7051 | char const *vsSource = |
| 7052 | "#version 450\n" |
| 7053 | "out gl_PerVertex {\n" |
| 7054 | " vec4 gl_Position;\n" |
| 7055 | "};\n" |
| 7056 | "layout(location=0) out vec3 x;\n" |
| 7057 | "layout(location=1) out ivec3 y;\n" |
| 7058 | "layout(location=2) out vec3 z;\n" |
| 7059 | "void main(){\n" |
| 7060 | " gl_Position = vec4(0);\n" |
| 7061 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 7062 | "}\n"; |
| 7063 | char const *fsSource = |
| 7064 | "#version 450\n" |
| 7065 | "\n" |
| 7066 | "layout(location=0) out vec4 color;\n" |
| 7067 | "layout(location=0) in float x;\n" |
| 7068 | "layout(location=1) flat in int y;\n" |
| 7069 | "layout(location=2) in vec2 z;\n" |
| 7070 | "void main(){\n" |
| 7071 | " color = vec4(1 + x + y + z.x);\n" |
| 7072 | "}\n"; |
| 7073 | |
| 7074 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7075 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7076 | |
| 7077 | VkPipelineObj pipe(m_device); |
| 7078 | pipe.AddColorAttachment(); |
| 7079 | pipe.AddShader(&vs); |
| 7080 | pipe.AddShader(&fs); |
| 7081 | |
| 7082 | VkDescriptorSetObj descriptorSet(m_device); |
| 7083 | descriptorSet.AppendDummy(); |
| 7084 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7085 | |
| 7086 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7087 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7088 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7089 | } |
| 7090 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7091 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 7092 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7093 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7094 | |
| 7095 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7096 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7097 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7098 | if (!m_device->phy().features().tessellationShader) { |
| 7099 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7100 | return; |
| 7101 | } |
| 7102 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7103 | char const *vsSource = |
| 7104 | "#version 450\n" |
| 7105 | "void main(){}\n"; |
| 7106 | char const *tcsSource = |
| 7107 | "#version 450\n" |
| 7108 | "layout(location=0) out int x[];\n" |
| 7109 | "layout(vertices=3) out;\n" |
| 7110 | "void main(){\n" |
| 7111 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7112 | " gl_TessLevelInner[0] = 1;\n" |
| 7113 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7114 | "}\n"; |
| 7115 | char const *tesSource = |
| 7116 | "#version 450\n" |
| 7117 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7118 | "layout(location=0) in int x[];\n" |
| 7119 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7120 | "void main(){\n" |
| 7121 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7122 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 7123 | "}\n"; |
| 7124 | char const *fsSource = |
| 7125 | "#version 450\n" |
| 7126 | "layout(location=0) out vec4 color;\n" |
| 7127 | "void main(){\n" |
| 7128 | " color = vec4(1);\n" |
| 7129 | "}\n"; |
| 7130 | |
| 7131 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7132 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7133 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7134 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7135 | |
| 7136 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7137 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7138 | nullptr, |
| 7139 | 0, |
| 7140 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7141 | VK_FALSE}; |
| 7142 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7143 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7144 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7145 | nullptr, |
| 7146 | 0, |
| 7147 | 3}; |
| 7148 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7149 | VkPipelineObj pipe(m_device); |
| 7150 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7151 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7152 | pipe.AddColorAttachment(); |
| 7153 | pipe.AddShader(&vs); |
| 7154 | pipe.AddShader(&tcs); |
| 7155 | pipe.AddShader(&tes); |
| 7156 | pipe.AddShader(&fs); |
| 7157 | |
| 7158 | VkDescriptorSetObj descriptorSet(m_device); |
| 7159 | descriptorSet.AppendDummy(); |
| 7160 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7161 | |
| 7162 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7163 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7164 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7165 | } |
| 7166 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 7167 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 7168 | { |
| 7169 | m_errorMonitor->ExpectSuccess(); |
| 7170 | |
| 7171 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7172 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7173 | |
| 7174 | if (!m_device->phy().features().geometryShader) { |
| 7175 | printf("Device does not support geometry shaders; skipped.\n"); |
| 7176 | return; |
| 7177 | } |
| 7178 | |
| 7179 | char const *vsSource = |
| 7180 | "#version 450\n" |
| 7181 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 7182 | "void main(){\n" |
| 7183 | " vs_out.x = vec4(1);\n" |
| 7184 | "}\n"; |
| 7185 | char const *gsSource = |
| 7186 | "#version 450\n" |
| 7187 | "layout(triangles) in;\n" |
| 7188 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 7189 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 7190 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7191 | "void main() {\n" |
| 7192 | " gl_Position = gs_in[0].x;\n" |
| 7193 | " EmitVertex();\n" |
| 7194 | "}\n"; |
| 7195 | char const *fsSource = |
| 7196 | "#version 450\n" |
| 7197 | "layout(location=0) out vec4 color;\n" |
| 7198 | "void main(){\n" |
| 7199 | " color = vec4(1);\n" |
| 7200 | "}\n"; |
| 7201 | |
| 7202 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7203 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 7204 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7205 | |
| 7206 | VkPipelineObj pipe(m_device); |
| 7207 | pipe.AddColorAttachment(); |
| 7208 | pipe.AddShader(&vs); |
| 7209 | pipe.AddShader(&gs); |
| 7210 | pipe.AddShader(&fs); |
| 7211 | |
| 7212 | VkDescriptorSetObj descriptorSet(m_device); |
| 7213 | descriptorSet.AppendDummy(); |
| 7214 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7215 | |
| 7216 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7217 | |
| 7218 | m_errorMonitor->VerifyNotFound(); |
| 7219 | } |
| 7220 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7221 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 7222 | { |
| 7223 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7224 | "is per-vertex in tessellation control shader stage " |
| 7225 | "but per-patch in tessellation evaluation shader stage"); |
| 7226 | |
| 7227 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7228 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7229 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7230 | if (!m_device->phy().features().tessellationShader) { |
| 7231 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7232 | return; |
| 7233 | } |
| 7234 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7235 | char const *vsSource = |
| 7236 | "#version 450\n" |
| 7237 | "void main(){}\n"; |
| 7238 | char const *tcsSource = |
| 7239 | "#version 450\n" |
| 7240 | "layout(location=0) out int x[];\n" |
| 7241 | "layout(vertices=3) out;\n" |
| 7242 | "void main(){\n" |
| 7243 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7244 | " gl_TessLevelInner[0] = 1;\n" |
| 7245 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7246 | "}\n"; |
| 7247 | char const *tesSource = |
| 7248 | "#version 450\n" |
| 7249 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7250 | "layout(location=0) patch in int x;\n" |
| 7251 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7252 | "void main(){\n" |
| 7253 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7254 | " gl_Position.w = x;\n" |
| 7255 | "}\n"; |
| 7256 | char const *fsSource = |
| 7257 | "#version 450\n" |
| 7258 | "layout(location=0) out vec4 color;\n" |
| 7259 | "void main(){\n" |
| 7260 | " color = vec4(1);\n" |
| 7261 | "}\n"; |
| 7262 | |
| 7263 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7264 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7265 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7266 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7267 | |
| 7268 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7269 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7270 | nullptr, |
| 7271 | 0, |
| 7272 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7273 | VK_FALSE}; |
| 7274 | |
| 7275 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7276 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7277 | nullptr, |
| 7278 | 0, |
| 7279 | 3}; |
| 7280 | |
| 7281 | VkPipelineObj pipe(m_device); |
| 7282 | pipe.SetInputAssembly(&iasci); |
| 7283 | pipe.SetTessellation(&tsci); |
| 7284 | pipe.AddColorAttachment(); |
| 7285 | pipe.AddShader(&vs); |
| 7286 | pipe.AddShader(&tcs); |
| 7287 | pipe.AddShader(&tes); |
| 7288 | pipe.AddShader(&fs); |
| 7289 | |
| 7290 | VkDescriptorSetObj descriptorSet(m_device); |
| 7291 | descriptorSet.AppendDummy(); |
| 7292 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7293 | |
| 7294 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7295 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7296 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7297 | } |
| 7298 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7299 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 7300 | m_errorMonitor->SetDesiredFailureMsg( |
| 7301 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7302 | "Duplicate vertex input binding descriptions for binding 0"); |
| 7303 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7304 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7305 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7306 | |
| 7307 | /* Two binding descriptions for binding 0 */ |
| 7308 | VkVertexInputBindingDescription input_bindings[2]; |
| 7309 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7310 | |
| 7311 | VkVertexInputAttributeDescription input_attrib; |
| 7312 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7313 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7314 | |
| 7315 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7316 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7317 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7318 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7319 | "out gl_PerVertex {\n" |
| 7320 | " vec4 gl_Position;\n" |
| 7321 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7322 | "void main(){\n" |
| 7323 | " gl_Position = vec4(x);\n" |
| 7324 | "}\n"; |
| 7325 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7326 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7327 | "\n" |
| 7328 | "layout(location=0) out vec4 color;\n" |
| 7329 | "void main(){\n" |
| 7330 | " color = vec4(1);\n" |
| 7331 | "}\n"; |
| 7332 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7333 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7334 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7335 | |
| 7336 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7337 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7338 | pipe.AddShader(&vs); |
| 7339 | pipe.AddShader(&fs); |
| 7340 | |
| 7341 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 7342 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7343 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7344 | VkDescriptorSetObj descriptorSet(m_device); |
| 7345 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7346 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7347 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7348 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7349 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7350 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7351 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 7352 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 7353 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 7354 | m_errorMonitor->ExpectSuccess(); |
| 7355 | |
| 7356 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7357 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7358 | |
| 7359 | if (!m_device->phy().features().tessellationShader) { |
| 7360 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 7361 | return; |
| 7362 | } |
| 7363 | |
| 7364 | VkVertexInputBindingDescription input_bindings[1]; |
| 7365 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7366 | |
| 7367 | VkVertexInputAttributeDescription input_attribs[4]; |
| 7368 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7369 | input_attribs[0].location = 0; |
| 7370 | input_attribs[0].offset = 0; |
| 7371 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7372 | input_attribs[1].location = 2; |
| 7373 | input_attribs[1].offset = 32; |
| 7374 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7375 | input_attribs[2].location = 4; |
| 7376 | input_attribs[2].offset = 64; |
| 7377 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7378 | input_attribs[3].location = 6; |
| 7379 | input_attribs[3].offset = 96; |
| 7380 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7381 | |
| 7382 | char const *vsSource = |
| 7383 | "#version 450\n" |
| 7384 | "\n" |
| 7385 | "layout(location=0) in dmat4 x;\n" |
| 7386 | "out gl_PerVertex {\n" |
| 7387 | " vec4 gl_Position;\n" |
| 7388 | "};\n" |
| 7389 | "void main(){\n" |
| 7390 | " gl_Position = vec4(x[0][0]);\n" |
| 7391 | "}\n"; |
| 7392 | char const *fsSource = |
| 7393 | "#version 450\n" |
| 7394 | "\n" |
| 7395 | "layout(location=0) out vec4 color;\n" |
| 7396 | "void main(){\n" |
| 7397 | " color = vec4(1);\n" |
| 7398 | "}\n"; |
| 7399 | |
| 7400 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7401 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7402 | |
| 7403 | VkPipelineObj pipe(m_device); |
| 7404 | pipe.AddColorAttachment(); |
| 7405 | pipe.AddShader(&vs); |
| 7406 | pipe.AddShader(&fs); |
| 7407 | |
| 7408 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 7409 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 7410 | |
| 7411 | VkDescriptorSetObj descriptorSet(m_device); |
| 7412 | descriptorSet.AppendDummy(); |
| 7413 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7414 | |
| 7415 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7416 | |
| 7417 | m_errorMonitor->VerifyNotFound(); |
| 7418 | } |
| 7419 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7420 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7421 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7422 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7423 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7424 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7425 | |
| 7426 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7427 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7428 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7429 | "out gl_PerVertex {\n" |
| 7430 | " vec4 gl_Position;\n" |
| 7431 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7432 | "void main(){\n" |
| 7433 | " gl_Position = vec4(1);\n" |
| 7434 | "}\n"; |
| 7435 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7436 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7437 | "\n" |
| 7438 | "void main(){\n" |
| 7439 | "}\n"; |
| 7440 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7441 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7442 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7443 | |
| 7444 | VkPipelineObj pipe(m_device); |
| 7445 | pipe.AddShader(&vs); |
| 7446 | pipe.AddShader(&fs); |
| 7447 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7448 | /* set up CB 0, not written */ |
| 7449 | pipe.AddColorAttachment(); |
| 7450 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7451 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7452 | VkDescriptorSetObj descriptorSet(m_device); |
| 7453 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7454 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7455 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7456 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7457 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7458 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 7459 | } |
| 7460 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7461 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7462 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7463 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7464 | "FS writes to output location 1 with no matching attachment"); |
| 7465 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7466 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7467 | |
| 7468 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7469 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7470 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7471 | "out gl_PerVertex {\n" |
| 7472 | " vec4 gl_Position;\n" |
| 7473 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7474 | "void main(){\n" |
| 7475 | " gl_Position = vec4(1);\n" |
| 7476 | "}\n"; |
| 7477 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7478 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7479 | "\n" |
| 7480 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7481 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7482 | "void main(){\n" |
| 7483 | " x = vec4(1);\n" |
| 7484 | " y = vec4(1);\n" |
| 7485 | "}\n"; |
| 7486 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7487 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7488 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7489 | |
| 7490 | VkPipelineObj pipe(m_device); |
| 7491 | pipe.AddShader(&vs); |
| 7492 | pipe.AddShader(&fs); |
| 7493 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7494 | /* set up CB 0, not written */ |
| 7495 | pipe.AddColorAttachment(); |
| 7496 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7497 | /* FS writes CB 1, but we don't configure it */ |
| 7498 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7499 | VkDescriptorSetObj descriptorSet(m_device); |
| 7500 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7501 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7502 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7503 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7504 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7505 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 7506 | } |
| 7507 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7508 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7509 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7510 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7511 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7512 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7513 | |
| 7514 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7515 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7516 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7517 | "out gl_PerVertex {\n" |
| 7518 | " vec4 gl_Position;\n" |
| 7519 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7520 | "void main(){\n" |
| 7521 | " gl_Position = vec4(1);\n" |
| 7522 | "}\n"; |
| 7523 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7524 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7525 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7526 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7527 | "void main(){\n" |
| 7528 | " x = ivec4(1);\n" |
| 7529 | "}\n"; |
| 7530 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7531 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7532 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7533 | |
| 7534 | VkPipelineObj pipe(m_device); |
| 7535 | pipe.AddShader(&vs); |
| 7536 | pipe.AddShader(&fs); |
| 7537 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7538 | /* set up CB 0; type is UNORM by default */ |
| 7539 | pipe.AddColorAttachment(); |
| 7540 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7541 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7542 | VkDescriptorSetObj descriptorSet(m_device); |
| 7543 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7544 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7545 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7546 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7547 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7548 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7549 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 7550 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7551 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7552 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7553 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7554 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7555 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7556 | |
| 7557 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7558 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7559 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7560 | "out gl_PerVertex {\n" |
| 7561 | " vec4 gl_Position;\n" |
| 7562 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7563 | "void main(){\n" |
| 7564 | " gl_Position = vec4(1);\n" |
| 7565 | "}\n"; |
| 7566 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7567 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7568 | "\n" |
| 7569 | "layout(location=0) out vec4 x;\n" |
| 7570 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 7571 | "void main(){\n" |
| 7572 | " x = vec4(bar.y);\n" |
| 7573 | "}\n"; |
| 7574 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7575 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7576 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7577 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7578 | VkPipelineObj pipe(m_device); |
| 7579 | pipe.AddShader(&vs); |
| 7580 | pipe.AddShader(&fs); |
| 7581 | |
| 7582 | /* set up CB 0; type is UNORM by default */ |
| 7583 | pipe.AddColorAttachment(); |
| 7584 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7585 | |
| 7586 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7587 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7588 | |
| 7589 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7590 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7591 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 7592 | } |
| 7593 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7594 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 7595 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7596 | "not declared in layout"); |
| 7597 | |
| 7598 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7599 | |
| 7600 | char const *vsSource = |
| 7601 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7602 | "\n" |
| 7603 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 7604 | "out gl_PerVertex {\n" |
| 7605 | " vec4 gl_Position;\n" |
| 7606 | "};\n" |
| 7607 | "void main(){\n" |
| 7608 | " gl_Position = vec4(consts.x);\n" |
| 7609 | "}\n"; |
| 7610 | char const *fsSource = |
| 7611 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7612 | "\n" |
| 7613 | "layout(location=0) out vec4 x;\n" |
| 7614 | "void main(){\n" |
| 7615 | " x = vec4(1);\n" |
| 7616 | "}\n"; |
| 7617 | |
| 7618 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7619 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7620 | |
| 7621 | VkPipelineObj pipe(m_device); |
| 7622 | pipe.AddShader(&vs); |
| 7623 | pipe.AddShader(&fs); |
| 7624 | |
| 7625 | /* set up CB 0; type is UNORM by default */ |
| 7626 | pipe.AddColorAttachment(); |
| 7627 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7628 | |
| 7629 | VkDescriptorSetObj descriptorSet(m_device); |
| 7630 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7631 | |
| 7632 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7633 | |
| 7634 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7635 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 7636 | } |
| 7637 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7638 | #endif // SHADER_CHECKER_TESTS |
| 7639 | |
| 7640 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 7641 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7642 | m_errorMonitor->SetDesiredFailureMsg( |
| 7643 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7644 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7645 | |
| 7646 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7647 | |
| 7648 | // Create an image |
| 7649 | VkImage image; |
| 7650 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7651 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7652 | const int32_t tex_width = 32; |
| 7653 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7654 | |
| 7655 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7656 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7657 | image_create_info.pNext = NULL; |
| 7658 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7659 | image_create_info.format = tex_format; |
| 7660 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7661 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7662 | image_create_info.extent.depth = 1; |
| 7663 | image_create_info.mipLevels = 1; |
| 7664 | image_create_info.arrayLayers = 1; |
| 7665 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7666 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7667 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 7668 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7669 | |
| 7670 | // Introduce error by sending down a bogus width extent |
| 7671 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7672 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7673 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7674 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 7675 | } |
| 7676 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 7677 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 7678 | m_errorMonitor->SetDesiredFailureMsg( |
| 7679 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7680 | "CreateImage extents is 0 for at least one required dimension"); |
| 7681 | |
| 7682 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7683 | |
| 7684 | // Create an image |
| 7685 | VkImage image; |
| 7686 | |
| 7687 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7688 | const int32_t tex_width = 32; |
| 7689 | const int32_t tex_height = 32; |
| 7690 | |
| 7691 | VkImageCreateInfo image_create_info = {}; |
| 7692 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7693 | image_create_info.pNext = NULL; |
| 7694 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7695 | image_create_info.format = tex_format; |
| 7696 | image_create_info.extent.width = tex_width; |
| 7697 | image_create_info.extent.height = tex_height; |
| 7698 | image_create_info.extent.depth = 1; |
| 7699 | image_create_info.mipLevels = 1; |
| 7700 | image_create_info.arrayLayers = 1; |
| 7701 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7702 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7703 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 7704 | image_create_info.flags = 0; |
| 7705 | |
| 7706 | // Introduce error by sending down a bogus width extent |
| 7707 | image_create_info.extent.width = 0; |
| 7708 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 7709 | |
| 7710 | m_errorMonitor->VerifyFound(); |
| 7711 | } |
| 7712 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7713 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 7714 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7715 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7716 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7717 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7718 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7719 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7720 | |
| 7721 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 7722 | vk_testing::Buffer buffer; |
| 7723 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 7724 | |
| 7725 | BeginCommandBuffer(); |
| 7726 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7727 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7728 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7729 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7730 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7731 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7732 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7733 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7734 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7735 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7736 | EndCommandBuffer(); |
| 7737 | } |
| 7738 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7739 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7740 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7741 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7742 | |
| 7743 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7744 | |
| 7745 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 7746 | vk_testing::Buffer buffer; |
| 7747 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 7748 | |
| 7749 | BeginCommandBuffer(); |
| 7750 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7751 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7752 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7753 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7754 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7755 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7756 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7757 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7758 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7759 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7760 | m_errorMonitor->VerifyFound(); |
| 7761 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7762 | EndCommandBuffer(); |
| 7763 | } |
| 7764 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7765 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 7766 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7767 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7768 | TEST_F(VkLayerTest, InvalidImageView) { |
| 7769 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7770 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7771 | m_errorMonitor->SetDesiredFailureMsg( |
| 7772 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7773 | "vkCreateImageView called with baseMipLevel 10 "); |
| 7774 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7775 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7776 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7777 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7778 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7779 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7780 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7781 | const int32_t tex_width = 32; |
| 7782 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7783 | |
| 7784 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7785 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7786 | image_create_info.pNext = NULL; |
| 7787 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7788 | image_create_info.format = tex_format; |
| 7789 | image_create_info.extent.width = tex_width; |
| 7790 | image_create_info.extent.height = tex_height; |
| 7791 | image_create_info.extent.depth = 1; |
| 7792 | image_create_info.mipLevels = 1; |
| 7793 | image_create_info.arrayLayers = 1; |
| 7794 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7795 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7796 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 7797 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7798 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7799 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7800 | ASSERT_VK_SUCCESS(err); |
| 7801 | |
| 7802 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7803 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7804 | image_view_create_info.image = image; |
| 7805 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7806 | image_view_create_info.format = tex_format; |
| 7807 | image_view_create_info.subresourceRange.layerCount = 1; |
| 7808 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 7809 | image_view_create_info.subresourceRange.levelCount = 1; |
| 7810 | image_view_create_info.subresourceRange.aspectMask = |
| 7811 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7812 | |
| 7813 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7814 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 7815 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7816 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7817 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 7818 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7820 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 7821 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7822 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7823 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7824 | "vkCreateImageView: Color image " |
| 7825 | "formats must have ONLY the " |
| 7826 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7827 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7828 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7829 | |
| 7830 | // 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] | 7831 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7832 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7833 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7834 | const int32_t tex_width = 32; |
| 7835 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7836 | |
| 7837 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7838 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7839 | image_create_info.pNext = NULL; |
| 7840 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7841 | image_create_info.format = tex_format; |
| 7842 | image_create_info.extent.width = tex_width; |
| 7843 | image_create_info.extent.height = tex_height; |
| 7844 | image_create_info.extent.depth = 1; |
| 7845 | image_create_info.mipLevels = 1; |
| 7846 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7847 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 7848 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 7849 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7850 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7851 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7852 | ASSERT_VK_SUCCESS(err); |
| 7853 | |
| 7854 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7855 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7856 | image_view_create_info.image = image; |
| 7857 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 7858 | image_view_create_info.format = tex_format; |
| 7859 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 7860 | image_view_create_info.subresourceRange.levelCount = 1; |
| 7861 | // Cause an error by setting an invalid image aspect |
| 7862 | image_view_create_info.subresourceRange.aspectMask = |
| 7863 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7864 | |
| 7865 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7866 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 7867 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7868 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7869 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 7870 | } |
| 7871 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 7872 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7873 | VkResult err; |
| 7874 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7875 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7876 | m_errorMonitor->SetDesiredFailureMsg( |
| 7877 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 7878 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7879 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7880 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7881 | |
| 7882 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7883 | VkImage srcImage; |
| 7884 | VkImage dstImage; |
| 7885 | VkDeviceMemory srcMem; |
| 7886 | VkDeviceMemory destMem; |
| 7887 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7888 | |
| 7889 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7890 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7891 | image_create_info.pNext = NULL; |
| 7892 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7893 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7894 | image_create_info.extent.width = 32; |
| 7895 | image_create_info.extent.height = 32; |
| 7896 | image_create_info.extent.depth = 1; |
| 7897 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 7898 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7899 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7900 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7901 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 7902 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7903 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7904 | err = |
| 7905 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7906 | ASSERT_VK_SUCCESS(err); |
| 7907 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7908 | err = |
| 7909 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7910 | ASSERT_VK_SUCCESS(err); |
| 7911 | |
| 7912 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7913 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7914 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 7915 | memAlloc.pNext = NULL; |
| 7916 | memAlloc.allocationSize = 0; |
| 7917 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7918 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 7919 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7920 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7921 | pass = |
| 7922 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 7923 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7924 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7925 | ASSERT_VK_SUCCESS(err); |
| 7926 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7927 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7928 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7929 | pass = |
| 7930 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7931 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7932 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7933 | ASSERT_VK_SUCCESS(err); |
| 7934 | |
| 7935 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 7936 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7937 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7938 | ASSERT_VK_SUCCESS(err); |
| 7939 | |
| 7940 | BeginCommandBuffer(); |
| 7941 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 7942 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7943 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 7944 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 7945 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7946 | copyRegion.srcOffset.x = 0; |
| 7947 | copyRegion.srcOffset.y = 0; |
| 7948 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 7949 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7950 | copyRegion.dstSubresource.mipLevel = 0; |
| 7951 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 7952 | // Introduce failure by forcing the dst layerCount to differ from src |
| 7953 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7954 | copyRegion.dstOffset.x = 0; |
| 7955 | copyRegion.dstOffset.y = 0; |
| 7956 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7957 | copyRegion.extent.width = 1; |
| 7958 | copyRegion.extent.height = 1; |
| 7959 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7960 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 7961 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7962 | EndCommandBuffer(); |
| 7963 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7964 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7965 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7966 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7967 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7968 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 7969 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 7970 | } |
| 7971 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7972 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7973 | VkResult err; |
| 7974 | bool pass; |
| 7975 | |
| 7976 | // Create color images with different format sizes and try to copy between them |
| 7977 | m_errorMonitor->SetDesiredFailureMsg( |
| 7978 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7979 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 7980 | |
| 7981 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7982 | |
| 7983 | // Create two images of different types and try to copy between them |
| 7984 | VkImage srcImage; |
| 7985 | VkImage dstImage; |
| 7986 | VkDeviceMemory srcMem; |
| 7987 | VkDeviceMemory destMem; |
| 7988 | VkMemoryRequirements memReqs; |
| 7989 | |
| 7990 | VkImageCreateInfo image_create_info = {}; |
| 7991 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7992 | image_create_info.pNext = NULL; |
| 7993 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7994 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7995 | image_create_info.extent.width = 32; |
| 7996 | image_create_info.extent.height = 32; |
| 7997 | image_create_info.extent.depth = 1; |
| 7998 | image_create_info.mipLevels = 1; |
| 7999 | image_create_info.arrayLayers = 1; |
| 8000 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8001 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8002 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8003 | image_create_info.flags = 0; |
| 8004 | |
| 8005 | err = |
| 8006 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 8007 | ASSERT_VK_SUCCESS(err); |
| 8008 | |
| 8009 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 8010 | // Introduce failure by creating second image with a different-sized format. |
| 8011 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 8012 | |
| 8013 | err = |
| 8014 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 8015 | ASSERT_VK_SUCCESS(err); |
| 8016 | |
| 8017 | // Allocate memory |
| 8018 | VkMemoryAllocateInfo memAlloc = {}; |
| 8019 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8020 | memAlloc.pNext = NULL; |
| 8021 | memAlloc.allocationSize = 0; |
| 8022 | memAlloc.memoryTypeIndex = 0; |
| 8023 | |
| 8024 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 8025 | memAlloc.allocationSize = memReqs.size; |
| 8026 | pass = |
| 8027 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 8028 | ASSERT_TRUE(pass); |
| 8029 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 8030 | ASSERT_VK_SUCCESS(err); |
| 8031 | |
| 8032 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 8033 | memAlloc.allocationSize = memReqs.size; |
| 8034 | pass = |
| 8035 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 8036 | ASSERT_TRUE(pass); |
| 8037 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 8038 | ASSERT_VK_SUCCESS(err); |
| 8039 | |
| 8040 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8041 | ASSERT_VK_SUCCESS(err); |
| 8042 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 8043 | ASSERT_VK_SUCCESS(err); |
| 8044 | |
| 8045 | BeginCommandBuffer(); |
| 8046 | VkImageCopy copyRegion; |
| 8047 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8048 | copyRegion.srcSubresource.mipLevel = 0; |
| 8049 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8050 | copyRegion.srcSubresource.layerCount = 0; |
| 8051 | copyRegion.srcOffset.x = 0; |
| 8052 | copyRegion.srcOffset.y = 0; |
| 8053 | copyRegion.srcOffset.z = 0; |
| 8054 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8055 | copyRegion.dstSubresource.mipLevel = 0; |
| 8056 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8057 | copyRegion.dstSubresource.layerCount = 0; |
| 8058 | copyRegion.dstOffset.x = 0; |
| 8059 | copyRegion.dstOffset.y = 0; |
| 8060 | copyRegion.dstOffset.z = 0; |
| 8061 | copyRegion.extent.width = 1; |
| 8062 | copyRegion.extent.height = 1; |
| 8063 | copyRegion.extent.depth = 1; |
| 8064 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8065 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8066 | EndCommandBuffer(); |
| 8067 | |
| 8068 | m_errorMonitor->VerifyFound(); |
| 8069 | |
| 8070 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 8071 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 8072 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8073 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8074 | } |
| 8075 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8076 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 8077 | VkResult err; |
| 8078 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8079 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8080 | // 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] | 8081 | m_errorMonitor->SetDesiredFailureMsg( |
| 8082 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8083 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8084 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8085 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8086 | |
| 8087 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8088 | VkImage srcImage; |
| 8089 | VkImage dstImage; |
| 8090 | VkDeviceMemory srcMem; |
| 8091 | VkDeviceMemory destMem; |
| 8092 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8093 | |
| 8094 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8095 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8096 | image_create_info.pNext = NULL; |
| 8097 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8098 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8099 | image_create_info.extent.width = 32; |
| 8100 | image_create_info.extent.height = 32; |
| 8101 | image_create_info.extent.depth = 1; |
| 8102 | image_create_info.mipLevels = 1; |
| 8103 | image_create_info.arrayLayers = 1; |
| 8104 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8105 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8106 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8107 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8108 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8109 | err = |
| 8110 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8111 | ASSERT_VK_SUCCESS(err); |
| 8112 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8113 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 8114 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8115 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8116 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8117 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8118 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8119 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8120 | err = |
| 8121 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8122 | ASSERT_VK_SUCCESS(err); |
| 8123 | |
| 8124 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8125 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8126 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8127 | memAlloc.pNext = NULL; |
| 8128 | memAlloc.allocationSize = 0; |
| 8129 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8130 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8131 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8132 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8133 | pass = |
| 8134 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8135 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8136 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8137 | ASSERT_VK_SUCCESS(err); |
| 8138 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8139 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8140 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8141 | pass = |
| 8142 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8143 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8144 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8145 | ASSERT_VK_SUCCESS(err); |
| 8146 | |
| 8147 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8148 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8149 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8150 | ASSERT_VK_SUCCESS(err); |
| 8151 | |
| 8152 | BeginCommandBuffer(); |
| 8153 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8154 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8155 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8156 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8157 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8158 | copyRegion.srcOffset.x = 0; |
| 8159 | copyRegion.srcOffset.y = 0; |
| 8160 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8161 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8162 | copyRegion.dstSubresource.mipLevel = 0; |
| 8163 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8164 | copyRegion.dstSubresource.layerCount = 0; |
| 8165 | copyRegion.dstOffset.x = 0; |
| 8166 | copyRegion.dstOffset.y = 0; |
| 8167 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8168 | copyRegion.extent.width = 1; |
| 8169 | copyRegion.extent.height = 1; |
| 8170 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8171 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8172 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8173 | EndCommandBuffer(); |
| 8174 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8175 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8176 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8177 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8178 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8179 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8180 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8181 | } |
| 8182 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8183 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 8184 | VkResult err; |
| 8185 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8186 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8187 | m_errorMonitor->SetDesiredFailureMsg( |
| 8188 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8189 | "vkCmdResolveImage called with source sample count less than 2."); |
| 8190 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8191 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8192 | |
| 8193 | // 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] | 8194 | VkImage srcImage; |
| 8195 | VkImage dstImage; |
| 8196 | VkDeviceMemory srcMem; |
| 8197 | VkDeviceMemory destMem; |
| 8198 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8199 | |
| 8200 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8201 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8202 | image_create_info.pNext = NULL; |
| 8203 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8204 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8205 | image_create_info.extent.width = 32; |
| 8206 | image_create_info.extent.height = 1; |
| 8207 | image_create_info.extent.depth = 1; |
| 8208 | image_create_info.mipLevels = 1; |
| 8209 | image_create_info.arrayLayers = 1; |
| 8210 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8211 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8212 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8213 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8214 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8215 | err = |
| 8216 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8217 | ASSERT_VK_SUCCESS(err); |
| 8218 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8219 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8220 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8221 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8222 | err = |
| 8223 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8224 | ASSERT_VK_SUCCESS(err); |
| 8225 | |
| 8226 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8227 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8228 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8229 | memAlloc.pNext = NULL; |
| 8230 | memAlloc.allocationSize = 0; |
| 8231 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8232 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8233 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8234 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8235 | pass = |
| 8236 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8237 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8238 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8239 | ASSERT_VK_SUCCESS(err); |
| 8240 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8241 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8242 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8243 | pass = |
| 8244 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8245 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8246 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8247 | ASSERT_VK_SUCCESS(err); |
| 8248 | |
| 8249 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8250 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8251 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8252 | ASSERT_VK_SUCCESS(err); |
| 8253 | |
| 8254 | BeginCommandBuffer(); |
| 8255 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8256 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8257 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8258 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8259 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8260 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8261 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8262 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8263 | resolveRegion.srcOffset.x = 0; |
| 8264 | resolveRegion.srcOffset.y = 0; |
| 8265 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8266 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8267 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8268 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8269 | resolveRegion.dstSubresource.layerCount = 0; |
| 8270 | resolveRegion.dstOffset.x = 0; |
| 8271 | resolveRegion.dstOffset.y = 0; |
| 8272 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8273 | resolveRegion.extent.width = 1; |
| 8274 | resolveRegion.extent.height = 1; |
| 8275 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8276 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8277 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8278 | EndCommandBuffer(); |
| 8279 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8280 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8281 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8282 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8283 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8284 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8285 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8286 | } |
| 8287 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8288 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 8289 | VkResult err; |
| 8290 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8291 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8292 | m_errorMonitor->SetDesiredFailureMsg( |
| 8293 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8294 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 8295 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8296 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8297 | |
| 8298 | // 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] | 8299 | VkImage srcImage; |
| 8300 | VkImage dstImage; |
| 8301 | VkDeviceMemory srcMem; |
| 8302 | VkDeviceMemory destMem; |
| 8303 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8304 | |
| 8305 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8306 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8307 | image_create_info.pNext = NULL; |
| 8308 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8309 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8310 | image_create_info.extent.width = 32; |
| 8311 | image_create_info.extent.height = 1; |
| 8312 | image_create_info.extent.depth = 1; |
| 8313 | image_create_info.mipLevels = 1; |
| 8314 | image_create_info.arrayLayers = 1; |
| 8315 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8316 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8317 | // Note: Some implementations expect color attachment usage for any |
| 8318 | // multisample surface |
| 8319 | image_create_info.usage = |
| 8320 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8321 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8322 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8323 | err = |
| 8324 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8325 | ASSERT_VK_SUCCESS(err); |
| 8326 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8327 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8328 | // Note: Some implementations expect color attachment usage for any |
| 8329 | // multisample surface |
| 8330 | image_create_info.usage = |
| 8331 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8332 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8333 | err = |
| 8334 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8335 | ASSERT_VK_SUCCESS(err); |
| 8336 | |
| 8337 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8338 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8339 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8340 | memAlloc.pNext = NULL; |
| 8341 | memAlloc.allocationSize = 0; |
| 8342 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8343 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8344 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8345 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8346 | pass = |
| 8347 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8348 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8349 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8350 | ASSERT_VK_SUCCESS(err); |
| 8351 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8352 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8353 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8354 | pass = |
| 8355 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8356 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8357 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8358 | ASSERT_VK_SUCCESS(err); |
| 8359 | |
| 8360 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8361 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8362 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8363 | ASSERT_VK_SUCCESS(err); |
| 8364 | |
| 8365 | BeginCommandBuffer(); |
| 8366 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8367 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8368 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8369 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8370 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8371 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8372 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8373 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8374 | resolveRegion.srcOffset.x = 0; |
| 8375 | resolveRegion.srcOffset.y = 0; |
| 8376 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8377 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8378 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8379 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8380 | resolveRegion.dstSubresource.layerCount = 0; |
| 8381 | resolveRegion.dstOffset.x = 0; |
| 8382 | resolveRegion.dstOffset.y = 0; |
| 8383 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8384 | resolveRegion.extent.width = 1; |
| 8385 | resolveRegion.extent.height = 1; |
| 8386 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8387 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8388 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8389 | EndCommandBuffer(); |
| 8390 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8391 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8392 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8393 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8394 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8395 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8396 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8397 | } |
| 8398 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8399 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 8400 | VkResult err; |
| 8401 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8402 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8403 | m_errorMonitor->SetDesiredFailureMsg( |
| 8404 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8405 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 8406 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8407 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8408 | |
| 8409 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8410 | VkImage srcImage; |
| 8411 | VkImage dstImage; |
| 8412 | VkDeviceMemory srcMem; |
| 8413 | VkDeviceMemory destMem; |
| 8414 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8415 | |
| 8416 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8417 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8418 | image_create_info.pNext = NULL; |
| 8419 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8420 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8421 | image_create_info.extent.width = 32; |
| 8422 | image_create_info.extent.height = 1; |
| 8423 | image_create_info.extent.depth = 1; |
| 8424 | image_create_info.mipLevels = 1; |
| 8425 | image_create_info.arrayLayers = 1; |
| 8426 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8427 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8428 | // Note: Some implementations expect color attachment usage for any |
| 8429 | // multisample surface |
| 8430 | image_create_info.usage = |
| 8431 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8432 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8433 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8434 | err = |
| 8435 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8436 | ASSERT_VK_SUCCESS(err); |
| 8437 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8438 | // Set format to something other than source image |
| 8439 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 8440 | // Note: Some implementations expect color attachment usage for any |
| 8441 | // multisample surface |
| 8442 | image_create_info.usage = |
| 8443 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8444 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8445 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8446 | err = |
| 8447 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8448 | ASSERT_VK_SUCCESS(err); |
| 8449 | |
| 8450 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8451 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8452 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8453 | memAlloc.pNext = NULL; |
| 8454 | memAlloc.allocationSize = 0; |
| 8455 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8456 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8457 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8458 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8459 | pass = |
| 8460 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8461 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8462 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8463 | ASSERT_VK_SUCCESS(err); |
| 8464 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8465 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8466 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8467 | pass = |
| 8468 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8469 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8470 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8471 | ASSERT_VK_SUCCESS(err); |
| 8472 | |
| 8473 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8474 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8475 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8476 | ASSERT_VK_SUCCESS(err); |
| 8477 | |
| 8478 | BeginCommandBuffer(); |
| 8479 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8480 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8481 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8482 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8483 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8484 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8485 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8486 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8487 | resolveRegion.srcOffset.x = 0; |
| 8488 | resolveRegion.srcOffset.y = 0; |
| 8489 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8490 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8491 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8492 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8493 | resolveRegion.dstSubresource.layerCount = 0; |
| 8494 | resolveRegion.dstOffset.x = 0; |
| 8495 | resolveRegion.dstOffset.y = 0; |
| 8496 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8497 | resolveRegion.extent.width = 1; |
| 8498 | resolveRegion.extent.height = 1; |
| 8499 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8500 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8501 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8502 | EndCommandBuffer(); |
| 8503 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8504 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8505 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8506 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8507 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8508 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8509 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8510 | } |
| 8511 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8512 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 8513 | VkResult err; |
| 8514 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8515 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8516 | m_errorMonitor->SetDesiredFailureMsg( |
| 8517 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8518 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 8519 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8520 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8521 | |
| 8522 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8523 | VkImage srcImage; |
| 8524 | VkImage dstImage; |
| 8525 | VkDeviceMemory srcMem; |
| 8526 | VkDeviceMemory destMem; |
| 8527 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8528 | |
| 8529 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8530 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8531 | image_create_info.pNext = NULL; |
| 8532 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8533 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8534 | image_create_info.extent.width = 32; |
| 8535 | image_create_info.extent.height = 1; |
| 8536 | image_create_info.extent.depth = 1; |
| 8537 | image_create_info.mipLevels = 1; |
| 8538 | image_create_info.arrayLayers = 1; |
| 8539 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 8540 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8541 | // Note: Some implementations expect color attachment usage for any |
| 8542 | // multisample surface |
| 8543 | image_create_info.usage = |
| 8544 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8545 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8546 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8547 | err = |
| 8548 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8549 | ASSERT_VK_SUCCESS(err); |
| 8550 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8551 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 8552 | // Note: Some implementations expect color attachment usage for any |
| 8553 | // multisample surface |
| 8554 | image_create_info.usage = |
| 8555 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8556 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8557 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8558 | err = |
| 8559 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8560 | ASSERT_VK_SUCCESS(err); |
| 8561 | |
| 8562 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8563 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8564 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8565 | memAlloc.pNext = NULL; |
| 8566 | memAlloc.allocationSize = 0; |
| 8567 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8568 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8569 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8570 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8571 | pass = |
| 8572 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8573 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8574 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8575 | ASSERT_VK_SUCCESS(err); |
| 8576 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8577 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8578 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8579 | pass = |
| 8580 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8581 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8582 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8583 | ASSERT_VK_SUCCESS(err); |
| 8584 | |
| 8585 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8586 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8587 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8588 | ASSERT_VK_SUCCESS(err); |
| 8589 | |
| 8590 | BeginCommandBuffer(); |
| 8591 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8592 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 8593 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8594 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8595 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8596 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8597 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8598 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8599 | resolveRegion.srcOffset.x = 0; |
| 8600 | resolveRegion.srcOffset.y = 0; |
| 8601 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8602 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8603 | resolveRegion.dstSubresource.mipLevel = 0; |
| 8604 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 8605 | resolveRegion.dstSubresource.layerCount = 0; |
| 8606 | resolveRegion.dstOffset.x = 0; |
| 8607 | resolveRegion.dstOffset.y = 0; |
| 8608 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8609 | resolveRegion.extent.width = 1; |
| 8610 | resolveRegion.extent.height = 1; |
| 8611 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8612 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8613 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8614 | EndCommandBuffer(); |
| 8615 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8616 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8617 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8618 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8619 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8620 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8621 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8622 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8623 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8624 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8625 | // 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] | 8626 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 8627 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8628 | // The image format check comes 2nd in validation so we trigger it first, |
| 8629 | // 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] | 8630 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8631 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8632 | m_errorMonitor->SetDesiredFailureMsg( |
| 8633 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8634 | "Combination depth/stencil image formats can have only the "); |
| 8635 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8636 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8637 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8638 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8639 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 8640 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8641 | |
| 8642 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8643 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8644 | ds_pool_ci.pNext = NULL; |
| 8645 | ds_pool_ci.maxSets = 1; |
| 8646 | ds_pool_ci.poolSizeCount = 1; |
| 8647 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8648 | |
| 8649 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8650 | err = |
| 8651 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8652 | ASSERT_VK_SUCCESS(err); |
| 8653 | |
| 8654 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8655 | dsl_binding.binding = 0; |
| 8656 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 8657 | dsl_binding.descriptorCount = 1; |
| 8658 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8659 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8660 | |
| 8661 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8662 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8663 | ds_layout_ci.pNext = NULL; |
| 8664 | ds_layout_ci.bindingCount = 1; |
| 8665 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8666 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8667 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8668 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8669 | ASSERT_VK_SUCCESS(err); |
| 8670 | |
| 8671 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8672 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8673 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8674 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8675 | alloc_info.descriptorPool = ds_pool; |
| 8676 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8677 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8678 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8679 | ASSERT_VK_SUCCESS(err); |
| 8680 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8681 | VkImage image_bad; |
| 8682 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8683 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8684 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8685 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8686 | const int32_t tex_width = 32; |
| 8687 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8688 | |
| 8689 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8690 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8691 | image_create_info.pNext = NULL; |
| 8692 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8693 | image_create_info.format = tex_format_bad; |
| 8694 | image_create_info.extent.width = tex_width; |
| 8695 | image_create_info.extent.height = tex_height; |
| 8696 | image_create_info.extent.depth = 1; |
| 8697 | image_create_info.mipLevels = 1; |
| 8698 | image_create_info.arrayLayers = 1; |
| 8699 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8700 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8701 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 8702 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 8703 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8704 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8705 | err = |
| 8706 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8707 | ASSERT_VK_SUCCESS(err); |
| 8708 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8709 | image_create_info.usage = |
| 8710 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8711 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 8712 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8713 | ASSERT_VK_SUCCESS(err); |
| 8714 | |
| 8715 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8716 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8717 | image_view_create_info.image = image_bad; |
| 8718 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8719 | image_view_create_info.format = tex_format_bad; |
| 8720 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 8721 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 8722 | image_view_create_info.subresourceRange.layerCount = 1; |
| 8723 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8724 | image_view_create_info.subresourceRange.aspectMask = |
| 8725 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8726 | |
| 8727 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8728 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8729 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8730 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8731 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8732 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8733 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 8734 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8735 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8736 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 8737 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8738 | #endif // IMAGE_TESTS |
| 8739 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 8740 | int main(int argc, char **argv) { |
| 8741 | int result; |
| 8742 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 8743 | #ifdef ANDROID |
| 8744 | int vulkanSupport = InitVulkan(); |
| 8745 | if (vulkanSupport == 0) |
| 8746 | return 1; |
| 8747 | #endif |
| 8748 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 8749 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 8750 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 8751 | |
| 8752 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 8753 | |
| 8754 | result = RUN_ALL_TESTS(); |
| 8755 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 8756 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 8757 | return result; |
| 8758 | } |